當前位置: 首頁>>代碼示例>>Java>>正文


Java Attributes.getLocalName方法代碼示例

本文整理匯總了Java中org.xml.sax.Attributes.getLocalName方法的典型用法代碼示例。如果您正苦於以下問題:Java Attributes.getLocalName方法的具體用法?Java Attributes.getLocalName怎麽用?Java Attributes.getLocalName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xml.sax.Attributes的用法示例。


在下文中一共展示了Attributes.getLocalName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setAttributes

import org.xml.sax.Attributes; //導入方法依賴的package包/類
/**
 * Copy an entire Attributes object.
 *
 * @param atts The attributes to copy.
 */
public void setAttributes(Attributes atts) {
    _length = atts.getLength();
    if (_length > 0) {

        if (_length >= _algorithmData.length) {
            resizeNoCopy();
        }

        int index = 0;
        for (int i = 0; i < _length; i++) {
            _data[index++] = atts.getURI(i);
            _data[index++] = atts.getLocalName(i);
            _data[index++] = atts.getQName(i);
            _data[index++] = atts.getType(i);
            _data[index++] = atts.getValue(i);
            index++;
            _toIndex[i] = false;
            _alphabets[i] = null;
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:27,代碼來源:EncodingAlgorithmAttributesImpl.java

示例2: setAttributes

import org.xml.sax.Attributes; //導入方法依賴的package包/類
/**
 * 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);
        }
    }
}
 
開發者ID:Pixplicity,項目名稱:HtmlCompat,代碼行數:24,代碼來源:AttributesImpl.java

示例3: handleFxScript

import org.xml.sax.Attributes; //導入方法依賴的package包/類
@NbBundle.Messages({
    "#0 - attribute name",
    "ERR_unexpectedScriptAttribute=Unexpected attribute in fx:script: {0}"
})
private FxNode handleFxScript(Attributes atts) {
    String ref = null;
    
    for (int i = 0; i < atts.getLength(); i++) {
        String name = atts.getLocalName(i);
         if (!FX_ATTR_REFERENCE_SOURCE.equals(name)) {
            addAttributeError(atts.getQName(i),
                "invalid-script-attribute",
                ERR_unexpectedScriptAttribute(name),
                name
            );
            continue;
        }
        ref = atts.getValue(i);
    }
    return accessor.createScript(ref);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:FxModelBuilder.java

示例4: begin

import org.xml.sax.Attributes; //導入方法依賴的package包/類
/**
 * Handle the beginning of an XML element.
 *
 * @param attributes The attributes of this element
 *
 * @exception Exception if a processing error occurs
 */
@Override
public void begin(String namespace, String nameX, Attributes attributes)
    throws Exception {

    for (int i = 0; i < attributes.getLength(); i++) {
        String name = attributes.getLocalName(i);
        if ("".equals(name)) {
            name = attributes.getQName(i);
        }
        if ("path".equals(name) || "docBase".equals(name)) {
            continue;
        }
        String value = attributes.getValue(i);
        if (!digester.isFakeAttribute(digester.peek(), name) 
                && !IntrospectionUtils.setProperty(digester.peek(), name, value) 
                && digester.getRulesValidation()) {
            digester.getLogger().warn("[SetContextPropertiesRule]{" + digester.getMatch() +
                    "} Setting property '" + name + "' to '" +
                    value + "' did not find a matching property.");
        }
    }

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:31,代碼來源:SetContextPropertiesRule.java

示例5: startElement

import org.xml.sax.Attributes; //導入方法依賴的package包/類
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
    if (atts != null) {
        boolean eos = false;
        if (namespaceURI == DSIG_NS || XENC_NS == namespaceURI) {
            eos = true;
        }
        int length = atts.getLength();
        AttributesImpl attrImpl = new AttributesImpl();
        for (int i = 0; i < length; i++) {
            String name = atts.getLocalName(i);
            if (name != null && (name.equals("Id"))) {
                if (eos || atts.getURI(i) == WSU_NS) {
                    attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i), atts.getQName(i), ID_NAME, atts.getValue(i));
                } else {
                    attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i), atts.getQName(i), atts.getType(i), atts.getValue(i));
                }
            } else {
                attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i), atts.getQName(i), atts.getType(i), atts.getValue(i));
            }
        }
        super.startElement(namespaceURI, localName, qName, attrImpl);
    } else {
        super.startElement(namespaceURI, localName, qName, atts);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:SAX2DOMTest.java

示例6: begin

import org.xml.sax.Attributes; //導入方法依賴的package包/類
/**
 * Handle the beginning of an XML element.
 *
 * @param attributes
 *            The attributes of this element
 *
 * @exception Exception
 *                if a processing error occurs
 */
@Override
public void begin(String namespace, String nameX, Attributes attributes) throws Exception {

	for (int i = 0; i < attributes.getLength(); i++) {
		String name = attributes.getLocalName(i);
		if ("".equals(name)) {
			name = attributes.getQName(i);
		}
		if ("path".equals(name) || "docBase".equals(name)) {
			continue;
		}
		String value = attributes.getValue(i);
		if (!digester.isFakeAttribute(digester.peek(), name)
				&& !IntrospectionUtils.setProperty(digester.peek(), name, value) && digester.getRulesValidation()) {
			digester.getLogger().warn("[SetContextPropertiesRule]{" + digester.getMatch() + "} Setting property '"
					+ name + "' to '" + value + "' did not find a matching property.");
		}
	}

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:30,代碼來源:SetContextPropertiesRule.java

示例7: begin

import org.xml.sax.Attributes; //導入方法依賴的package包/類
/**
 * Handle the beginning of an XML element.
 *
 * @param attributes
 *            The attributes of this element
 *
 * @exception Exception
 *                if a processing error occurs
 */
@Override
public void begin(String namespace, String nameX, Attributes attributes) throws Exception {

	for (int i = 0; i < attributes.getLength(); i++) {
		String name = attributes.getLocalName(i);
		if ("".equals(name)) {
			name = attributes.getQName(i);
		}
		String value = attributes.getValue(i);
		if (!excludes.containsKey(name)) {
			if (!digester.isFakeAttribute(digester.peek(), name)
					&& !IntrospectionUtils.setProperty(digester.peek(), name, value)
					&& digester.getRulesValidation()) {
				digester.getLogger().warn("[SetAllPropertiesRule]{" + digester.getMatch() + "} Setting property '"
						+ name + "' to '" + value + "' did not find a matching property.");
			}
		}
	}

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:30,代碼來源:SetAllPropertiesRule.java

示例8: addAttributes

import org.xml.sax.Attributes; //導入方法依賴的package包/類
/**
 * Add the contents of the attribute list to this list.
 *
 * @param atts List of attributes to add to this list
 */
public void addAttributes(Attributes atts)
{

  int nAtts = atts.getLength();

  for (int i = 0; i < nAtts; i++)
  {
    String uri = atts.getURI(i);

    if (null == uri)
      uri = "";

    String localName = atts.getLocalName(i);
    String qname = atts.getQName(i);
    int index = this.getIndex(uri, localName);
    // System.out.println("MutableAttrListImpl#addAttributes: "+uri+":"+localName+", "+index+", "+atts.getQName(i)+", "+this);
    if (index >= 0)
      this.setAttribute(index, uri, localName, qname, atts.getType(i),
                        atts.getValue(i));
    else
      addAttribute(uri, localName, qname, atts.getType(i),
                   atts.getValue(i));
  }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:MutableAttrListImpl.java

示例9: startElement

import org.xml.sax.Attributes; //導入方法依賴的package包/類
@Override
public void startElement(String uri, String name, String qName, Attributes atts) throws SAXException 
{
    mAttributes.clear();
    for (int i=0; i < atts.getLength(); ++i) {
        String attName = atts.getLocalName(i);
        mAttributes.put(attName, atts.getValue(i));
    }
    
    mContentBuilder.setLength(0);
    
    mTagStack.add(name);

    String xmlPath = getXMLPath();
    
    onAsyncElementStart(xmlPath, name, mAttributes);
    
    Method method = mStartHandlers.get(xmlPath);
    if (method != null) {
        try {
            method.invoke(XmlSaxTask.this, mAttributes);
        } 
        catch (Exception e) {
            throw new RuntimeException(e);
        } 
    }
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-android,代碼行數:28,代碼來源:XmlSaxTask.java

示例10: setAttributes

import org.xml.sax.Attributes; //導入方法依賴的package包/類
/**
 * 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();
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);
}
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:AttributesImpl.java

示例11: startElement

import org.xml.sax.Attributes; //導入方法依賴的package包/類
/**
 * Adds a new child {@link org.w3c.dom.Element Element} to the current
 * node.
 * 
 * @param namespaceURI the namespace URI
 * @param localName the local name
 * @param qName the qualified (prefixed) name
 * @param atts the list of attributes
 * @throws SAXException if the DOM implementation throws an exception
 */
@Override
public void startElement(String namespaceURI, String localName,
                         String qName, Attributes atts)
    throws SAXException {

    try {
        Node previousTop = top;
        if ((localName == null) || (localName.length() == 0)) { 
            top = doc.createElement(qName);
        } else {
            top = doc.createElementNS(namespaceURI, localName);
        }
        for (int i = 0; i < atts.getLength(); i++) {
            Attr attr = null;
            if ((atts.getLocalName(i) == null) ||
                (atts.getLocalName(i).length() == 0)) {
                attr = doc.createAttribute(atts.getQName(i));
                attr.setNodeValue(atts.getValue(i));
                ((Element)top).setAttributeNode(attr);
            } else {
                attr = doc.createAttributeNS(atts.getURI(i),
                                             atts.getLocalName(i));
                attr.setNodeValue(atts.getValue(i));
                ((Element)top).setAttributeNodeNS(attr);
            }
        }
        previousTop.appendChild(top);
        depth++;
    } catch (DOMException e) {
        throw new SAXException(e.getMessage(), e);
    }

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:44,代碼來源:NodeCreateRule.java

示例12: startElement

import org.xml.sax.Attributes; //導入方法依賴的package包/類
@Override
public void startElement(
  ParseContext context,
  String       namespaceURI,
  String       localName,
  Attributes   attrs) throws SAXParseException
{
  _type = attrs.getValue(NAMESPACE, "type");
  if (_type == null)
    logError(context, "tr:type attribute not on component", null);
  String facet = attrs.getValue(NAMESPACE, "facet");
  _definition = new ComponentDefinition(_type, _info);
  for (int i = 0; i < attrs.getLength(); i++)
  {
    if ("".equals(attrs.getURI(i)))
    {
      String name = attrs.getLocalName(i);
      String valueStr = attrs.getValue(i);
      _definition.getAttributes().put(name, valueStr);
    }
  }

  if (_parent != null)
  {
    if (facet != null)
      _parent.getFacets().put(facet, _definition);
    else
      _parent.getChildren().add(_definition);
  }

  _definition.setUsesUpload(
     "true".equals(attrs.getValue(NAMESPACE, "usesUpload")));
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:34,代碼來源:TestScriptParser.java

示例13: startElement

import org.xml.sax.Attributes; //導入方法依賴的package包/類
public void startElement(String namespace, String localName, String qName, Attributes attrs) {
  final Element tmp = (Element) _document.createElementNS(namespace, qName);

  // Add name space declarations first
  if (_namespaceDecls != null) {
    final int nDecls = _namespaceDecls.size();
    for (int i = 0; i < nDecls; i++) {
      final String prefix = (String) _namespaceDecls.elementAt(i++);

      if (prefix == null || prefix.equals(EMPTYSTRING)) {
        tmp.setAttributeNS(XMLNS_URI, XMLNS_PREFIX, (String) _namespaceDecls.elementAt(i));
      } else {
        tmp.setAttributeNS(XMLNS_URI, XMLNS_STRING + prefix,
            (String) _namespaceDecls.elementAt(i));
      }
    }
    _namespaceDecls.clear();
  }

  // Add attributes to element
  final int nattrs = attrs.getLength();
  for (int i = 0; i < nattrs; i++) {
    if (attrs.getLocalName(i) == null) {
      tmp.setAttribute(attrs.getQName(i), attrs.getValue(i));
    } else {
      tmp.setAttributeNS(attrs.getURI(i), attrs.getQName(i), attrs.getValue(i));
    }
  }

  // Append this new node onto current stack node
  Node last = _nodeStk.peek();
  last.appendChild(tmp);

  // Push this node onto stack
  _nodeStk.push(tmp);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:37,代碼來源:Sax2Dom.java

示例14: handleFxReference

import org.xml.sax.Attributes; //導入方法依賴的package包/類
@NbBundle.Messages({
    "# {0} - attribute local name",
    "ERR_unexpectedReferenceAttribute=Unexpected attribute in fx:reference or fx:copy: {0}",
    "ERR_missingReferenceSource=Missing 'source' attribute in fx:reference or fx:copy"
})
private FxNode handleFxReference(Attributes atts, boolean copy) {
    String refId = null;
    String id = null;
    
    for (int i = 0; i < atts.getLength(); i++) {
        String ns = atts.getURI(i);
        String name = atts.getLocalName(i);
        if (!isFxmlNamespaceUri(ns)) {
            if (FX_ATTR_REFERENCE_SOURCE.equals(name) && refId == null) {
                refId = atts.getValue(i);
            } else if (!copy) {
                // error, references do not support normal attributes
                addAttributeError(atts.getQName(i),
                    "invalid-reference-attribute",
                    ERR_unexpectedReferenceAttribute(name),
                    name
                );
            }
        } else {
            if (FX_ID.equals(name) && id == null) {
                id = atts.getValue(i);
            } else {
                // error, unexpected attribute
                addAttributeError(atts.getQName(i),
                    "invalid-reference-attribute",
                    ERR_unexpectedReferenceAttribute(name),
                    name
                );
            }
        }
    }
    
    FxObjectBase ref = accessor.createCopyReference(copy, refId);
    if (refId == null || "".equals(refId)) {
        // error, no source attribute found
        addError(
                "missing-reference-source",
                ERR_missingReferenceSource()
        );
        accessor.makeBroken(ref);
    }
    return ref;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:49,代碼來源:FxModelBuilder.java

示例15: begin

import org.xml.sax.Attributes; //導入方法依賴的package包/類
/**
 * Process the beginning of this element.
 *
 * @param namespace the namespace URI of the matching element, or an 
 *   empty string if the parser is not namespace aware or the element has
 *   no namespace
 * @param theName the local name if the parser is namespace aware, or just 
 *   the element name otherwise
 * @param attributes The attribute list for this element
 * 
 * @exception NoSuchMethodException if the bean does not
 *  have a writable property of the specified name
 */
@Override
public void begin(String namespace, String theName, Attributes attributes)
        throws Exception {

    // Identify the actual property name and value to be used
    String actualName = null;
    String actualValue = null;
    for (int i = 0; i < attributes.getLength(); i++) {
        String name = attributes.getLocalName(i);
        if ("".equals(name)) {
            name = attributes.getQName(i);
        }
        String value = attributes.getValue(i);
        if (name.equals(this.name)) {
            actualName = value;
        } else if (name.equals(this.value)) {
            actualValue = value;
        }
    }

    // Get a reference to the top object
    Object top = digester.peek();

    // Log some debugging information
    if (digester.log.isDebugEnabled()) {
        digester.log.debug("[SetPropertyRule]{" + digester.match +
                "} Set " + top.getClass().getName() + " property " +
                actualName + " to " + actualValue);
    }

    // Set the property (with conversion as necessary)
    if (!digester.isFakeAttribute(top, actualName) 
            && !IntrospectionUtils.setProperty(top, actualName, actualValue) 
            && digester.getRulesValidation()) {
        digester.log.warn("[SetPropertyRule]{" + digester.match +
                "} Setting property '" + name + "' to '" +
                value + "' did not find a matching property.");
    }

}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:54,代碼來源:SetPropertyRule.java


注:本文中的org.xml.sax.Attributes.getLocalName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。