List of usage examples for javax.xml.namespace QName equals
public final boolean equals(Object objectToTest)
Test this QName
for equality with another Object
.
If the Object
to be tested is not a QName
or is null
, then this method returns false
.
Two QName
s are considered equal if and only if both the Namespace URI and local part are equal.
From source file:org.wso2.carbon.relay.module.policy.PolicyProcessor.java
private static boolean handlePolicyComponents(RelayConfiguration relayConfiguration, Collection topLevelAssertionList) throws AxisFault { for (Object topLevelAssertionObject : topLevelAssertionList) { if (topLevelAssertionObject instanceof Policy) { Policy policy = (Policy) topLevelAssertionObject; Collection policyComponents = policy.getPolicyComponents(); handlePolicyComponents(relayConfiguration, policyComponents); } else if (topLevelAssertionObject instanceof XmlPrimtiveAssertion) { XmlPrimtiveAssertion tlxa = (XmlPrimtiveAssertion) topLevelAssertionObject; QName qName = tlxa.getName(); // validating the relay assertion if (!qName.equals(RelayConstants.RELAY_ASSERSION_QNAME)) { return false; }//from www .j a v a 2 s. com Policy rpc = PolicyEngine.getPolicy(tlxa.getValue()); for (Object configAssertion : rpc.getPolicyComponents()) { // Validating the relay policy if (!(configAssertion instanceof Policy)) { return false; } Policy cachingPolicy = (Policy) configAssertion; List childAssertionsList = cachingPolicy.getPolicyComponents(); for (Object configData : childAssertionsList) { if (!(configData instanceof All)) { handleException("Unexpected relay " + "policy, \"wsp:All\" expected"); } All all = (All) configData; List configDataList = all.getPolicyComponents(); for (Object configDtaObject : configDataList) { if (!(configDtaObject instanceof XmlPrimtiveAssertion)) { // invalid relay policy handleException("Unexpected relay policy " + "assertion for the relay module"); } XmlPrimtiveAssertion assertion = (XmlPrimtiveAssertion) configDtaObject; if (assertion.getName().equals(RelayConstants.INCLUDE_HIDDEN_SERVICES_QNAME)) { String value = assertion.getValue().getText(); relayConfiguration.setIncludeHiddenServices(Boolean.parseBoolean(value)); } if (assertion.getName().equals(RelayConstants.BUILDERS_QNAME) && assertion.getValue() != null) { processBuilders(assertion.getValue(), relayConfiguration); } if (assertion.getName().equals(RelayConstants.SERVICES_QNAME) && assertion.getValue() != null) { processServices(assertion.getValue(), relayConfiguration); } } } } } else { return false; } } return true; }
From source file:org.wso2.developerstudio.eclipse.gmf.esb.diagram.custom.deserializer.DummyTaskDescriptionFactory.java
public static TaskDescription createTaskDescription(OMElement el, OMNamespace tagetNamespace) { if (log.isDebugEnabled()) { log.debug("Creating SimpleQuartz Task"); }//from w w w.j a v a 2 s.co m QName task = createQName(TASK, tagetNamespace); if (task.equals(el.getQName())) { TaskDescription taskDescription = new TaskDescription(); String name = el.getAttributeValue(new QName(NULL_NAMESPACE, "name")); if (name != null) { taskDescription.setName(name); } else { handleException("Name for a task is required, missing name in the task"); } String group = el.getAttributeValue(new QName(NULL_NAMESPACE, "group")); if (group != null) { taskDescription.setTaskGroup(group); } // set the task class OMAttribute classAttr = el.getAttribute(new QName("class")); if (classAttr != null && classAttr.getAttributeValue() != null) { String classname = classAttr.getAttributeValue(); taskDescription.setTaskImplClassName(classname); } else { log.warn("TaskClass cannot be found." + "Task implementation may need a task class if there is no default one"); } OMElement descElem = el.getFirstChildWithName(createQName(DESCRIPTION, tagetNamespace)); if (descElem != null) { taskDescription.setTaskDescription(descElem.getText()); } // set pinned server list OMAttribute pinnedServers = el.getAttribute(new QName(NULL_NAMESPACE, "pinnedServers")); if (pinnedServers != null) { String pinnedServersValue = pinnedServers.getAttributeValue(); if (pinnedServersValue == null) { // default to all servers } else { StringTokenizer st = new StringTokenizer(pinnedServersValue, " ,"); List<String> pinnedServersList = new ArrayList<String>(); while (st.hasMoreTokens()) { String token = st.nextToken(); if (token.length() != 0) { pinnedServersList.add(token); } } taskDescription.setPinnedServers(pinnedServersList); } } // next sort out the property children Iterator it = el.getChildrenWithName(createQName(PROPERTY, tagetNamespace)); while (it.hasNext()) { OMElement prop = (OMElement) it.next(); if (PropertyHelper.isStaticProperty(prop)) { taskDescription.setXmlProperty(prop); } else { handleException("Tasks does not support dynamic properties"); } } // setting the trigger to the task OMElement trigger = el.getFirstChildWithName(createQName(TRIGGER, tagetNamespace)); if (trigger != null) { OMAttribute count = trigger.getAttribute(new QName("count")); if (count != null) { try { taskDescription.setCount(Integer.parseInt(count.getAttributeValue())); } catch (Exception e) { handleException("Failed to parse trigger count as an integer", e); } } OMAttribute once = trigger.getAttribute(new QName("once")); if (once != null && Boolean.TRUE.toString().equals(once.getAttributeValue())) { taskDescription.setCount(1); taskDescription.setInterval(1); } OMAttribute repeatInterval = trigger.getAttribute(new QName("interval")); if (repeatInterval == null && taskDescription.getCount() > 1) { handleException("Trigger seems to be " + "a simple trigger, but no interval specified"); } else if (repeatInterval != null && repeatInterval.getAttributeValue() != null) { try { long repeatIntervalInMillis = Long.parseLong(repeatInterval.getAttributeValue()); taskDescription.setInterval(repeatIntervalInMillis); } catch (Exception e) { handleException("Failed to parse trigger interval as a long value", e); } } OMAttribute expr = trigger.getAttribute(new QName("cron")); if (expr == null && taskDescription.getInterval() == 0) { taskDescription.setCount(1); taskDescription.setInterval(1); } else if (expr != null && taskDescription.getInterval() > 0) { handleException( "Trigger syntax error : " + "both cron and simple trigger attributes are present"); } else if (expr != null && expr.getAttributeValue() != null) { taskDescription.setCronExpression(expr.getAttributeValue()); } } else { taskDescription.setCount(1); taskDescription.setInterval(1); } return taskDescription; } else { handleException("Syntax error in the task : wrong QName for the task"); return null; } }
From source file:org.xmlsh.commands.internal.xml2json.java
private boolean parse(XMLEventReader reader, PrintWriter writer, boolean bComma) throws XMLStreamException, CoreException, UnsupportedEncodingException, IOException, TransformException, SaxonApiException { mLevel++;/*from w ww. j ava 2 s.c om*/ while (reader.hasNext()) { XMLEvent e = reader.nextEvent(); if (e.isStartElement()) { StartElement start = e.asStartElement(); QName name = start.getName(); if (name.equals(kELEM_XJSON)) { if (mLevel != 1) throw new UnexpectedException("XJSON element must be at document root"); // Children become the new roots mLevel = 0; while (parse(reader, writer, bComma)) ; return false; } else if (name.equals(kELEM_FILE)) { if (!writeFile(start, reader, writer)) return false; } else if (bComma) writer.print(","); if (name.equals(kELEM_OBJECT)) writeObject(start, reader, writer); else if (name.equals(kELEM_ARRAY)) writeArray(start, reader, writer); else if (name.equals(kELEM_MEMBER)) writeMember(start, reader, writer); else if (name.equals(kELEM_NUMBER)) writeNumber(start, reader, writer); else if (name.equals(kELEM_BOOLEAN)) writeBoolean(start, reader, writer); else if (name.equals(kELEM_NULL)) writeNull(reader, writer); else if (name.equals(kELEM_STRING)) writeString(start, reader, writer); else readToEnd(reader); mLevel--; return true; } else if (e.isEndElement()) { mLevel--; return false; } } mLevel--; return false; }