Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see java.lang.Comparable#compareTo(java.lang.Object)
   */
  public int compareTo(Object obj) {
    if (this == obj) return 0;

    if (!(obj instanceof XMLNode)) return 0;

    XMLNode other = (XMLNode) obj;
    return (getOffset() > other.getOffset()) ? 1 : ((getOffset() < other.getOffset()) ? -1 : 0);
  }
Пример #2
0
 public XMLNode getAttributeAt(int offset) {
   List attrs = getAttributes();
   for (Iterator it = attrs.iterator(); it.hasNext(); ) {
     XMLNode artifact = (XMLNode) it.next();
     if (artifact.getOffset() <= offset && offset <= artifact.getOffset() + artifact.getLength())
       return artifact;
   }
   return null;
 }
Пример #3
0
 public synchronized void addChild(XMLNode childArtifact) {
   for (int i = 0; i < children.size(); i++) {
     if (((XMLNode) children.get(i)).getOffset() > childArtifact.getOffset()) {
       children.add(i, childArtifact);
       break;
     }
   }
   if (!children.contains(childArtifact)) children.add(childArtifact);
 }
Пример #4
0
  public List getChildrenAfter(XMLNode child) {
    List result = new ArrayList();
    for (int i = 0; i < children.size(); i++) {
      if (((XMLNode) children.get(i)).getOffset() > child.getOffset()) {
        result.add(child);
      }
    }

    return result;
  }