本文整理汇总了Java中org.xml.sax.AttributeList.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeList.getLength方法的具体用法?Java AttributeList.getLength怎么用?Java AttributeList.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xml.sax.AttributeList
的用法示例。
在下文中一共展示了AttributeList.getLength方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.xml.sax.AttributeList; //导入方法依赖的package包/类
/**
* Configures an object using an introspection handler.
*
* @param target The target object to be configured.
* Must not be <code>null</code>.
* @param attrs A list of attributes to configure within the target.
* Must not be <code>null</code>.
* @param project The project containing the target.
* Must not be <code>null</code>.
*
* @deprecated since 1.6.x.
* Use IntrospectionHelper for each property.
*
* @exception BuildException if any of the attributes can't be handled by
* the target
*/
public static void configure(Object target, AttributeList attrs,
Project project) throws BuildException {
if (target instanceof TypeAdapter) {
target = ((TypeAdapter) target).getProxy();
}
IntrospectionHelper ih = IntrospectionHelper.getHelper(project, target.getClass());
for (int i = 0, length = attrs.getLength(); i < length; i++) {
// reflect these into the target
String value = replaceProperties(project, attrs.getValue(i), project.getProperties());
try {
ih.setAttribute(project, target, attrs.getName(i).toLowerCase(Locale.ENGLISH), value);
} catch (BuildException be) {
// id attribute must be set externally
if (!attrs.getName(i).equals("id")) {
throw be;
}
}
}
}
示例2: setAttributeList
import org.xml.sax.AttributeList; //导入方法依赖的package包/类
/**
* Set the attribute list, discarding previous contents.
*
* <p>This method allows an application writer to reuse an
* attribute list easily.</p>
*
* @param atts The attribute list to copy.
*/
public void setAttributeList (AttributeList atts)
{
int count = atts.getLength();
clear();
for (int i = 0; i < count; i++) {
addAttribute(atts.getName(i), atts.getType(i), atts.getValue(i));
}
}
示例3: setAttributeList
import org.xml.sax.AttributeList; //导入方法依赖的package包/类
/**
* Set the attribute list, discarding previous contents.
*
* <p>This method allows an application writer to reuse an
* attribute list easily.</p>
*
* @param atts The attribute list to copy.
*/
public void setAttributeList (AttributeList atts)
{
int count = atts.getLength();
clear();
for (int i = 0; i < count; i++) {
addAttribute(atts.getName(i), atts.getType(i), atts.getValue(i));
}
}
示例4: setAttributeList
import org.xml.sax.AttributeList; //导入方法依赖的package包/类
/**
* Set the attribute list, discarding previous contents.
*
* <p>This method allows an application writer to reuse an
* attribute list easily.</p>
*
* @param atts The attribute list to copy.
*/
public void setAttributeList (AttributeList atts)
{
int count = atts.getLength();
clear();
for (int i = 0; i < count; i++) {
addAttribute(atts.getName(i), atts.getType(i), atts.getValue(i));
}
}
示例5: setAttributes
import org.xml.sax.AttributeList; //导入方法依赖的package包/类
/**
* Sets the attributes for the wrapped element.
*
* @param attributes List of attributes defined in the XML for this
* element. May be <code>null</code>.
* @deprecated since 1.6.x.
*/
@Deprecated
public synchronized void setAttributes(AttributeList attributes) {
this.attributes = new AttributeListImpl(attributes);
for (int i = 0; i < attributes.getLength(); i++) {
setAttribute(attributes.getName(i), attributes.getValue(i));
}
}
示例6: startElement
import org.xml.sax.AttributeList; //导入方法依赖的package包/类
public synchronized void startElement( String tagName, AttributeList attrList )
throws SAXException
{
ElementImpl elem;
int i;
if ( tagName == null )
throw new SAXException( "HTM004 Argument 'tagName' is null." );
// If this is the root element, this is the time to create a new document,
// because only know we know the document element name and namespace URI.
if ( _document == null )
{
// No need to create the element explicitly.
_document = new HTMLDocumentImpl();
elem = (ElementImpl) _document.getDocumentElement();
_current = elem;
if ( _current == null )
throw new SAXException( "HTM005 State error: Document.getDocumentElement returns null." );
// Insert nodes (comment and PI) that appear before the root element.
if ( _preRootNodes != null )
{
for ( i = _preRootNodes.size() ; i-- > 0 ; )
_document.insertBefore( (Node) _preRootNodes.elementAt( i ), elem );
_preRootNodes = null;
}
}
else
{
// This is a state error, indicates that document has been parsed in full,
// or that there are two root elements.
if ( _current == null )
throw new SAXException( "HTM006 State error: startElement called after end of document element." );
elem = (ElementImpl) _document.createElement( tagName );
_current.appendChild( elem );
_current = elem;
}
// Add the attributes (specified and not-specified) to this element.
if ( attrList != null )
{
for ( i = 0 ; i < attrList.getLength() ; ++ i )
elem.setAttribute( attrList.getName( i ), attrList.getValue( i ) );
}
}
示例7: init
import org.xml.sax.AttributeList; //导入方法依赖的package包/类
/**
* Initialisation routine called after handler creation
* with the element name and attributes. The attributes which
* this handler can deal with are: <code>"default"</code>,
* <code>"name"</code>, <code>"id"</code> and <code>"basedir"</code>.
*
* @param tag Name of the element which caused this handler
* to be created. Should not be <code>null</code>.
* Ignored in this implementation.
* @param attrs Attributes of the element which caused this
* handler to be created. Must not be <code>null</code>.
*
* @exception SAXParseException if an unexpected attribute is
* encountered or if the <code>"default"</code> attribute
* is missing.
*/
public void init(String tag, AttributeList attrs) throws SAXParseException {
String def = null;
String name = null;
String id = null;
String baseDir = null;
for (int i = 0; i < attrs.getLength(); i++) {
String key = attrs.getName(i);
String value = attrs.getValue(i);
if ("default".equals(key)) {
def = value;
} else if ("name".equals(key)) {
name = value;
} else if ("id".equals(key)) {
id = value;
} else if ("basedir".equals(key)) {
baseDir = value;
} else {
throw new SAXParseException(
"Unexpected attribute \"" + attrs.getName(i)
+ "\"", helperImpl.locator);
}
}
if (def != null && !def.isEmpty()) {
helperImpl.project.setDefault(def);
} else {
throw new BuildException("The default attribute is required");
}
if (name != null) {
helperImpl.project.setName(name);
helperImpl.project.addReference(name, helperImpl.project);
}
if (id != null) {
helperImpl.project.addReference(id, helperImpl.project);
}
if (helperImpl.project.getProperty("basedir") != null) {
helperImpl.project.setBasedir(helperImpl.project.getProperty("basedir"));
} else {
if (baseDir == null) {
helperImpl.project.setBasedir(helperImpl.buildFileParent.getAbsolutePath());
} else {
// check whether the user has specified an absolute path
if ((new File(baseDir)).isAbsolute()) {
helperImpl.project.setBasedir(baseDir);
} else {
File resolvedBaseDir = FILE_UTILS.resolveFile(helperImpl.buildFileParent,
baseDir);
helperImpl.project.setBaseDir(resolvedBaseDir);
}
}
}
helperImpl.project.addTarget("", helperImpl.implicitTarget);
}
示例8: startElement
import org.xml.sax.AttributeList; //导入方法依赖的package包/类
/** Start element. */
public void startElement(String name, AttributeList attrs) {
fElementCount++;
fAttributeCount += attrs != null ? attrs.getLength() : 0;
}
示例9: startElement
import org.xml.sax.AttributeList; //导入方法依赖的package包/类
/** Start element. */
public void startElement(String name, AttributeList attributes)
throws SAXException {
printIndent();
fOut.print("startElement(");
fOut.print("name=");
printQuotedString(name);
fOut.print(',');
fOut.print("attributes=");
if (attributes == null) {
fOut.println("null");
}
else {
fOut.print('{');
int length = attributes.getLength();
for (int i = 0; i < length; i++) {
if (i > 0) {
System.out.print(',');
}
String attrName = attributes.getName(i);
String attrType = attributes.getType(i);
String attrValue = attributes.getValue(i);
fOut.print('{');
fOut.print("name=");
printQuotedString(attrName);
fOut.print(',');
fOut.print("type=");
printQuotedString(attrType);
fOut.print(',');
fOut.print("value=");
printQuotedString(attrValue);
fOut.print('}');
}
fOut.print('}');
}
fOut.println(')');
fOut.flush();
fIndent++;
}