Java 类org.w3c.dom.Node 实例源码
项目:openjdk-jdk10
文件:ElementImpl.java
public String getNamespacePrefix(String uri) {
NamespaceContextIterator eachNamespace = getNamespaceContextNodes();
while (eachNamespace.hasNext()) {
org.w3c.dom.Attr namespaceDecl = eachNamespace.nextNamespaceAttr();
if (namespaceDecl.getNodeValue().equals(uri)) {
String candidatePrefix = namespaceDecl.getLocalName();
if ("xmlns".equals(candidatePrefix))
return "";
else
return candidatePrefix;
}
}
// Find if any of the ancestors' name has this uri
org.w3c.dom.Node currentAncestor = this;
while (currentAncestor != null &&
!(currentAncestor instanceof Document)) {
if (uri.equals(currentAncestor.getNamespaceURI()))
return currentAncestor.getPrefix();
currentAncestor = currentAncestor.getParentNode();
}
return null;
}
项目:OpenJSharp
文件:DOMUtil.java
/** Finds and returns the first visible child element node. */
public static Element getFirstVisibleChildElement(Node parent, Hashtable hiddenNodes) {
// search for node
Node child = parent.getFirstChild();
while (child != null) {
if (child.getNodeType() == Node.ELEMENT_NODE &&
!isHidden(child, hiddenNodes)) {
return (Element)child;
}
child = child.getNextSibling();
}
// not found
return null;
}
项目:tuxguitar
文件:GPXDocumentReader.java
public void readBars(){
if( this.xmlDocument != null ){
NodeList barNodes = getChildNodeList(this.xmlDocument.getFirstChild(), "Bars");
for( int i = 0 ; i < barNodes.getLength() ; i ++ ){
Node barNode = barNodes.item( i );
if( barNode.getNodeName().equals("Bar") ){
GPXBar bar = new GPXBar();
bar.setId(getAttributeIntegerValue(barNode, "id"));
bar.setVoiceIds( getChildNodeIntegerContentArray(barNode, "Voices"));
bar.setClef(getChildNodeContent(barNode, "Clef"));
bar.setSimileMark(getChildNodeContent(barNode,"SimileMark"));
this.gpxDocument.getBars().add( bar );
}
}
}
}
项目:openjdk-jdk10
文件:RangeImpl.java
/**
* Returns true IFF the given node can be contained by
* a range.
*/
private boolean isLegalContainedNode( Node node )
{
if ( node==null )
return false;
switch( node.getNodeType() )
{
case Node.DOCUMENT_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.ATTRIBUTE_NODE:
case Node.ENTITY_NODE:
case Node.NOTATION_NODE:
return false;
}
return true;
}
项目:openjdk-jdk10
文件:DOM3TreeWalker.java
/**
* End processing of given node
*
*
* @param node Node we just finished processing
*
* @throws org.xml.sax.SAXException
*/
protected void endNode(Node node) throws org.xml.sax.SAXException {
switch (node.getNodeType()) {
case Node.DOCUMENT_NODE :
break;
case Node.DOCUMENT_TYPE_NODE :
serializeDocType((DocumentType) node, false);
break;
case Node.ELEMENT_NODE :
serializeElement((Element) node, false);
break;
case Node.CDATA_SECTION_NODE :
break;
case Node.ENTITY_REFERENCE_NODE :
serializeEntityReference((EntityReference) node, false);
break;
default :
}
}
项目:OpenJSharp
文件:ExsltSets.java
/**
* The set:intersection function returns a node set comprising the nodes that are within
* both the node sets passed as arguments to it.
*
* @param nl1 NodeList for first node-set.
* @param nl2 NodeList for second node-set.
* @return a NodeList containing the nodes in nl1 that are also
* in nl2.
*
* @see <a href="http://www.exslt.org/">EXSLT</a>
*/
public static NodeList intersection(NodeList nl1, NodeList nl2)
{
NodeSet ns1 = new NodeSet(nl1);
NodeSet ns2 = new NodeSet(nl2);
NodeSet inter = new NodeSet();
inter.setShouldCacheNodes(true);
for (int i = 0; i < ns1.getLength(); i++)
{
Node n = ns1.elementAt(i);
if (ns2.contains(n))
inter.addElement(n);
}
return inter;
}
项目:openjdk-jdk10
文件:ElementImpl.java
private Node getPreviousLogicalSibling(Node n) {
Node prev = n.getPreviousSibling();
// If "n" has no previous sibling and its parent is an entity reference node we
// need to continue the search through the previous siblings of the entity
// reference as these are logically siblings of the given node.
if (prev == null) {
Node parent = n.getParentNode();
while (parent != null && parent.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
prev = parent.getPreviousSibling();
if (prev != null) {
break;
}
parent = parent.getParentNode();
}
}
return prev;
}
项目:OpenJSharp
文件:AttrImpl.java
/**
* Make newChild occupy the location that oldChild used to
* have. Note that newChild will first be removed from its previous
* parent, if any. Equivalent to inserting newChild before oldChild,
* then removing oldChild.
*
* @return oldChild, in its new state (removed).
*
* @throws DOMException(HIERARCHY_REQUEST_ERR) if newChild is of a
* type that shouldn't be a child of this node, or if newChild is
* one of our ancestors.
*
* @throws DOMException(WRONG_DOCUMENT_ERR) if newChild has a
* different owner document than we do.
*
* @throws DOMException(NOT_FOUND_ERR) if oldChild is not a child of
* this node.
*
* @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) if this node is
* read-only.
*/
public Node replaceChild(Node newChild, Node oldChild)
throws DOMException {
makeChildNode();
// If Mutation Events are being generated, this operation might
// throw aggregate events twice when modifying an Attr -- once
// on insertion and once on removal. DOM Level 2 does not specify
// this as either desirable or undesirable, but hints that
// aggregations should be issued only once per user request.
// notify document
CoreDocumentImpl ownerDocument = ownerDocument();
ownerDocument.replacingNode(this);
internalInsertBefore(newChild, oldChild, true);
if (newChild != oldChild) {
internalRemoveChild(oldChild, true);
}
// notify document
ownerDocument.replacedNode(this);
return oldChild;
}
项目:openjdk-jdk10
文件:XMLCipher.java
/**
* Encrypts an <code>Element</code> and replaces it with its encrypted
* counterpart in the context <code>Document</code>, that is, the
* <code>Document</code> specified when one calls
* {@link #getInstance(String) getInstance}.
*
* @param element the <code>Element</code> to encrypt.
* @return the context <code>Document</code> with the encrypted
* <code>Element</code> having replaced the source <code>Element</code>.
* @throws Exception
*/
private Document encryptElement(Element element) throws Exception{
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Encrypting element...");
}
if (null == element) {
log.log(java.util.logging.Level.SEVERE, "Element unexpectedly null...");
}
if (cipherMode != ENCRYPT_MODE && log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in ENCRYPT_MODE...");
}
if (algorithm == null) {
throw new XMLEncryptionException("XMLCipher instance without transformation specified");
}
encryptData(contextDocument, element, false);
Element encryptedElement = factory.toElement(ed);
Node sourceParent = element.getParentNode();
sourceParent.replaceChild(encryptedElement, element);
return contextDocument;
}
项目:kaltura-ce-sakai-extension
文件:KalturaAssetDistributionPropertyCondition.java
public KalturaAssetDistributionPropertyCondition(Element node) throws KalturaApiException {
super(node);
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node aNode = childNodes.item(i);
String nodeName = aNode.getNodeName();
String txt = aNode.getTextContent();
if (nodeName.equals("propertyName")) {
this.propertyName = ParseUtils.parseString(txt);
continue;
} else if (nodeName.equals("propertyValue")) {
this.propertyValue = ParseUtils.parseString(txt);
continue;
}
}
}
项目:openjdk-jdk10
文件:DOMScanner.java
private void visit( Node n ) throws SAXException {
setCurrentLocation( n );
// if a case statement gets too big, it should be made into a separate method.
switch(n.getNodeType()) {
case Node.CDATA_SECTION_NODE:
case Node.TEXT_NODE:
String value = n.getNodeValue();
receiver.characters( value.toCharArray(), 0, value.length() );
break;
case Node.ELEMENT_NODE:
visit( (Element)n );
break;
case Node.ENTITY_REFERENCE_NODE:
receiver.skippedEntity(n.getNodeName());
break;
case Node.PROCESSING_INSTRUCTION_NODE:
ProcessingInstruction pi = (ProcessingInstruction)n;
receiver.processingInstruction(pi.getTarget(),pi.getData());
break;
}
}
项目:AndroidApktool
文件:ResXmlPatcher.java
/**
* Removes attributes like "versionCode" and "versionName" from file.
*
* @param file File representing AndroidManifest.xml
* @throws AndrolibException
*/
public static void removeManifestVersions(File file) throws AndrolibException {
if (file.exists()) {
try {
Document doc = loadDocument(file);
Node manifest = doc.getFirstChild();
NamedNodeMap attr = manifest.getAttributes();
Node vCode = attr.getNamedItem("android:versionCode");
Node vName = attr.getNamedItem("android:versionName");
if (vCode != null) {
attr.removeNamedItem("android:versionCode");
}
if (vName != null) {
attr.removeNamedItem("android:versionName");
}
saveDocument(file, doc);
} catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) {
}
}
}
项目:openjdk-jdk10
文件:MagentaEXIFTest.java
static void displayMetadata(Node node, int level) {
for (int i = 0; i < level; i++) System.out.print(" ");
System.out.print("<" + node.getNodeName());
NamedNodeMap map = node.getAttributes();
if (map != null) { // print attribute values
int length = map.getLength();
for (int i = 0; i < length; i++) {
Node attr = map.item(i);
System.out.print(" " + attr.getNodeName() +
"=\"" + attr.getNodeValue() + "\"");
}
}
Node child = node.getFirstChild();
if (child != null) {
System.out.println(">"); // close current tag
while (child != null) { // emit child tags recursively
displayMetadata(child, level + 1);
child = child.getNextSibling();
}
for (int i = 0; i < level; i++) System.out.print(" ");
System.out.println("</" + node.getNodeName() + ">");
} else {
System.out.println("/>");
}
}
项目:convertigo-eclipse
文件:SourcePickerHelper.java
private void removeUserDefinedNodes(Element parent) {
HashSet<Node> toRemove = new HashSet<Node>();
NodeList list = parent.getChildNodes();
for (int i=0; i<list.getLength(); i++) {
Node node = list.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
((Element)node).removeAttribute("done");
((Element)node).removeAttribute("hashcode");
if (node.getNodeName().equals("schema-type")) {
toRemove.add(node);
}
else {
removeUserDefinedNodes((Element)node);
}
}
}
Iterator<Node> it = toRemove.iterator();
while (it.hasNext()) {
parent.removeChild(it.next());
}
toRemove.clear();
}
项目:oscm
文件:ShareResultEvaluator.java
public void assertRevenueShareDetails_BrokerService(String marketplaceId,
VOService service, String expectedServiceRevenue,
String expectedMarketplacePercentage,
String expectedMarketplaceRevenue,
String expectedOperatorPercentage, String expectedOperatorRevenue,
String expectedBrokerPercentage, String expectedBrokerRevenue,
String expectedSupplierAmount) throws Exception {
Node revenueShareDetails = assertRevenueShareDetails(marketplaceId,
service, expectedServiceRevenue, expectedMarketplacePercentage,
expectedMarketplaceRevenue, expectedOperatorPercentage,
expectedOperatorRevenue, expectedSupplierAmount);
assertAttribute(
revenueShareDetails,
BillingShareResultXmlTags.ATTRIBUTE_NAME_BROKER_REVENUE_SHARE_PERCENTAGE,
expectedBrokerPercentage);
assertAttribute(revenueShareDetails,
BillingShareResultXmlTags.ATTRIBUTE_NAME_BROKER_REVENUE,
expectedBrokerRevenue);
}
项目:myfaces-trinidad
文件:RemoveChildComponentChange.java
/**
* {@inheritDoc}
*/
public void changeDocument(Node componentNode)
{
Node currChild = componentNode.getFirstChild();
while (currChild != null)
{
NamedNodeMap attributes = currChild.getAttributes();
if (attributes != null)
{
Node idAttr = attributes.getNamedItem(_identifier);
if (idAttr != null)
{
if (_childId.equals(idAttr.getNodeValue()))
{
currChild.getParentNode().removeChild(currChild);
break;
}
}
}
currChild = currChild.getNextSibling();
}
}
项目:java-tools
文件:XmlTreeOperations.java
private static void indentNode(org.w3c.dom.Node node, int nIndent) {
if (node == null)
return;
if (nIndent > 0 && (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE || node.getNodeType() == org.w3c.dom.Node.COMMENT_NODE))
{
if (node.getPreviousSibling() == null ||
(node.getPreviousSibling().getNodeType() != org.w3c.dom.Node.CDATA_SECTION_NODE &&
node.getPreviousSibling().getNodeType() != org.w3c.dom.Node.TEXT_NODE))
{
String sIndent = "\n";
for (int i=0; i<nIndent; i++) sIndent += "\t";
node.getParentNode().insertBefore(node.getOwnerDocument().createTextNode(sIndent), node);
if (node.getNextSibling() == null)
{
sIndent = sIndent.substring(0, nIndent);
node.getParentNode().appendChild(node.getOwnerDocument().createTextNode(sIndent));
}
}
}
for (org.w3c.dom.Node child = node.getFirstChild(); child != null; child = child.getNextSibling())
indentNode(child, nIndent+1);
}
项目:openjdk-jdk10
文件:NodeSet.java
/**
* Copy NodeList members into this nodelist, adding in
* document order. If a node is null, don't add it.
*
* @param nodelist List of nodes which should now be referenced by
* this NodeSet.
* @throws RuntimeException thrown if this NodeSet is not of
* a mutable type.
*/
public void addNodes(NodeList nodelist)
{
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
if (null != nodelist) // defensive to fix a bug that Sanjiva reported.
{
int nChildren = nodelist.getLength();
for (int i = 0; i < nChildren; i++)
{
Node obj = nodelist.item(i);
if (null != obj)
{
addElement(obj);
}
}
}
// checkDups();
}
项目:OpenJSharp
文件:ExsltSets.java
/**
* The set:leading function returns the nodes in the node set passed as the first argument that
* precede, in document order, the first node in the node set passed as the second argument. If
* the first node in the second node set is not contained in the first node set, then an empty
* node set is returned. If the second node set is empty, then the first node set is returned.
*
* @param nl1 NodeList for first node-set.
* @param nl2 NodeList for second node-set.
* @return a NodeList containing the nodes in nl1 that precede in document order the first
* node in nl2; an empty node-set if the first node in nl2 is not in nl1; all of nl1 if nl2
* is empty.
*
* @see <a href="http://www.exslt.org/">EXSLT</a>
*/
public static NodeList leading (NodeList nl1, NodeList nl2)
{
if (nl2.getLength() == 0)
return nl1;
NodeSet ns1 = new NodeSet(nl1);
NodeSet leadNodes = new NodeSet();
Node endNode = nl2.item(0);
if (!ns1.contains(endNode))
return leadNodes; // empty NodeSet
for (int i = 0; i < nl1.getLength(); i++)
{
Node testNode = nl1.item(i);
if (DOMHelper.isNodeAfter(testNode, endNode)
&& !DOMHelper.isNodeTheSame(testNode, endNode))
leadNodes.addElement(testNode);
}
return leadNodes;
}
项目:OpenVSP3Plugin
文件:OpenVSP3File.java
private TreeItem<DesignVariableGroup> getUserParmContainer() throws Exception {
Map<String, TreeItem<DesignVariableGroup>> map = new HashMap<>();
TreeItem<DesignVariableGroup> container = new TreeItem<>(new DesignVariableGroup(USERPARMS));
NodeList nodes = xpu.getElementNodes(USERPARMPATH);
for (int i = 1; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
String groupName = XPathUtil.getNodeAttribute(node, "GroupName", null);
if (groupName != null) {
TreeItem<DesignVariableGroup> group;
if (map.containsKey(groupName)) {
group = map.get(groupName);
} else {
group = new TreeItem<>(new DesignVariableGroup(groupName));
map.put(groupName, group);
container.getChildren().add(group);
}
addDesignVariable(container, group, XPathUtil.getNodeAttribute(node, "Name", ""),
XPathUtil.getNodeAttribute(node, "ID", ""),
XPathUtil.getNodeAttribute(node, "Value", ""),
USERPARMPATH + "[" + i + "]",
false);
}
}
return container;
}
项目:jdk8u-jdk
文件:DOMKeyInfo.java
public void marshal(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
if (parent == null) {
throw new NullPointerException("parent is null");
}
if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
throw new ClassCastException("parent must be of type DOMStructure");
}
Node pNode = ((javax.xml.crypto.dom.DOMStructure)parent).getNode();
String dsPrefix = DOMUtils.getSignaturePrefix(context);
Element kiElem = DOMUtils.createElement
(DOMUtils.getOwnerDocument(pNode), "KeyInfo",
XMLSignature.XMLNS, dsPrefix);
if (dsPrefix == null || dsPrefix.length() == 0) {
kiElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
"xmlns", XMLSignature.XMLNS);
} else {
kiElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
"xmlns:" + dsPrefix, XMLSignature.XMLNS);
}
marshal(pNode, kiElem, null, dsPrefix, (DOMCryptoContext)context);
}
项目:defense-solutions-proofs-of-concept
文件:CoTAdapterInbound.java
private String getAttribute(Node node, String attributeName)
throws Exception {
try {
NamedNodeMap attributes = node.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node attributeNode = attributes.item(i);
if (attributeNode.getNodeName().equals(attributeName)) {
return attributeNode.getNodeValue();
}
}
return null;
} catch (Exception e) {
log.error(e);
log.error(e.getStackTrace());
throw (e);
}
}
项目:openjdk-jdk10
文件:NodeInfo.java
/**
* <code>lineNumber</code> returns the line number of the node
* passed as argument. If a node set is passed as argument, the line
* number of the first node in the set is returned.
*
* NOTE: Xalan does not normally record location information for each node.
* To obtain it, you must set the custom TrAX attribute
* "http://xml.apache.org/xalan/features/source_location"
* true in the TransformerFactory before generating the Transformer and executing
* the stylesheet. Storage cost per node will be noticably increased in this mode.
*
* @param nodeList a <code>NodeList</code> value
* @return an <code>int</code> value. This may be -1 to indicate that the
* line number is not known.
*/
public static int lineNumber(NodeList nodeList)
{
if (nodeList == null || nodeList.getLength() == 0)
return -1;
Node node = nodeList.item(0);
int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber();
SourceLocator locator = ((DTMNodeProxy)node).getDTM()
.getSourceLocatorFor(nodeHandler);
if (locator != null)
return locator.getLineNumber();
else
return -1;
}
项目:whackpad
文件:XmlNode.java
void replaceWith(XmlNode other) {
Node replacement = other.dom;
if (replacement.getOwnerDocument() != this.dom.getOwnerDocument()) {
replacement = this.dom.getOwnerDocument().importNode(replacement, true);
}
this.dom.getParentNode().replaceChild(replacement, this.dom);
}
项目:convertigo-engine
文件:DOMNodePointer.java
/**
* Locates a node by ID.
* @param context starting context
* @param id to find
* @return Pointer
*/
public Pointer getPointerByID(JXPathContext context, String id) {
Document document = node.getNodeType() == Node.DOCUMENT_NODE ? (Document) node
: node.getOwnerDocument();
Element element = document.getElementById(id);
return element == null ? (Pointer) new NullPointer(getLocale(), id)
: new DOMNodePointer(element, getLocale(), id);
}
项目:openjdk-jdk10
文件:CanonicalizerBase.java
protected int isVisibleInt(Node currentNode) {
if (nodeFilter != null) {
Iterator<NodeFilter> it = nodeFilter.iterator();
while (it.hasNext()) {
int i = (it.next()).isNodeInclude(currentNode);
if (i != 1) {
return i;
}
}
}
if ((this.xpathNodeSet != null) && !this.xpathNodeSet.contains(currentNode)) {
return 0;
}
return 1;
}
项目:alvisnlp
文件:XMLWriter.java
public static final double number(ExpressionContext ctx, String exprStr) {
Evaluator expr = expressionCache.safeGet(exprStr);
Node node = ctx.getContextNode();
Element elt = getElement(node);
if (elt == null)
return Double.MIN_VALUE;
return expr.evaluateDouble(EVALUATION_CONTEXT, elt);
}
项目:java-tools
文件:XmlTreeOperations.java
public static Node dereference12(Node node) throws Exception
{
if (node.getNodeType() == Node.ELEMENT_NODE && ((Element) node).hasAttributeNS("http://www.w3.org/2003/05/soap-encoding", "ref"))
{
String ref = ((Element) node).getAttributeNS("http://www.w3.org/2003/05/soap-encoding", "ref");
if (ref.length() == 0)
throw new Exception("Cannot dereference null references.");
Node refNode = derefNode12(node.getOwnerDocument().getDocumentElement(), ref);
if (refNode != null)
return refNode;
}
return node;
}
项目:OpenJSharp
文件:DOMLocatorImpl.java
public DOMLocatorImpl (int lineNumber, int columnNumber, int byteoffset, Node relatedData, String uri ){
fLineNumber = lineNumber ;
fColumnNumber = columnNumber ;
fByteOffset = byteoffset ;
fRelatedNode = relatedData ;
fUri = uri;
}
项目:oscm
文件:SharesXMLNodeSearch.java
public static Node getResellerRevenuePerSupplierNode(Node document,
String currency, String supplierId) throws XPathExpressionException {
String xpath = String
.format("/Supplier[.//OrganizationData[@id='%s']]/ResellerRevenuePerSupplier",
supplierId);
return XMLConverter.getNodeByXPath(document,
currencyPathPrefix(currency) + xpath);
}
项目:OpenJSharp
文件:ElementImpl.java
public ElementImpl(String prefix, String localpart, String rawname,
String uri, int line, int column, int offset) {
super(prefix, localpart, rawname, uri, Node.ELEMENT_NODE);
row = -1;
col = -1;
parentRow = -1;
this.line = line;
this.column = column;
charOffset = offset;
}
项目:L2jBrasil
文件:DocumentBase.java
protected void attachSkill(Node n, Object template, Condition attachCond)
{
NamedNodeMap attrs = n.getAttributes();
int id = 0, lvl = 1;
if (attrs.getNamedItem("id") != null)
{
id = Integer.decode(getValue(attrs.getNamedItem("id").getNodeValue(), template));
}
if (attrs.getNamedItem("lvl") != null)
{
lvl = Integer.decode(getValue(attrs.getNamedItem("lvl").getNodeValue(), template));
}
L2Skill skill = SkillTable.getInstance().getInfo(id, lvl);
if (attrs.getNamedItem("chance") != null)
{
if (template instanceof L2Weapon || template instanceof L2Item)
{
skill.attach(new ConditionGameChance(Integer.decode(getValue(attrs.getNamedItem("chance").getNodeValue(), template))), true);
}
else
{
skill.attach(new ConditionGameChance(Integer.decode(getValue(attrs.getNamedItem("chance").getNodeValue(), template))), false);
}
}
if (template instanceof L2Weapon)
{
if (attrs.getNamedItem("onUse") != null
|| (attrs.getNamedItem("onCrit") == null && attrs.getNamedItem("onCast") == null))
((L2Weapon) template).attach(skill); // Attach as skill triggered on use
if (attrs.getNamedItem("onCrit") != null) ((L2Weapon) template).attachOnCrit(skill); // Attach as skill triggered on critical hit
if (attrs.getNamedItem("onCast") != null) ((L2Weapon) template).attachOnCast(skill); // Attach as skill triggered on cast
}
else if (template instanceof L2Item)
{
((L2Item) template).attach(skill); // Attach as skill triggered on use
}
}
项目:convertigo-engine
文件:XMLUtils.java
public static List<Node> toArrayList(NodeList nl) {
List<Node> res = new ArrayList<Node>();
for (int i = 0 ; i < nl.getLength() ; i++) {
res.add(nl.item(i));
}
return res;
}
项目:openjdk-jdk10
文件:XMLUtils.java
/**
* @param sibling
* @param uri
* @param nodeName
* @return nodes with the constraint
*/
public static Element[] selectNodes(Node sibling, String uri, String nodeName) {
List<Element> list = new ArrayList<Element>();
while (sibling != null) {
if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri)
&& sibling.getLocalName().equals(nodeName)) {
list.add((Element)sibling);
}
sibling = sibling.getNextSibling();
}
return list.toArray(new Element[list.size()]);
}
项目:oscm
文件:BugAsyncIT.java
@Test
public void billingPerUnitWeekBug10091() throws Exception {
// given subscription data for scenario
testSetup.createWeekScenarioBug10091();
// when billing run performed
performBillingRun(0, "2013-05-16 07:00:00");
// then
VOSubscriptionDetails voSubscriptionDetails = getSubscriptionDetails(
"BUG10091_PERUNIT_WEEK", 0);
Document billingResult = loadBillingResult(
voSubscriptionDetails.getKey(),
DateTimeHandling.calculateMillis("2013-04-10 00:00:00"),
DateTimeHandling.calculateMillis("2013-05-10 00:00:00"));
BillingResultEvaluator eva = new BillingResultEvaluator(billingResult);
eva.assertNullOneTimeFee();
eva.assertOverallCosts("EUR", "709.10");
voSubscriptionDetails = getSubscriptionDetails("BUG10091_PERUNIT_WEEK",
0);
billingResult = loadBillingResult(voSubscriptionDetails.getKey(),
DateTimeHandling.calculateMillis("2013-03-10 00:00:00"),
DateTimeHandling.calculateMillis("2013-04-10 00:00:00"));
Node priceModel = BillingXMLNodeSearch.getPriceModelNode(billingResult,
voSubscriptionDetails.getPriceModel().getKey());
eva = new BillingResultEvaluator(billingResult);
eva.assertOneTimeFee(priceModel, "25.00");
}
项目:openjdk-jdk10
文件:XMLUtils.java
/**
* @param sibling
* @param uri
* @param nodeName
* @param number
* @return nodes with the constrain
*/
public static Element selectNode(Node sibling, String uri, String nodeName, int number) {
while (sibling != null) {
if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri)
&& sibling.getLocalName().equals(nodeName)) {
if (number == 0){
return (Element)sibling;
}
number--;
}
sibling = sibling.getNextSibling();
}
return null;
}
项目:openjdk-jdk10
文件:DeferredDocumentImpl.java
public void setInternalSubset(int doctypeIndex, String subset) {
int chunk = doctypeIndex >> CHUNK_SHIFT;
int index = doctypeIndex & CHUNK_MASK;
// create extra data node to store internal subset
int extraDataIndex = createNode(Node.DOCUMENT_TYPE_NODE);
int echunk = extraDataIndex >> CHUNK_SHIFT;
int eindex = extraDataIndex & CHUNK_MASK;
setChunkIndex(fNodeExtra, extraDataIndex, chunk, index);
setChunkValue(fNodeValue, subset, echunk, eindex);
}
项目:L2jBrasil
文件:FaenorQuestParser.java
private void parseQuestDrop(Node drop, String questID)// throws NullPointerException
{
if (DEBUG) System.out.println("Parsing Drop.");
int npcID;
int itemID;
int min;
int max;
int chance;
String[] states;
try
{
npcID = getInt(attribute(drop, "NpcID"));
itemID = getInt(attribute(drop, "ItemID"));
min = getInt(attribute(drop, "Min"));
max = getInt(attribute(drop, "Max"));
chance = getInt(attribute(drop, "Chance"));
states = (attribute(drop, "States")).split(",");
}
catch (NullPointerException e)
{
throw new NullPointerException("Incorrect Drop Data");
}
if (DEBUG) System.out.println("Adding Drop to NpcID: "+npcID);
_bridge.addQuestDrop(npcID, itemID, min, max, chance, questID, states);
}
项目:cas-server-4.2.1
文件:AbstractSamlObjectBuilder.java
/**
* Gets the xml signature insert location.
*
* @param elem the elem
* @return the xml signature insert location
*/
private static Node getXmlSignatureInsertLocation(final org.w3c.dom.Element elem) {
org.w3c.dom.Node insertLocation = null;
org.w3c.dom.NodeList nodeList = elem.getElementsByTagNameNS(
SAMLConstants.SAML20P_NS, "Extensions");
if (nodeList.getLength() != 0) {
insertLocation = nodeList.item(nodeList.getLength() - 1);
} else {
nodeList = elem.getElementsByTagNameNS(SAMLConstants.SAML20P_NS, "Status");
insertLocation = nodeList.item(nodeList.getLength() - 1);
}
return insertLocation;
}
项目:convertigo-engine
文件:WebClipper2.java
protected void removeUnwanted(Element elt){
try {
NodeList aElements = xpathApi.selectNodeList(elt,".//*[@href[name(..)=\"A\"]]"); // A with href
NodeList nodes = xpathApi.selectNodeList(elt, ".//SCRIPT" // remove scripts
+"|.//@*[starts-with(name(),\"on\")]" // remove on*** attributes
+"|.//@action" // remove action attributes
+"|.//@href[name(..)=\"A\"]" // remove href attributes of A elements
+"|.//@target[name(..)=\"A\"]" // remove target attributes of A elements
);
for(int i=0;i<nodes.getLength();i++){
Node node = nodes.item(i);
if(node instanceof Attr){
Attr at = (Attr)node;
at.getOwnerElement().removeAttributeNode(at);
}else if(node!=null && node.getParentNode()!=null)
node.getParentNode().removeChild(node);
}
for(int i=0;i<aElements.getLength();i++) // restore fake href
((Element)aElements.item(i)).setAttribute("href", "#");
xpathApi.resetCache(); // dom change
} catch (TransformerException e) {
Engine.logBeans.error("Exception when using xpathAPI on WebClipper.removeUnwanted()");
}
}