/** * Leave enclosing element */ @Override void leaveEnclosingElement() throws IOException { depthCounter.decLevel(); if(tagQ.size() == 0) throw new IOException("Tried to exit non-existent enclosing element " + "in EditLog file"); EditsElement element = tagQ.pop(); printIndents(); write("</" + element.toString() + ">\n"); }
/** * Write an XML tag * * @param tag a tag name * @param value a tag value */ private void writeTag(String tag, String value) throws IOException { printIndents(); if(value.length() > 0) { write("<" + tag + ">" + value + "</" + tag + ">\n"); } else { write("<" + tag + "/>\n"); } }
/** * Visit an enclosing element (element that cntains other elements) * * @param value a Token to visit */ @Override void visitEnclosingElement(Tokenizer.Token value) throws IOException { printIndents(); write("<" + value.getEditsElement().toString() + ">\n"); tagQ.push(value.getEditsElement()); depthCounter.incLevel(); }
/** * Visit a Token * * @param value a Token to visit */ @Override Tokenizer.Token visit(Tokenizer.Token value) throws IOException { EditsElement ele = value.getEditsElement(); if (ele == EditsElement.OPCODE) { printIndents(); write("<OFFSET>" + value.offset + "</OFFSET>\n"); } writeTag(value.getEditsElement().toString(), value.toString()); return value; }