/** * <p>toXMLString.</p> * * @return a {@link java.lang.String} object. */ public String toXMLString(){ return name + '=' +XMLHelper.quote(value); } }
private XMLNode getChildNode(String name, String text){ XMLNode ret = new XMLNode(name); ret.setContent(text); return ret; }
/** * <p>createXMLNodeForListValue.</p> * * @param name a {@link java.lang.String} object. * @param contentType a {@link java.lang.String} object. * @param content a {@link java.util.List} object. * @param <T> a T object. * @return a {@link net.anotheria.util.xml.XMLNode} object. */ public static <T> XMLNode createXMLNodeForListValue(String name, String contentType, List<T> content){ XMLNode ret = new XMLNode(name); XMLNode val = new XMLNode("value"); ret.addChildNode(val); val.addAttribute(new XMLAttribute("type", "list")); val.addAttribute(new XMLAttribute("contentType", contentType)); for(Object c:content){ XMLNode el = new XMLNode("element"); val.addChildNode(el); el.setContent(""+c); } return ret; }
/** * Recursive - Write method. * * @param aWriter PrintStream writer. * @param aTabs position to start */ public void write(PrintStream aWriter, int aTabs) { String attributeString = createAttributeString(); String ident = XMLHelper.makeIdent(aTabs); aWriter.println(ident+XMLHelper.entag(name +attributeString)); for (XMLNode child : nodes) child.write(aWriter, aTabs+1); if (content!=null) aWriter.println(XMLHelper.makeIdent(aTabs+1)+"<![CDATA["+content+"]]>\n"); aWriter.println(ident+XMLHelper.detag(name)); }
/** * <p>toXMLNode.</p> * * @return a {@link net.anotheria.util.xml.XMLNode} object. */ public XMLNode toXMLNode(){ XMLNode e = new XMLNode("dataholder"); e.addAttribute( new XMLAttribute("id", getId())); return e; }
/** {@inheritDoc} */ @Override public XMLNode toXMLNode(){ XMLNode elem = super.toXMLNode(); elem.setContent(""); for (Property p : getList()){ elem.addChildNode(p.toXMLNode()); } return elem; }
/** * Writes the contents of the xml tree as xml to the given output writer. * * @param aWriter the writer to write the output to. * @throws java.io.IOException rethrown if thrown by the writer. */ public void write(OutputStreamWriter aWriter) throws IOException{ aWriter.write("<?xml version="+XMLHelper.quote(version)+" encoding="+XMLHelper.quote(encoding)+"?>\n"); if (root!=null) root.write(aWriter, 0); }
/** * <p>write.</p> * * @param tree a {@link net.anotheria.util.xml.XMLTree} object. * @param stream a {@link java.io.OutputStream} object. * @return a {@link java.io.OutputStreamWriter} object. * @throws java.io.IOException if any. */ public static OutputStreamWriter write(XMLTree tree, OutputStream stream) throws IOException{ OutputStreamWriter writer = new OutputStreamWriter(stream, tree.getEncoding()); tree.write(writer); writer.flush(); return writer; } }
/** * <p>toXMLNode.</p> * * @return a {@link net.anotheria.util.xml.XMLNode} object. */ public XMLNode toXMLNode(){ return new XMLNode("NotImplemented "+getId()); }
/** * Areates attribute string. */ private String createAttributeString(){ String ret = ""; if (attributes == null || attributes.isEmpty()) return ret; for (XMLAttribute a : attributes){ ret += ' ' +a.toXMLString(); } return ret; }
private static XMLNode createXMLNodeWithContent(String name, String[] languages, String type, Object... value){ XMLNode ret = new XMLNode(name); if (languages==null){ XMLNode val = new XMLNode("value"); if (type!=null) val.addAttribute(new XMLAttribute("type", type)); ret.addChildNode(val); if (value!=null) val.setContent(""+value[0]); }else{ for (int i=0; i<languages.length; i++){ String l = languages[i]; XMLNode val = new XMLNode("value"); if (type!=null) val.addAttribute(new XMLAttribute("type", type)); val.addAttribute(new XMLAttribute("language", l)); if (value!=null){ Object valueToSet = value[i]!=null?value[i]:""; val.setContent("" + valueToSet); } ret.addChildNode(val); } } return ret; }
/** * Recursive - Write method. * * @param aWriter PrintWriter * @param aTabs position to start */ public void write(PrintWriter aWriter, int aTabs) { String attributeString = createAttributeString(); String ident = XMLHelper.makeIdent(aTabs); aWriter.write(ident+XMLHelper.entag(name +attributeString)); for (XMLNode child : nodes) child.write(aWriter, aTabs+1); if (content!=null) aWriter.write(XMLHelper.makeIdent(aTabs+1)+"<![CDATA["+content+"]]>\n"); aWriter.write(ident+XMLHelper.detag(name)); }
/** {@inheritDoc} */ @Override public XMLNode toXMLNode(){ return new XMLNode("NotImplemented "+getId()); }
private static XMLNode createXMLNodeWithAttribute(String name, String[] languages, String type, Object... value){ XMLNode ret = new XMLNode(name); if (languages==null){ XMLNode val = new XMLNode("value"); if (type!=null) val.addAttribute(new XMLAttribute("type", type)); ret.addChildNode(val); if (value!=null) val.addAttribute(new XMLAttribute("value", ""+value[0])); }else{ for (int i=0; i<languages.length; i++){ String l = languages[i]; System.out.println(l+" -> "+value[i]); XMLNode val = new XMLNode("value"); if (type!=null) val.addAttribute(new XMLAttribute("type", type)); val.addAttribute(new XMLAttribute("language", l)); if (value!=null) val.addAttribute(new XMLAttribute("value", ""+value[i])); ret.addChildNode(val); } } return ret; }
/** * Recursive - Write method. * * @param aWriter java.io.Writer * @param aTabs tabs */ public void write(Writer aWriter, int aTabs) { try{ String attributeString = createAttributeString(); String ident = XMLHelper.makeIdent(aTabs); aWriter.write(ident+XMLHelper.entag(name +attributeString)); for (XMLNode child : nodes) child.write(aWriter, aTabs+1); if (content!=null) aWriter.write(XMLHelper.makeIdent(aTabs+1)+"<![CDATA["+content+"]]>\n"); aWriter.write(ident+XMLHelper.detag(name)); }catch(Throwable t){ log.error(t.getMessage(), t); } } }
/** {@inheritDoc} */ @Override public XMLNode toXMLNode(){ XMLNode root = new XMLNode("documentlist"); root.addAttribute(new XMLAttribute("listId", getId())); for (D d : list){ root.addChildNode(d.toXMLNode()); } return root; }
/** * Creates an xml node for export. * * @return new XMLNode object */ public XMLNode toXMLNode(){ XMLNode ret = new XMLNode("property"); ret.addAttribute(new XMLAttribute("name", getName())); ret.addAttribute(new XMLAttribute("type", getPropertyType().toString())); ret.setContent(""+getValue()); return ret; }
/** * Creates an XMLNode for XML export. * * @return a {@link net.anotheria.util.xml.XMLNode} object. */ public XMLNode toXMLNode(){ XMLNode root = new XMLNode("module"); root.addAttribute(new XMLAttribute("moduleId", getId())); root.addAttribute(new XMLAttribute("copyId", getCopyId())); root.addAttribute(new XMLAttribute("ownerId", getOwnerId())); root.addAttribute(new XMLAttribute("size", ""+getSizeInBytes())); Collection<DataHolder> myDataHolders = holders.values(); for (DataHolder dh : myDataHolders){ root.addChildNode(dh.toXMLNode()); } return root; }
/** {@inheritDoc} */ @Override public XMLNode toXMLNode(){ XMLNode root = new XMLNode("document"); root.addAttribute(new XMLAttribute("documentId", getId())); for (Iterator<DataHolder> it = dataStorage.values().iterator(); it.hasNext();) root.addChildNode(it.next().toXMLNode()); return root; }
/** * Creates the XMLNode for xml representation of this object info. * * @return created XMLNode */ public XMLNode toXML(){ XMLNode ret = new XMLNode("objectinfo"); ret.addAttribute(new XMLAttribute("id",getId())); ret.addChildNode(getChildNode("id", getId())); ret.addChildNode(getChildNode("type", getType())); ret.addChildNode(getChildNode("timestamp", ""+getLastChangeTimestamp())); ret.addChildNode(getChildNode("iso8601timestamp", NumberUtils.makeISO8601TimestampString(getLastChangeTimestamp()))); ret.addChildNode(getChildNode("footprint", getFootprint())); return ret; }