Refine search
@Override public void endStartTag() throws IOException { if(otherAttributes.isEmpty()) { if(len!=0) { // sort is expensive even for size 0 array, // so it's worth checking len==0 if(!namedAttributesAreOrdered) Arrays.sort(staticAttributes,0,len); // this is the common case for( int i=0; i<len; i++ ) staticAttributes[i].write(); len = 0; } } else { // this is the exceptional case // sort all the attributes, not just the other attributes for( int i=0; i<len; i++ ) otherAttributes.add(staticAttributes[i].toDynamicAttribute()); len = 0; Collections.sort(otherAttributes); // write them all int size = otherAttributes.size(); for( int i=0; i<size; i++ ) { DynamicAttribute a = otherAttributes.get(i); super.attribute(a.prefix,a.localName,a.value); } otherAttributes.clear(); } super.endStartTag(); }
FinalArrayList<Class> classes = new FinalArrayList<Class>(); StringTokenizer tokens = new StringTokenizer(contextPath,":"); List<Class> indexedClasses; try { o = classLoader.loadClass(pkg+".ObjectFactory"); classes.add(o); foundObjectFactory = true; } catch (ClassNotFoundException e) { classes.addAll(indexedClasses); foundJaxbIndex = true; return createContext(classes.toArray(new Class[classes.size()]),properties);
private void addSubstitutionMember(ElementInfoImpl<T,C,F,M> child) { if(substitutionMembers==null) substitutionMembers = new FinalArrayList<ElementInfoImpl<T,C,F,M>>(); substitutionMembers.add(child); }
/** * Returns the namespace URI bound by the given prefix. * * @param prefix * Prefix to look up. */ String getNamespaceURI(@NotNull String prefix) { String nsDeclName = prefix.length()==0 ? "xmlns" : "xmlns:"+prefix; for( Scope sp=this; sp!=null; sp=sp.parent ) { for( int i=sp.currentNamespaces.size()-1; i>=0; i--) { Attr a = sp.currentNamespaces.get(i); if(a.getNodeName().equals(nsDeclName)) return a.getValue(); } for( int i=sp.additionalNamespaces.size()-2; i>=0; i-=2 ) if(sp.additionalNamespaces.get(i).equals(prefix)) return sp.additionalNamespaces.get(i+1); } return null; } }
_currentAttributes.clear(); for (int i = 0; i < n; i++) { final Attr attr = (Attr) _namedNodeMap.item(i); final String attrName = attr.getNodeName(); if (attrName.startsWith("xmlns:") || attrName.equals("xmlns")) { // NS decl? scope.currentNamespaces.add(attr); _currentAttributes.add(attr); for( int i=_currentAttributes.size()-1; i>=0; i-- ) { Attr a = _currentAttributes.get(i); if(fixNull(a.getNamespaceURI()).length()>0)
String getNamespacePrefix(int index) { int sz = currentNamespaces.size(); if(index< sz) { Attr attr = currentNamespaces.get(index); String result = attr.getLocalName(); if (result == null) { result = QName.valueOf(attr.getNodeName()).getLocalPart(); } return result.equals("xmlns") ? null : result; } else { return additionalNamespaces.get((index-sz)*2); } }
/** * Return an attribute's local name. Handle the case of DOM level 1 nodes. */ public String getAttributeLocalName(int index) { if (_state == START_ELEMENT) { String localName = _currentAttributes.get(index).getLocalName(); return (localName != null) ? localName : QName.valueOf(_currentAttributes.get(index).getNodeName()).getLocalPart(); } throw new IllegalStateException("DOMStreamReader: getAttributeLocalName() called in illegal state"); }
public String getAttributeNamespace(int index) { if (_state == START_ELEMENT) { String uri = _currentAttributes.get(index).getNamespaceURI(); return fixNull(uri); } throw new IllegalStateException("DOMStreamReader: getAttributeNamespace() called in illegal state"); }
public String getAttributeValue(int index) { if (_state == START_ELEMENT) { return _currentAttributes.get(index).getNodeValue(); } throw new IllegalStateException("DOMStreamReader: getAttributeValue() called in illegal state"); }
private static <T> List<T> makeSet( T... args ) { List<T> l = new FinalArrayList<T>(); for( T arg : args ) if(arg!=null) l.add(arg); return l; }
public void startDocument() { prefixMap.clear(); }
public int getAttributeCount() { if (_state == START_ELEMENT) return _currentAttributes.size(); throw new IllegalStateException("DOMStreamReader: getAttributeCount() called in illegal state"); }
public boolean hasProperties() { return !properties.isEmpty(); }
/** * Returns the namespace URI bound by the given prefix. * * @param prefix * Prefix to look up. */ String getNamespaceURI(@NotNull String prefix) { String nsDeclName = prefix.length()==0 ? "xmlns" : "xmlns:"+prefix; for( Scope sp=this; sp!=null; sp=sp.parent ) { for( int i=sp.currentNamespaces.size()-1; i>=0; i--) { Attr a = sp.currentNamespaces.get(i); if(a.getNodeName().equals(nsDeclName)) return a.getValue(); } for( int i=sp.additionalNamespaces.size()-2; i>=0; i-=2 ) if(sp.additionalNamespaces.get(i).equals(prefix)) return sp.additionalNamespaces.get(i+1); } return null; } }