Ejemplo n.º 1
0
 /* (non-Javadoc)
  * @see org.eclipse.ohf.utilities.xml.IXMLWriter#start()
  */
 @Override
 public void start() throws IOException {
   condition(!started, "attempt to start after starting");
   levels.clear();
   attributes = null;
   try {
     if (xmlHeader) {
       write("<?xml version=\"1.0\" encoding=\"" + getXMLCharsetName(charset) + "\"?>");
       if (prettyBase || prettyHeader) write(lineType == LINE_UNIX ? "\n" : "\r\n");
     }
   } catch (UnsupportedEncodingException e) {
     // TODO Auto-generated catch block
     throw new IOException(e.getMessage());
   }
   started = true;
 }
Ejemplo n.º 2
0
  private void addAttribute(String name, String value, boolean noLines) throws IOException {
    if (!XMLUtil.isNMToken(name))
      throw new IOException("XML name " + name + " is not valid for value '" + value + "'");

    newLevelIfRequired();
    value = XMLUtil.escapeXML(value, charset, noLines);

    if (attributes == null) attributes = new String[][] {{name, value}};
    else {
      String[][] newattr = new String[attributes.length + 1][];
      for (int i = 0; i < attributes.length; i++) {
        condition(
            !attributes[i][0].equals(name),
            "attempt to define attribute with name "
                + name
                + " more than once for value '"
                + value
                + "'");
        newattr[i] = attributes[i];
      }
      attributes = newattr;
      attributes[attributes.length - 1] = new String[] {name, value};
    }
  }
Ejemplo n.º 3
0
 private void checkInElement() throws IOException {
   condition(levels.size() > 0, "not in an element");
 }
Ejemplo n.º 4
0
 private void checkStarted() throws IOException {
   condition(started, "not started");
 }