本文整理汇总了Java中org.w3c.dom.Element.getNodeName方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getNodeName方法的具体用法?Java Element.getNodeName怎么用?Java Element.getNodeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.Element
的用法示例。
在下文中一共展示了Element.getNodeName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createComponent
import org.w3c.dom.Element; //导入方法依赖的package包/类
static TestComponent2 createComponent(TestModel2 model, TestComponent2 parent, Element e) {
String namespace = e.getNamespaceURI();
if (namespace == null && parent != null) {
namespace = parent.lookupNamespaceURI(e.getPrefix());
}
if (e.getLocalName().equals("a") && NS_URI.equals(namespace)) {
return new TestComponent2.A(model, e);
} else if (e.getLocalName().equals("a") && NS2_URI.equals(namespace)) {
return new TestComponent2.Aa(model, e);
} else if (e.getLocalName().equals("b") && NS_URI.equals(namespace)) {
return new TestComponent2.B(model, e);
} else if (e.getLocalName().equals("c") && NS_URI.equals(namespace)) {
return new TestComponent2.C(model, e);
} else if (e.getLocalName().equals("d") && NS_URI.equals(namespace)) {
return new TestComponent2.D(model, e);
} else if (e.getLocalName().equals("e") && NS_URI.equals(namespace)) {
return new TestComponent2.E(model, e);
} else {
throw new RuntimeException("unsupported element type "+ e.getNodeName());
}
}
示例2: parsePackageProcedures
import org.w3c.dom.Element; //导入方法依赖的package包/类
private static void parsePackageProcedures(Element pkgElement, DBPackage pkg) {
for (Element e : XMLUtil.getChildElements(pkgElement)) {
String nodeName = e.getNodeName();
if ("procedure".equals(nodeName)) {
DBProcedure procedure = new DBProcedure(e.getAttribute("name"), pkg);
String objectId = e.getAttribute("objectId");
if (!StringUtil.isEmpty(objectId))
procedure.setObjectId(objectId);
String subProgramId = e.getAttribute("subProgramId");
if (!StringUtil.isEmpty(subProgramId))
procedure.setSubProgramId(subProgramId);
String overload = e.getAttribute("overload");
if (!StringUtil.isEmpty(overload))
procedure.setOverload(overload);
} else
throw new SyntaxError("Illegal child element of <package>", XMLUtil.format(e));
}
}
示例3: checkForDuplicatedMapIds
import org.w3c.dom.Element; //导入方法依赖的package包/类
private void checkForDuplicatedMapIds() {
// load all elements for this section
NodeList childNodes = sectionNode.getChildNodes();
List<String> childNodeMapIds = new ArrayList<String>();
for (int i = 0; i < childNodes.getLength(); i++) {
if (childNodes.item(i) instanceof Element) {
Element element = ((Element) childNodes.item(i));
String elementMapId = element.getAttribute(ATT_ELEMENT_MAP_ID);
if (StringUtils.isNullOrEmpty(elementMapId)) {
throw new ElementsMapException("Error reading " + ATT_ELEMENT_MAP_ID + " for element '"
+ sectionNode.getNodeName() + "\\" + element.getNodeName()
+ "'");
}
if (childNodeMapIds.contains(elementMapId)) {
throw new ElementsMapException("Map section '"
+ ((Element) sectionNode).getAttribute("name")
+ "' already contains element with the same mapId '"
+ elementMapId + "'");
}
childNodeMapIds.add(elementMapId);
}
}
}
示例4: parse
import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public Metadata parse(final Element element, final ParserContext context) {
LOG.debug("In parse for {}", element);
if (nodeNameEquals(element, RpcImplementationBean.RPC_IMPLEMENTATION)) {
return parseRpcImplementation(element, context);
} else if (nodeNameEquals(element, RoutedRpcMetadata.ROUTED_RPC_IMPLEMENTATION)) {
return parseRoutedRpcImplementation(element, context);
} else if (nodeNameEquals(element, RPC_SERVICE)) {
return parseRpcService(element, context);
} else if (nodeNameEquals(element, NotificationListenerBean.NOTIFICATION_LISTENER)) {
return parseNotificationListener(element, context);
} else if (nodeNameEquals(element, CLUSTERED_APP_CONFIG)) {
return parseClusteredAppConfig(element, context);
} else if (nodeNameEquals(element, SPECIFIC_SERVICE_REF_LIST)) {
return parseSpecificReferenceList(element, context);
} else if (nodeNameEquals(element, STATIC_REFERENCE)) {
return parseStaticReference(element, context);
} else if (nodeNameEquals(element, ACTION_SERVICE)) {
return parseActionService(element, context);
} else if (nodeNameEquals(element, ActionProviderBean.ACTION_PROVIDER)) {
return parseActionProvider(element, context);
}
throw new ComponentDefinitionException("Unsupported standalone element: " + element.getNodeName());
}
示例5: getChildNodeValue
import org.w3c.dom.Element; //导入方法依赖的package包/类
private static String getChildNodeValue( Element root, String childNodeName, String defaultValue ) throws SAXException {
NodeList nl = root.getElementsByTagName( childNodeName );
if (nl.getLength() == 1) {
return getTextValue( nl.item( 0 ) ).trim();
} else if (defaultValue == null) {
throw new SAXException( "Node <" + root.getNodeName() + "> has no child named <" + childNodeName + ">" );
} else {
return defaultValue;
}
}
示例6: getPublicPackages
import org.w3c.dom.Element; //导入方法依赖的package包/类
private PublicPackage[] getPublicPackages(Document d) throws BuildException {
Element cfg = getConfig(d);
Element pp = findNBMElement(cfg, "public-packages");
if (pp == null) {
pp = findNBMElement(cfg, "friend-packages");
}
if (pp == null) {
throw new BuildException("No <public-packages>", getLocation());
}
List<PublicPackage> pkgs = new ArrayList<>();
for (Element p : XMLUtil.findSubElements(pp)) {
boolean sub = false;
if ("friend".equals(p.getNodeName())) {
continue;
}
if (!"package".equals (p.getNodeName ())) {
if (!("subpackages".equals (p.getNodeName ()))) {
throw new BuildException ("Strange element name, should be package or subpackages: " + p.getNodeName (), getLocation ());
}
sub = true;
}
String t = XMLUtil.findText(p);
if (t == null) {
throw new BuildException("No text in <package>", getLocation());
}
pkgs.add(new PublicPackage(t, sub));
}
return pkgs.toArray(new PublicPackage[pkgs.size()]);
}
示例7: isElementPresent
import org.w3c.dom.Element; //导入方法依赖的package包/类
private void isElementPresent(Element element, String key) {
try {
String value = element.getElementsByTagName(key).item(0).getTextContent();
if (value.isEmpty() || value == null){
throw new IllegalArgumentException("Element '" + key + "' is not found in '" + element.getNodeName() +"'");
}
} catch (Exception e) {
throw new IllegalArgumentException("Element '" + key + "' is not found in '" + element.getNodeName() +"'");
}
}
示例8: parseDatabase
import org.w3c.dom.Element; //导入方法依赖的package包/类
private Database parseDatabase(Element e) {
String environment = e.getAttribute("environment");
if (StringUtil.isEmpty(environment))
environment = e.getAttribute("name");
if (StringUtil.isEmpty(environment))
throw new ConfigurationError("No environment defined in cache file");
Database db = new Database(environment, realImporter, false);
db.setUser(e.getAttribute("user"));
db.setTableInclusionPattern(e.getAttribute("tableInclusionPattern"));
db.setTableExclusionPattern(e.getAttribute("tableExclusionPattern"));
db.setSequencesImported(XMLUtil.getBooleanAttribute(e, "sequencesImported", true));
db.setTriggersImported(XMLUtil.getBooleanAttribute(e, "triggersImported", true));
db.setPackagesImported(XMLUtil.getBooleanAttribute(e, "packagesImported", true));
db.setChecksImported(XMLUtil.getBooleanAttribute(e, "checksImported", true));
// import catalogs
for (Element child : XMLUtil.getChildElements(e)) {
String childName = child.getNodeName();
if ("catalog".equals(childName))
parseCatalog(child, db);
else
throw new UnsupportedOperationException("Not an allowed element within <database>: " + childName);
}
scanReferers(db);
return db;
}
示例9: parseTableStructure
import org.w3c.dom.Element; //导入方法依赖的package包/类
private DBTable parseTableStructure(Element e, DBSchema schema) {
String name = e.getAttribute("name");
DBTable table = (DBTable) schema.getTable(name);
boolean columnsImported = XMLUtil.getBooleanAttributeWithDefault(e, "columnsImported", true);
table.setColumnsImported(columnsImported);
boolean pkImported = XMLUtil.getBooleanAttributeWithDefault(e, "pkImported", true);
table.setPKImported(pkImported);
boolean fksImported = XMLUtil.getBooleanAttributeWithDefault(e, "fksImported", true);
table.setFKsImported(fksImported);
boolean indexesImported = XMLUtil.getBooleanAttributeWithDefault(e, "indexesImported", true);
table.setIndexesImported(indexesImported);
boolean checksImported = XMLUtil.getBooleanAttributeWithDefault(e, "checksImported", true);
table.setChecksImported(checksImported);
for (Element child : XMLUtil.getChildElements(e)) {
String childName = child.getNodeName();
if ("column".equals(childName))
parseColumn(child, table);
else if ("pk".equals(childName))
parsePK(child, table);
else if ("uk".equals(childName))
parseUK(child, table);
else if ("fk".equals(childName))
parseFK(child, table, schema);
else if ("check".equals(childName))
parseCheck(child, table);
else if ("index".equals(childName))
parseIndex(child, table);
else
throw new SyntaxError("Not an allowed element within <table>", XMLUtil.format(child));
}
return table;
}
示例10: handle
import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public void handle(Element node) throws Exception {
switch (node.getNodeName()) {
case "spectrum_query": {
ParseSpectrumNode(node);
break;
}
case "search_summary": {
ParseSearchSummary(node);
break;
}
}
}
示例11: getMandatoryAttribute
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
*
* @param node the node {@link Element}
* @param attributeName the attribute name
* @return the attribute value
* @throws XMLException if the mandatory attribute is missing or its value is empty
*/
public static String getMandatoryAttribute( Element node,
String attributeName ) throws XMLException {
String attributeValue = getAttribute(node, attributeName);
if (StringUtils.isNullOrEmpty(attributeValue)) {
throw new XMLException(node.getNodeName() + " is missing mandatory attribute '"
+ attributeName + "'");
}
return attributeValue;
}
示例12: getSpecificAnnotationKindConverter
import org.w3c.dom.Element; //导入方法依赖的package包/类
private ConvertSpecificAnnotationKind getSpecificAnnotationKindConverter(Element elt) throws ConverterException {
String name = elt.getNodeName();
if (name.equals("text"))
return new ConvertTextAnnotationDefinition();
if (name.equals("group"))
return new ConvertGroupAnnotationDefinition();
if (name.equals("relation"))
return new ConvertRelationAnnotationDefinition();
cannotConvertXML(elt, "unknown annotation kind " + name);
return null;
}
示例13: buildElementMapXPath
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Build element map for elements matching <code>xPath</code> relative to <code>parent</code> into
* <code>elementMap</code> .
*
* @param elementMap to add elements to
* @param schema {@link Document} for schema.
* @param parent {@link Element} to query XPath.
* @param rank current rank of elements.
* @param xPath XPath to query for elements.
* @param xPathContext XPath context for queries.
* @return final rank of elements.
* @throws XPathExpressionException
* @since GemFire 8.1
*/
private static int buildElementMapXPath(final LinkedHashMap<String, CacheElement> elementMap,
final Document schema, final Node parent, int rank, final String xPath,
final XPathContext xPathContext) throws XPathExpressionException {
final NodeList children = XmlUtils.query(parent, xPath, xPathContext);
for (int i = 0; i < children.getLength(); i++) {
final Element child = (Element) children.item(i);
switch (child.getNodeName()) {
case XSD_ALL_CHILDREN:
final String name = getAttribute(child, "name");
elementMap.put(name, new CacheElement(name, rank++, isMultiple(child)));
break;
// TODO group support as XSD matures
// case "xsd:group":
// buildElementMapGroup(elementMap, doc, child, rank, xPathContext);
// break;
case "xsd:choice":
case "xsd:sequence":
rank = buildElementMapXPath(elementMap, schema, child, rank,
XSD_CHOICE_OR_SEQUENCE_CHILDREN, xPathContext);
break;
case "xsd:any":
// ignore extensions
break;
default:
// TODO jbarrett - localize
throw new UnsupportedOperationException(
"Unsupported child type '" + child.getNodeName() + "'");
}
}
return rank;
}
示例14: parseNestedCustomElement
import org.w3c.dom.Element; //导入方法依赖的package包/类
private BeanDefinitionHolder parseNestedCustomElement(Element ele, BeanDefinition containingBd) {
BeanDefinition innerDefinition = parseCustomElement(ele, containingBd);
if (innerDefinition == null) {
error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " +
"This tag cannot be used nested inside <property>.", ele);
return null;
}
String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR +
ObjectUtils.getIdentityHexString(innerDefinition);
if (logger.isDebugEnabled()) {
logger.debug("Using generated bean name [" + id +
"] for nested custom element '" + ele.getNodeName() + "'");
}
return new BeanDefinitionHolder(innerDefinition, id);
}
示例15: getQuery
import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public Query getQuery(Element n) throws ParserException {
QueryBuilder builder = builders.get(n.getNodeName());
if (builder == null) {
throw new ParserException("No QueryObjectBuilder defined for node " + n.getNodeName());
}
return builder.getQuery(n);
}