/** * Can be used to encode values that contain invalid XML characters. At SAX parser end must be * used pair method to get original value. * * @param val data to be converted * @param start offset * @param len count * @since 1.29 */ public static String toHex(byte[] val, int start, int len) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < len; i++) { byte b = val[start + i]; buf.append(DEC2HEX[(b & 0xf0) >> 4]); buf.append(DEC2HEX[b & 0x0f]); } return buf.toString(); }
/** * Makes an XML text representation. * * @param buffer */ public void makeTextElement(StringBuffer buffer) { int size; buffer.append("<legal"); if (id_ != null) { buffer.append(" id=\""); buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getId()))); buffer.append("\""); } if (xmlLang_ != null) { buffer.append(" xml:lang=\""); buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getXmlLang()))); buffer.append("\""); } size = this.content_.size(); for (int i = 0; i < size; i++) { IFtContentMixMixed value = (IFtContentMixMixed) this.content_.get(i); value.makeTextAttribute(buffer); } buffer.append(">"); size = this.content_.size(); for (int i = 0; i < size; i++) { IFtContentMixMixed value = (IFtContentMixMixed) this.content_.get(i); value.makeTextElement(buffer); } buffer.append("</legal>"); }
public String toString() { StringBuffer sb = new StringBuffer(); sb.append(sourcepid + "," + sourceNode + "," + targetpid + "," + targetNode + ","); Iterator<LayoutPoint> e = bends.iterator(); LayoutPoint b; while (e.hasNext()) { b = (LayoutPoint) e.next(); sb.append(b.x + "," + b.y + ","); } sb.append("\n"); return sb.toString(); }
private static String readFileAsString(String filePath) throws IOException { StringBuffer fileData = new StringBuffer(); BufferedReader reader = new BufferedReader(new FileReader(filePath)); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { String readData = String.valueOf(buf, 0, numRead); fileData.append(readData); } reader.close(); return fileData.toString(); }
private String getFeatureIDs() { StringBuffer buffer = new StringBuffer(); Object[] objects = fPage.getSelectedItems(); for (int i = 0; i < objects.length; i++) { Object object = objects[i]; if (object instanceof IFeatureModel) { buffer.append(((IFeatureModel) object).getFeature().getId()); if (i < objects.length - 1) buffer.append(","); // $NON-NLS-1$ } } return buffer.toString(); }
public String toString() { if (isEmpty()) { return ""; } StringBuffer sb = new StringBuffer(); Iterator<NodeLayout> e = nodes.iterator(); while (e.hasNext()) sb.append((e.next()).toString()); sb.append("\n"); Iterator<EdgeLayout> ee = edges.iterator(); while (ee.hasNext()) sb.append((ee.next()).toString()); return sb.toString(); }
/** * ** Filters an ID String, convertering all letters to lowercase and ** removing invalid * characters ** @param text The ID String to filter ** @return The filtered ID String */ public static String FilterID(String text) { // ie. "sky.12", "acme@123" if (text != null) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < text.length(); i++) { char ch = Character.toLowerCase(text.charAt(i)); if (DBRecordKey.isValidIDChar(ch)) { sb.append(ch); } } return sb.toString(); } else { return ""; } }
/** * ** Returns a string representation of this object ** @return The string representation of this * object */ public String toString() { DBField kf[] = this.getKeyFields(); if (kf.length == 0) { return "<null>"; } else { DBFieldValues fv = this.getFieldValues(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < kf.length; i++) { if (i > 0) { sb.append(","); } sb.append(fv.getFieldValueAsString(kf[i].getName())); } return sb.toString(); } }
/* return the value of the XML text node (never null) */ protected static String GetNodeText(Node root) { StringBuffer sb = new StringBuffer(); if (root != null) { NodeList list = root.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node n = list.item(i); if (n.getNodeType() == Node.CDATA_SECTION_NODE) { // CDATA Section sb.append(n.getNodeValue()); } else if (n.getNodeType() == Node.TEXT_NODE) { sb.append(n.getNodeValue()); } else { // Print.logWarn("Unrecognized node type: " + n.getNodeType()); } } } return sb.toString(); }
/** * Escape passed string as XML attibute value (<code><</code>, <code>&</code>, <code>' * </code> and <code>"</code> will be escaped. Note: An XML processor returns normalized value * that can be different. * * @param val a string to be escaped * @return escaped value * @throws CharConversionException if val contains an improper XML character * @since 1.40 */ public static String toAttributeValue(String val) throws CharConversionException { if (val == null) throw new CharConversionException("null"); // NOI18N if (checkAttributeCharacters(val)) return val; StringBuffer buf = new StringBuffer(); for (int i = 0; i < val.length(); i++) { char ch = val.charAt(i); if ('<' == ch) { buf.append("<"); continue; } else if ('&' == ch) { buf.append("&"); continue; } else if ('\'' == ch) { buf.append("'"); continue; } else if ('"' == ch) { buf.append("""); continue; } buf.append(ch); } return buf.toString(); }
public Element reportDtElem() { StringBuffer sb = new StringBuffer(255); sb.append(shortTypeName); sb.append(" [ dataSourceName: "); sb.append(pds.getDataSourceName()); sb.append("; identityToken: "); sb.append(pds.getIdentityToken()); sb.append(" ]"); Element dtElem = doc.createElement("dt"); dtElem.appendChild(doc.createTextNode(sb.toString())); return dtElem; }
public String toBeautifiedString() { StringBuffer sb = new StringBuffer(); Iterator<NodeLayout> e = nodes.iterator(); while (e.hasNext()) sb.append((e.next()).toBeautifiedString()); sb.append("\n"); Iterator<EdgeLayout> ee = edges.iterator(); while (ee.hasNext()) { sb.append((ee.next()).toBeautifiedString()); } sb.append("\n\nNumber of Nodes: "); sb.append(nodes.size()); sb.append("\nNumber of Edges: "); sb.append(edges.size() + "\n"); return sb.toString(); }
public String toBeautifiedString() { StringBuffer sb = new StringBuffer(); sb.append("PID: " + processID); sb.append(" Node id: " + nodeID); if (cofactor.equalsIgnoreCase("true")) { sb.append("\n is Cofactor. "); } sb.append("\n"); sb.append(" x: " + x + " y: " + y + "\n\n"); return sb.toString(); }
/** @param tag */ private String makeElementNameFromHexadecimalGroupElementValues(AttributeTag tag) { StringBuffer str = new StringBuffer(); str.append("HEX"); // XML element names not allowed to start with a number String groupString = Integer.toHexString(tag.getGroup()); for (int i = groupString.length(); i < 4; ++i) str.append("0"); str.append(groupString); String elementString = Integer.toHexString(tag.getElement()); for (int i = elementString.length(); i < 4; ++i) str.append("0"); str.append(elementString); return str.toString(); }
public String toBeautifiedString() { StringBuffer sb = new StringBuffer(); sb.append("sourcePID: " + sourcepid); sb.append(" sourceNodeId: " + sourceNode + "\n"); sb.append(" targetPID: " + targetpid); sb.append(" targetNodeId: " + targetNode + "\n"); Iterator<LayoutPoint> e = bends.iterator(); LayoutPoint b; while (e.hasNext()) { b = (LayoutPoint) e.next(); sb.append(" Bend Points: " + b.x + "," + b.y + " "); } sb.append("\n\n"); return sb.toString(); }
/** ** Encodes this DBRecordKey into XML for "GTSRequest' purposes */ private StringBuffer toRequestXML(StringBuffer sb, int indent) { boolean isSoapReq = false; if (sb == null) { sb = new StringBuffer(); } DBRecordKey<gDBR> recKey = this; String tableName = recKey.getTableName(); DBField fld[] = recKey.getKeyFields(); // KEY fields DBFieldValues fldVals = recKey.getFieldValues(); String PFX1 = XMLTools.PREFIX(isSoapReq, indent); sb.append(PFX1); sb.append( XMLTools.startTAG( isSoapReq, DBFactory.TAG_Record, XMLTools.ATTR(DBFactory.ATTR_table, tableName), false, true)); DBFactory.writeXML_DBFields(sb, 2 * indent, fld, fldVals, isSoapReq); sb.append(PFX1); sb.append(XMLTools.endTAG(isSoapReq, DBFactory.TAG_Record, true)); return sb; }
private static void showDocument(Document doc) { StringBuffer content = new StringBuffer(); Node node = doc.getChildNodes().item(0); ApplicationNode appNode = new ApplicationNode(node); content.append("Application \n"); List<ClassNode> classes = appNode.getClasses(); for (int i = 0; i < classes.size(); i++) { ClassNode classNode = classes.get(i); content.append(SPACE + "Class: " + classNode.getName() + " \n"); List<MethodNode> methods = classNode.getMethods(); for (int j = 0; j < methods.size(); j++) { MethodNode methodNode = methods.get(j); content.append(SPACE + SPACE + "Method: " + methodNode.getName() + " \n"); } } System.out.println(content.toString()); }
/** * Makes a XML text representation. * * @param buffer */ public void makeTextElement(StringBuffer buffer) { int size; String prefix = rNSContext_.getPrefixByUri("http://www.asahi-net.or.jp/~cs8k-cyu/bulletml"); buffer.append("<"); URelaxer.makeQName(prefix, "direction", buffer); rNSContext_.makeNSMappings(buffer); if (type_ != null) { buffer.append(" "); buffer.append("type"); buffer.append("=\""); buffer.append(URelaxer.escapeAttrQuot(getType())); buffer.append("\""); } buffer.append(">"); buffer.append("</"); URelaxer.makeQName(prefix, "direction", buffer); buffer.append(">"); }
private void logResultInfo(Query query, String queryResult) { StringBuffer sb = new StringBuffer(); sb.append( "\n\n\tQuery " + query.getNr() + " of run " + (query.getQueryMix().getQueryMixRuns() + 1) + ":\n"); sb.append("\n\tQuery string:\n\n"); sb.append(query.getQueryString()); sb.append("\n\n\tResult:\n\n"); sb.append(queryResult); sb.append( "\n\n__________________________________________________________________________________\n"); logger.log(Level.ALL, sb.toString()); }
/** * ** Encodes this DBRecordKey into XML ** @param sb The StringBuffer to which the DBRecord XML is * writen ** @param indent The number of spaces to indent ** @param sequence An optional record * sequence number ** @param soapXML True for SOAP XML ** @return The StringBuffer */ public StringBuffer toXML(StringBuffer sb, int indent, int sequence, boolean soapXML) { if (sb == null) { sb = new StringBuffer(); } String prefix = StringTools.replicateString(" ", indent); DBRecordKey<gDBR> recKey = this; String tableName = recKey.getTableName(); DBField fld[] = recKey.getKeyFields(); // KEY fields DBFieldValues fldVals = recKey.getFieldValues(); String PFX1 = XMLTools.PREFIX(soapXML, indent); sb.append(PFX1); sb.append( XMLTools.startTAG( soapXML, DBFactory.TAG_RecordKey, XMLTools.ATTR(DBFactory.ATTR_table, tableName) + ((sequence > 0) ? XMLTools.ATTR(DBFactory.ATTR_sequence, sequence) : ""), false, true)); DBFactory.writeXML_DBFields(sb, 2 * indent, fld, fldVals, soapXML); sb.append(PFX1); sb.append(XMLTools.endTAG(soapXML, DBFactory.TAG_RecordKey, true)); return sb; }
public String toString() { StringBuffer sb = new StringBuffer(); sb.append(processID + ","); sb.append(nodeID + ","); if (cofactor.equalsIgnoreCase("true")) { sb.append("cofactor"); } sb.append("," + x + "," + y + "\n"); return sb.toString(); }
/** * Makes an XML text representation. * * @param buffer */ public void makeTextElement(StringBuffer buffer) { int size; buffer.append("<authors"); if (id_ != null) { buffer.append(" id=\""); buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getId()))); buffer.append("\""); } if (xmlLang_ != null) { buffer.append(" xml:lang=\""); buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getXmlLang()))); buffer.append("\""); } buffer.append(">"); size = this.person_.size(); for (int i = 0; i < size; i++) { FtPerson value = (FtPerson) this.person_.get(i); value.makeTextElement(buffer); } buffer.append("</authors>"); }
/** * Makes an XML text representation. * * @param buffer */ public void makeTextElement(StringBuffer buffer) { int size; buffer.append("<header"); if (id_ != null) { buffer.append(" id=\""); buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getId()))); buffer.append("\""); } if (xmlLang_ != null) { buffer.append(" xml:lang=\""); buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getXmlLang()))); buffer.append("\""); } buffer.append(">"); title_.makeTextElement(buffer); if (subtitle_ != null) { subtitle_.makeTextElement(buffer); } if (version_ != null) { version_.makeTextElement(buffer); } if (type_ != null) { type_.makeTextElement(buffer); } if (authors_ != null) { authors_.makeTextElement(buffer); } size = this.notice_.size(); for (int i = 0; i < size; i++) { FtNotice value = (FtNotice) this.notice_.get(i); value.makeTextElement(buffer); } if (abstract_ != null) { abstract_.makeTextElement(buffer); } buffer.append("</header>"); }
private static String FilterID(String id) { if (id == null) { return null; } else { StringBuffer newID = new StringBuffer(); int st = 0; for (int i = 0; i < id.length(); i++) { char ch = Character.toLowerCase(id.charAt(i)); if (Character.isLetterOrDigit(ch)) { newID.append(ch); st = 1; } else if (st == 1) { newID.append("_"); st = 0; } else { // ignore char } } while ((newID.length() > 0) && (newID.charAt(newID.length() - 1) == '_')) { newID.setLength(newID.length() - 1); } return newID.toString(); } }
/** * Makes an XML text representation. * * @param buffer */ public void makeTextElement(StringBuffer buffer) { int size; buffer.append("<table"); if (id_ != null) { buffer.append(" id=\""); buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getId()))); buffer.append("\""); } if (xmlLang_ != null) { buffer.append(" xml:lang=\""); buffer.append(URelaxer.escapeAttrQuot(URelaxer.getString(getXmlLang()))); buffer.append("\""); } buffer.append(">"); if (caption_ != null) { caption_.makeTextElement(buffer); } size = this.tr_.size(); for (int i = 0; i < size; i++) { FcTr value = (FcTr) this.tr_.get(i); value.makeTextElement(buffer); } buffer.append("</table>"); }
/** * @param node * @param indent */ public static String toString(Node node, int indent) { StringBuffer str = new StringBuffer(); for (int i = 0; i < indent; ++i) str.append(" "); str.append(node); if (node.hasAttributes()) { NamedNodeMap attrs = node.getAttributes(); for (int j = 0; j < attrs.getLength(); ++j) { Node attr = attrs.item(j); // str.append(toString(attr,indent+2)); str.append(" "); str.append(attr); } } str.append("\n"); ++indent; for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { str.append(toString(child, indent)); // str.append("\n"); } return str.toString(); }
/** * Escape passed string as XML element content (<code><</code>, * <code>&</code> and <code>><code> in <code>]]></code> sequences). * * @param val a string to be escaped * * @return escaped value * @throws CharConversionException if val contains an improper XML character * * @since 1.40 */ public static String toElementContent(String val) throws CharConversionException { if (val == null) throw new CharConversionException("null"); // NOI18N if (checkContentCharacters(val)) return val; StringBuffer buf = new StringBuffer(); for (int i = 0; i < val.length(); i++) { char ch = val.charAt(i); if ('<' == ch) { buf.append("<"); continue; } else if ('&' == ch) { buf.append("&"); continue; } else if ('>' == ch && i > 1 && val.charAt(i - 2) == ']' && val.charAt(i - 1) == ']') { buf.append(">"); continue; } buf.append(ch); } return buf.toString(); }
/** * Makes a XML text representation. * * @param buffer */ public void makeTextElement(StringBuffer buffer) { int size; String prefix = rNSContext_.getPrefixByUri("http://www.iso_relax.org/xmlns/miaou/binaryTreeAutomaton"); buffer.append("<"); URelaxer.makeQName(prefix, "textTransition", buffer); rNSContext_.makeNSMappings(buffer); buffer.append(" "); buffer.append("target"); buffer.append("=\""); buffer.append(URelaxer.getString(getTarget())); buffer.append("\""); buffer.append(" "); buffer.append("right"); buffer.append("=\""); buffer.append(URelaxer.getString(getRight())); buffer.append("\""); buffer.append(">"); buffer.append("</"); URelaxer.makeQName(prefix, "textTransition", buffer); buffer.append(">"); }
// Log the error private void log(int level, SAXParseException e) { int line = e.getLineNumber(); int col = e.getColumnNumber(); String publicId = e.getPublicId(); String systemId = e.getSystemId(); StringBuffer sb = new StringBuffer(); sb.append(e.getMessage()); if (line > 0 || col > 0) { sb.append(": line="); sb.append(line); sb.append(", col="); sb.append(col); } if (publicId != null || systemId != null) { sb.append(": publicId="); sb.append(publicId); sb.append(", systemId="); sb.append(systemId); } // Log the message log.log(level, sb.toString()); }
/** * Makes a XML text representation. * * @param buffer */ public void makeTextElement(StringBuffer buffer) { int size; String prefix = rNSContext_.getPrefixByUri("http://www.iso_relax.org/xmlns/miaou/binaryTreeAutomaton"); buffer.append("<"); URelaxer.makeQName(prefix, "nonExistentAttributeTransition", buffer); rNSContext_.makeNSMappings(buffer); buffer.append(" "); buffer.append("target"); buffer.append("=\""); buffer.append(URelaxer.getString(getTarget())); buffer.append("\""); buffer.append(" "); buffer.append("nameClass"); buffer.append("=\""); buffer.append(URelaxer.getString(getNameClass())); buffer.append("\""); if (exceptNameClass_ != null) { buffer.append(" "); buffer.append("exceptNameClass"); buffer.append("=\""); buffer.append(URelaxer.getString(getExceptNameClass())); buffer.append("\""); } buffer.append(" "); buffer.append("right"); buffer.append("=\""); buffer.append(URelaxer.getString(getRight())); buffer.append("\""); buffer.append(">"); buffer.append("</"); URelaxer.makeQName(prefix, "nonExistentAttributeTransition", buffer); buffer.append(">"); }