/** * Copy an existing Attributes object. * * <p>This constructor is especially useful inside a * {@link org.xml.sax.ContentHandler#startElement startElement} event.</p> * * @param atts The existing Attributes object. */ public AttributesImpl (Attributes atts) { setAttributes(atts); }
/** * Set the type of a specific attribute. * * @param index The index of the attribute (zero-based). * @param type The attribute's type. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not point to an attribute * in the list. */ public void setType (int index, String type) { if (index >= 0 && index < length) { data[index*5+3] = type; } else { badIndex(index); } }
public static String which( Class clazz ) { return which( clazz.getName(), SecureLoader.getClassClassLoader(clazz)); }
/** * Returns a nice string representation for better debug experience. */ public String toString() { StringBuffer buf = new StringBuffer(); buf.append("[url="); buf.append(getURL()); buf.append(",line="); buf.append(getLineNumber()); buf.append(",column="); buf.append(getColumnNumber()); buf.append(",node="); buf.append(getNode()); buf.append(",object="); buf.append(getObject()); buf.append(",field="); buf.append(getFieldName()); buf.append("]"); return buf.toString(); } }
@Override public String toString() { StringBuilder buf = new StringBuilder(Which.which(getClass()) + " Build-Id: " + getBuildId()); buf.append("\nClasses known to this context:\n"); Set<String> names = new TreeSet<String>(); // sort them so that it's easy to read for (Class key : beanInfoMap.keySet()) names.add(key.getName()); for(String name: names) buf.append(" ").append(name).append('\n'); return buf.toString(); }
public ValidationEventLocator getCurrentLocation(String fieldName) { return new ValidationEventLocatorExImpl(cycleDetectionStack.peek(),fieldName); }
/** * Copy an entire Attributes object. * * <p>It may be more efficient to reuse an existing object * rather than constantly allocating new ones.</p> * * @param atts The attributes to copy. */ public void setAttributes (Attributes atts) { clear(); length = atts.getLength(); if (length > 0) { data = new String[length*5]; for (int i = 0; i < length; i++) { data[i*5] = atts.getURI(i); data[i*5+1] = atts.getLocalName(i); data[i*5+2] = atts.getQName(i); data[i*5+3] = atts.getType(i); data[i*5+4] = atts.getValue(i); } } }
public void attribute(int prefix, String localName, String value) { String qname; String nsUri; if(prefix==-1) { nsUri = ""; qname = localName; } else { nsUri = nsContext.getNamespaceURI(prefix); String p = nsContext.getPrefix(prefix); if(p.length()==0) // this is more likely a bug in the application code (NamespacePrefixMapper implementation) // this only happens when it tries to assign "" prefix to a non-"" URI, // which is by itself violation of namespace rec. But let's just be safe. // See http://forums.java.net/jive/thread.jspa?messageID=212598#212598 qname = localName; else qname = p +':'+localName; } atts.addAttribute( nsUri, localName, qname, "CDATA", value ); }
/** * Search the specified classloader for the given classname. * Then give the return value. * @param classname the fully qualified name of the class to search for * @param loader the classloader to search * @return the source location of the resource, or null if it wasn't found */ public static String which(String classname, ClassLoader loader) { String classnameAsResource = classname.replace('.', '/') + ".class"; if(loader == null) { loader = SecureLoader.getSystemClassLoader(); } URL it = loader.getResource(classnameAsResource); if (it != null) { return it.toString(); } else { return null; } }
/** * Add an attribute to the end of the list. * * <p>For the sake of speed, this method does no checking * to see if the attribute is already in the list: that is * the responsibility of the application.</p> * * @param uri The Namespace URI, or the empty string if * none is available or Namespace processing is not * being performed. * @param localName The local name, or the empty string if * Namespace processing is not being performed. * @param qName The qualified (prefixed) name, or the empty string * if qualified names are not available. * @param type The attribute type as a string. * @param value The attribute value. */ public void addAttribute (String uri, String localName, String qName, String type, String value) { ensureCapacity(length+1); data[length*5] = uri; data[length*5+1] = localName; data[length*5+2] = qName; data[length*5+3] = type; data[length*5+4] = value; length++; }
Messages.format(Messages.DOM_IMPL_DOESNT_SUPPORT_CREATELEMENTNS, document.getClass().getName(), Which.which(document.getClass())));
public boolean handleError(Exception e,Object source,String fieldName) { return handleEvent( new ValidationEventImpl( ValidationEvent.ERROR, e.getMessage(), new ValidationEventLocatorExImpl(source,fieldName), e)); }
public void beginStartTag(int prefix, String localName) { elementNsUri = nsContext.getNamespaceURI(prefix); elementLocalName = localName; elementQName = getQName(prefix,localName); atts.clear(); }
/** * Set the value of a specific attribute. * * @param index The index of the attribute (zero-based). * @param value The attribute's value. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not point to an attribute * in the list. */ public void setValue (int index, String value) { if (index >= 0 && index < length) { data[index*5+4] = value; } else { badIndex(index); } }
/** * Copy an existing Attributes object. * * <p>This constructor is especially useful inside a * {@link org.xml.sax.ContentHandler#startElement startElement} event.</p> * * @param atts The existing Attributes object. */ public AttributesImpl (Attributes atts) { setAttributes(atts); }
/** * Set the local name of a specific attribute. * * @param index The index of the attribute (zero-based). * @param localName The attribute's local name, or the empty * string for none. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not point to an attribute * in the list. */ public void setLocalName (int index, String localName) { if (index >= 0 && index < length) { data[index*5+1] = localName; } else { badIndex(index); } }
/** * Set the Namespace URI of a specific attribute. * * @param index The index of the attribute (zero-based). * @param uri The attribute's Namespace URI, or the empty * string for none. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not point to an attribute * in the list. */ public void setURI (int index, String uri) { if (index >= 0 && index < length) { data[index*5] = uri; } else { badIndex(index); } }
/** * Set the qualified name of a specific attribute. * * @param index The index of the attribute (zero-based). * @param qName The attribute's qualified name, or the empty * string for none. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not point to an attribute * in the list. */ public void setQName (int index, String qName) { if (index >= 0 && index < length) { data[index*5+2] = qName; } else { badIndex(index); } }
data[index*5+4] = value; } else { badIndex(index);
/** * Remove an attribute from the list. * * @param index The index of the attribute (zero-based). * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not point to an attribute * in the list. */ public void removeAttribute (int index) { if (index >= 0 && index < length) { if (index < length - 1) { System.arraycopy(data, (index+1)*5, data, index*5, (length-index-1)*5); } index = (length - 1) * 5; data [index++] = null; data [index++] = null; data [index++] = null; data [index++] = null; data [index] = null; length--; } else { badIndex(index); } }