Esempio n. 1
0
 @Nullable
 public ElementStub getElementStub(String name, int index) {
   List<DomStub> stubs = getChildrenStubs();
   int i = 0;
   for (DomStub stub : stubs) {
     if (stub instanceof ElementStub && name.equals(stub.getName()) && i++ == index) {
       return (ElementStub) stub;
     }
   }
   return null;
 }
Esempio n. 2
0
  @Nullable
  public AttributeStub getAttributeStub(final XmlName name) {
    final List<DomStub> stubs = getChildrenStubs();
    if (stubs.isEmpty()) {
      return null;
    }

    //noinspection ForLoopReplaceableByForEach
    for (int i = 0, size = stubs.size(); i < size; i++) {
      final DomStub stub = stubs.get(i);
      if (stub instanceof AttributeStub && stub.getName().equals(name.getLocalName())) {
        return (AttributeStub) stub;
      }
    }
    return null;
  }
Esempio n. 3
0
  public List<DomStub> getChildrenByName(final CharSequence name, @Nullable final String nsKey) {
    final List<DomStub> stubs = getChildrenStubs();
    if (stubs.isEmpty()) {
      return Collections.emptyList();
    }

    final String s = nsKey == null ? "" : nsKey;
    final List<DomStub> result = new SmartList<DomStub>();
    //noinspection ForLoopReplaceableByForEach
    for (int i = 0, size = stubs.size(); i < size; i++) {
      final DomStub stub = stubs.get(i);
      if (XmlUtil.getLocalName(stub.getName()).equals(name)
          && Comparing.equal(s, stub.getNamespaceKey())) {
        result.add(stub);
      }
    }
    return result;
  }
Esempio n. 4
0
 public int getChildIndex(DomStub child) {
   List<DomStub> stubs =
       getChildrenByName(XmlUtil.getLocalName(child.getName()), child.getNamespaceKey());
   return stubs.indexOf(child);
 }