/* (non-Javadoc)
@see tuwien.auto.calimero.xml.XMLWriter#writeElement
(java.lang.String, java.util.List, java.lang.String)
979806
public void writeElement(String name, List att, String content) throws KNXMLException
	{
		try {
			final Tag tag = new Tag(name, att, content, false);
			layout.push(tag);
		}
		catch (final IOException e) {
			throw new KNXMLException(e.getMessage());
		}
	}
524557
public void writeSingleLineTextElement(String elementName, String text) throws IOException {
		if (elementName == null || elementName.length() == 0) {
			return;
		}
		if (text == null || text.length() == 0) {
			return;
		}
		addElementName(elementName);		
		indent();		
		writer.write("<");
		writer.write(elementName);
		writer.write(">");
		writer.write(escapeXml(text));
		writer.write("</");
		writer.write(elementName);
		writer.write(">\n");						
		removeElementName(elementName);
	}
1127391
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    writer.newLine();
    writer.taggedValue("tick", _tick);
    writer.taggedValue("protocolState", _protocolState);
  }
348477
public void write(EnumType type) throws XMLStreamException {

        LOG.debug("Writing type {} of type {}", type.getName(), type.getMetaType());

        xmlWriter.writeStartElement(ENUM_TYPE);
        xmlWriter.writeAttribute(NAME, type.getName());
        for (EnumMember member : type.getMembers()) {
            xmlWriter.writeStartElement(ENUM_MEMBER);
            xmlWriter.writeAttribute(NAME, member.getName());
            xmlWriter.writeEndElement();
        }
        xmlWriter.writeEndElement();
    }
1341526
public void writeSingleLineDateElement(String elementName, Date value) throws IOException {
		if (elementName == null || elementName.length() == 0) {
			return;
		}
		if (value == null) {
			return;
		}
		addElementName(elementName);		
		indent();		
		writer.write("<");
		writer.write(elementName);
		writer.write(">");
		writer.write(DATE_FORMAT.format(value));
		writer.write("</");
		writer.write(elementName);
		writer.write(">\n");						
		removeElementName(elementName);
	}
817970
public void write(Writer out)
         throws IOException
    {
        if (codeBase != null)
            attribute("codebase",codeBase);
        
        if (debug)
            paramHolder.add("<param name=\"debug\" value=\"yes\">");
        if (params != null)
            for (Enumeration enm = params.keys(); enm.hasMoreElements();)
            {
                String key = enm.nextElement().toString();
                paramHolder.add("<param name=\"" + key + "\" value=\"" +
                                params.get(key).toString() + "\">");
            }
        super.write(out);
    }
965610
@Override
    public void xmlWriteOn(FormattedWriter writer) throws IOException
    {
        super.xmlWriteOn(writer);
        writer.newLine();
        writer.taggedValue("toBeDeleted", _toBeDeleted);
        writer.newLine();
        writer.taggedValue("toBeIgnored", _toBeIgnored);
    }
154674
protected void writeElementContent(char[] buf, int off, int len, Writer out) throws IOException {
		// esccape '<', '&', ']]>'
		final int end = off + len;
		int pos = off;
		for (int i = off; i < end; i++) {
			final char ch = buf[i];
			if (ch == ']') {
				if (seenBracket) {
					seenBracketBracket = true;
				} else {
					seenBracket = true;
				}
			} else {
				if (ch == '&') {
					if (i > pos) {
						out.write(buf, pos, i - pos);
					}
					out.write("&amp;");
					pos = i + 1;
				} else if (ch == '<') {
					if (i > pos) {
						out.write(buf, pos, i - pos);
					}
					out.write("&lt;");
					pos = i + 1;

				} else if (seenBracketBracket && ch == '>') {
					if (i > pos) {
						out.write(buf, pos, i - pos);
					}
					out.write("&gt;");
					pos = i + 1;
				} else if (ch < 32) {
					// in XML 1.0 only legal character are #x9 | #xA | #xD
					if (ch == 9 || ch == 10 || ch == 13) {
						// pass through

						// } else if(ch == 13 ) { //if(ch == '\r') {
						// if(i > pos) {
						// out.write(buf, pos, i - pos);
						// }
						// out.write("&#");
						// out.write(Integer.toString(ch));
						// out.write(';');
						// pos = i + 1;
					} else {
						if (TRACE_ESCAPING)
							System.err.println(getClass().getName() + " DEBUG TEXT value.len=" + len + " " + printable(new String(buf, off, len)));
						throw new IllegalStateException("character " + printable(ch) + " (" + Integer.toString(ch) + ") is not allowed in output" + getLocation());
						// in XML 1.1 legal are [#x1-#xD7FF]
						// if(ch > 0) {
						// if(i > pos) out.write(text.substring(pos, i));
						// out.write("&#");
						// out.write(Integer.toString(ch));
						// out.write(';');
						// pos = i + 1;
						// } else {
						// throw new IllegalStateException(
						// "character zero is not allowed in XML 1.1
						// output"+getLocation());
						// }
					}
				}
				if (seenBracket) {
					seenBracketBracket = seenBracket = false;
				}
				// assert seenBracketBracket == seenBracket == false;
			}
		}
		if (end > pos) {
			out.write(buf, pos, end - pos);
		}
	}
513626
public final void write(Throwable e) throws IOException {
    indent();
    newLine();

    write(e.toString());

    StackTraceElement[] elements = e.getStackTrace();
    for (int i = 0; i < elements.length; i++) {
      newLine();
      write(elements[i].toString());
    }

    Throwable cause = e.getCause();
    if (cause != null) {
      newLine();
      write(cause.toString());
    }

    outdent();
  }
697242
public void write(BufferedWriter writer) throws Exception {
		Enumeration enm;

		// header
		writer.write("# generated " + new Date());
		writer.newLine();

		enm = elements();

		while (enm.hasMoreElements()) {
			writer.write(enm.nextElement().toString());
			writer.newLine();
		}

		writer.flush();
		writer.close();
	}
8420
public void write(Writer out)
         throws IOException
    {
        writeHtmlHead(out);
        writeBodyTag(out);
        writeElements(out);
        writeHtmlEnd(out);
    }
1034076
public static void write(JsonElement element, JsonWriter writer) throws IOException {
    TypeAdapters.JSON_ELEMENT.write(writer, element);
  }
214727
public void writeContent(final XMLUtil xmlUtil, final ZipUTF8Writer writer) throws IOException {
        this.logger.log(Level.FINER, "Writing odselement: contentElement to zip file");
        this.contentElement.write(xmlUtil, writer);
    }
1016244
public void write(Collection<? extends E> elements) throws IOException {
		final Progression progressBar = getTaskProgression();
		Progression subTask = null;

		if (progressBar != null) {
			progressBar.setProperties(0, 0, (elements.size() + 1) * 100, false);
		}

		if (this.fileBounds == null) {
			this.fileBounds = getFileBounds();
		}

		if (this.fileBounds != null) {
			writeHeader(this.fileBounds, this.elementType, elements);

			if (progressBar != null) {
				progressBar.setValue(100);
				subTask = progressBar.subTask(elements.size() * 100);
				subTask.setProperties(0, 0, elements.size(), false);
			}

			for (final E element : elements) {

				writeElement(this.recordIndex, element, this.elementType);

				if (subTask != null) {
					subTask.setValue(this.recordIndex + 1);
				}

				++this.recordIndex;

			}
		} else {
			throw new BoundsNotFoundException();
		}

		if (progressBar != null) {
			progressBar.end();
		}
	}
1070117
public void writeEndElement() throws XMLStreamException {
		try {
			this.checkPendingATEvents();
			encoder.encodeEndElement();
		} catch (Exception e) {
			throw new XMLStreamException(e.getLocalizedMessage(), e);
		}
	}
1215532
public synchronized void addElement(T element) {
    checkArgument(
        element.getNext() == null && element.getPrev() == null && element != head,
        "Element already in a list.");
    size++;
    if (head == null) {
      head = element;
    } else {
      head.setPrev(element);
      element.setNext(head);
      head = element;
    }
  }
60328
public void save(XMLWriter w) throws KNXMLException
	{
		w.writeElement(TAG_DATAPOINTS, Collections.EMPTY_LIST, null);
		synchronized (points) {
			for (final Iterator i = points.values().iterator(); i.hasNext();)
				((Datapoint) i.next()).save(w);
		}
		w.endElement();
	}