Lines 10-20
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.internal.core; |
11 |
package org.eclipse.jdt.internal.core; |
12 |
|
12 |
|
|
|
13 |
import java.io.CharArrayWriter; |
13 |
import java.io.File; |
14 |
import java.io.File; |
|
|
15 |
import java.io.IOException; |
16 |
import java.util.ArrayList; |
14 |
import java.util.HashMap; |
17 |
import java.util.HashMap; |
15 |
import java.util.HashSet; |
18 |
import java.util.HashSet; |
16 |
import java.util.Map; |
19 |
import java.util.Map; |
17 |
|
20 |
|
|
|
21 |
import org.apache.crimson.tree.XmlWritable; |
22 |
import org.apache.crimson.tree.XmlWriteContext; |
18 |
import org.eclipse.core.resources.IProject; |
23 |
import org.eclipse.core.resources.IProject; |
19 |
import org.eclipse.core.resources.IResource; |
24 |
import org.eclipse.core.resources.IResource; |
20 |
import org.eclipse.core.resources.IWorkspaceRoot; |
25 |
import org.eclipse.core.resources.IWorkspaceRoot; |
Lines 39-45
Link Here
|
39 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
44 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
40 |
import org.eclipse.jdt.internal.core.util.Messages; |
45 |
import org.eclipse.jdt.internal.core.util.Messages; |
41 |
import org.eclipse.jdt.internal.core.util.Util; |
46 |
import org.eclipse.jdt.internal.core.util.Util; |
|
|
47 |
import org.w3c.dom.DOMException; |
42 |
import org.w3c.dom.Element; |
48 |
import org.w3c.dom.Element; |
|
|
49 |
import org.w3c.dom.NamedNodeMap; |
43 |
import org.w3c.dom.Node; |
50 |
import org.w3c.dom.Node; |
44 |
import org.w3c.dom.NodeList; |
51 |
import org.w3c.dom.NodeList; |
45 |
|
52 |
|
Lines 119-124
Link Here
|
119 |
private String rootID; |
126 |
private String rootID; |
120 |
private AccessRuleSet accessRuleSet; |
127 |
private AccessRuleSet accessRuleSet; |
121 |
|
128 |
|
|
|
129 |
|
130 |
static class UnknownXmlElements { |
131 |
String[] attributes; |
132 |
ArrayList children; |
133 |
} |
134 |
|
122 |
/* |
135 |
/* |
123 |
* Default inclusion pattern set |
136 |
* Default inclusion pattern set |
124 |
*/ |
137 |
*/ |
Lines 278-287
Link Here
|
278 |
return result; |
291 |
return result; |
279 |
} |
292 |
} |
280 |
|
293 |
|
281 |
static IClasspathAttribute[] decodeExtraAttributes(Element element) { |
294 |
static IClasspathAttribute[] decodeExtraAttributes(NodeList attributes) { |
282 |
Node extra = element.getElementsByTagName(TAG_ATTRIBUTES).item(0); |
|
|
283 |
if (extra == null) return NO_EXTRA_ATTRIBUTES; |
284 |
NodeList attributes = element.getElementsByTagName(TAG_ATTRIBUTE); |
285 |
if (attributes == null) return NO_EXTRA_ATTRIBUTES; |
295 |
if (attributes == null) return NO_EXTRA_ATTRIBUTES; |
286 |
int length = attributes.getLength(); |
296 |
int length = attributes.getLength(); |
287 |
if (length == 0) return NO_EXTRA_ATTRIBUTES; |
297 |
if (length == 0) return NO_EXTRA_ATTRIBUTES; |
Lines 303-333
Link Here
|
303 |
return result; |
313 |
return result; |
304 |
} |
314 |
} |
305 |
|
315 |
|
306 |
static IAccessRule[] decodeAccessRules(Element element) { |
316 |
static IAccessRule[] decodeAccessRules(NodeList list) { |
307 |
Node accessRules = element.getElementsByTagName(TAG_ACCESS_RULES).item(0); |
317 |
if (list == null) return null; |
308 |
if (accessRules == null || accessRules.getNodeType() != Node.ELEMENT_NODE) return null; |
|
|
309 |
NodeList list = ((Element) accessRules).getElementsByTagName(TAG_ACCESS_RULE); |
310 |
int length = list.getLength(); |
318 |
int length = list.getLength(); |
311 |
if (length == 0) return null; |
319 |
if (length == 0) return null; |
312 |
IAccessRule[] result = new IAccessRule[length]; |
320 |
IAccessRule[] result = new IAccessRule[length]; |
313 |
int index = 0; |
321 |
int index = 0; |
314 |
for (int i = 0; i < length; i++) { |
322 |
for (int i = 0; i < length; i++) { |
315 |
Node accessRule = list.item(i); |
323 |
Node accessRule = list.item(i); |
316 |
if (accessRule == null || accessRule.getNodeType() != Node.ELEMENT_NODE) return null; |
324 |
if (accessRule.getNodeType() == Node.ELEMENT_NODE) { |
317 |
Element elementAccessRule = (Element) accessRule; |
325 |
Element elementAccessRule = (Element) accessRule; |
318 |
String pattern = elementAccessRule.getAttribute(TAG_PATTERN); |
326 |
String pattern = elementAccessRule.getAttribute(TAG_PATTERN); |
319 |
if (pattern == null) continue; |
327 |
if (pattern == null) continue; |
320 |
String tagKind = elementAccessRule.getAttribute(TAG_KIND); |
328 |
String tagKind = elementAccessRule.getAttribute(TAG_KIND); |
321 |
int kind; |
329 |
int kind; |
322 |
if (TAG_ACCESSIBLE.equals(tagKind)) |
330 |
if (TAG_ACCESSIBLE.equals(tagKind)) |
323 |
kind = IAccessRule.K_ACCESSIBLE; |
331 |
kind = IAccessRule.K_ACCESSIBLE; |
324 |
else if (TAG_NON_ACCESSIBLE.equals(tagKind)) |
332 |
else if (TAG_NON_ACCESSIBLE.equals(tagKind)) |
325 |
kind = IAccessRule.K_NON_ACCESSIBLE; |
333 |
kind = IAccessRule.K_NON_ACCESSIBLE; |
326 |
else if (TAG_DISCOURAGED.equals(tagKind)) |
334 |
else if (TAG_DISCOURAGED.equals(tagKind)) |
327 |
kind = IAccessRule.K_DISCOURAGED; |
335 |
kind = IAccessRule.K_DISCOURAGED; |
328 |
else |
336 |
else |
329 |
continue; |
337 |
continue; |
330 |
result[index++] = new ClasspathAccessRule(new Path(pattern), kind); |
338 |
result[index++] = new ClasspathAccessRule(new Path(pattern), kind); |
|
|
339 |
} |
331 |
} |
340 |
} |
332 |
if (index != length) |
341 |
if (index != length) |
333 |
System.arraycopy(result, 0, result = new IAccessRule[index], 0, index); |
342 |
System.arraycopy(result, 0, result = new IAccessRule[index], 0, index); |
Lines 337-344
Link Here
|
337 |
/** |
346 |
/** |
338 |
* Decode some element tag containing a sequence of patterns into IPath[] |
347 |
* Decode some element tag containing a sequence of patterns into IPath[] |
339 |
*/ |
348 |
*/ |
340 |
private static IPath[] decodePatterns(Element element, String tag) { |
349 |
private static IPath[] decodePatterns(NamedNodeMap nodeMap, String tag) { |
341 |
String sequence = element.getAttribute(tag); |
350 |
String sequence = removeAttribute(tag, nodeMap); |
342 |
if (!sequence.equals("")) { //$NON-NLS-1$ |
351 |
if (!sequence.equals("")) { //$NON-NLS-1$ |
343 |
char[][] patterns = CharOperation.splitOn('|', sequence.toCharArray()); |
352 |
char[][] patterns = CharOperation.splitOn('|', sequence.toCharArray()); |
344 |
int patternCount; |
353 |
int patternCount; |
Lines 352-357
Link Here
|
352 |
} |
361 |
} |
353 |
return null; |
362 |
return null; |
354 |
} |
363 |
} |
|
|
364 |
|
365 |
private static void decodeUnknownChild(Node child, StringBuffer buffer) { |
366 |
if (child instanceof XmlWritable) { |
367 |
CharArrayWriter writer = new CharArrayWriter(); |
368 |
XmlWriteContext context = new XmlWriteContext(writer); |
369 |
try { |
370 |
((XmlWritable) child).writeXml(context); |
371 |
buffer.append(writer.toString()); |
372 |
} catch (IOException e) { |
373 |
buffer.append("<exception reading unknown elements (see previous version from local history)>"); //$NON-NLS-1$ |
374 |
} |
375 |
} else { |
376 |
buffer.append("<unknown elements detected (see previous version from local history)>"); //$NON-NLS-1$ |
377 |
} |
378 |
} |
379 |
|
355 |
/* |
380 |
/* |
356 |
* Returns a char based representation of the exclusions patterns full path. |
381 |
* Returns a char based representation of the exclusions patterns full path. |
357 |
*/ |
382 |
*/ |
Lines 389-395
Link Here
|
389 |
/** |
414 |
/** |
390 |
* Returns the XML encoding of the class path. |
415 |
* Returns the XML encoding of the class path. |
391 |
*/ |
416 |
*/ |
392 |
public void elementEncode(XMLWriter writer, IPath projectPath, boolean indent, boolean newLine) { |
417 |
public void elementEncode(XMLWriter writer, IPath projectPath, boolean indent, boolean newLine, Map unknownElements) { |
393 |
HashMap parameters = new HashMap(); |
418 |
HashMap parameters = new HashMap(); |
394 |
|
419 |
|
395 |
parameters.put(TAG_KIND, ClasspathEntry.kindToString(this.entryKind)); |
420 |
parameters.put(TAG_KIND, ClasspathEntry.kindToString(this.entryKind)); |
Lines 433-438
Link Here
|
433 |
parameters.put(TAG_COMBINE_ACCESS_RULES, "false"); //$NON-NLS-1$ |
458 |
parameters.put(TAG_COMBINE_ACCESS_RULES, "false"); //$NON-NLS-1$ |
434 |
|
459 |
|
435 |
|
460 |
|
|
|
461 |
// unknown attributes |
462 |
UnknownXmlElements unknownXmlElements = unknownElements == null ? null : (UnknownXmlElements) unknownElements.get(this.path); |
463 |
String[] unknownAttributes; |
464 |
if (unknownXmlElements != null && (unknownAttributes = unknownXmlElements.attributes) != null) |
465 |
for (int i = 0, length = unknownAttributes.length; i < length; i+=2) { |
466 |
String tagName = unknownAttributes[i]; |
467 |
String tagValue = unknownAttributes[i+1]; |
468 |
parameters.put(tagName, tagValue); |
469 |
} |
470 |
|
436 |
if (this.specificOutputLocation != null) { |
471 |
if (this.specificOutputLocation != null) { |
437 |
IPath outputLocation = this.specificOutputLocation.removeFirstSegments(1); |
472 |
IPath outputLocation = this.specificOutputLocation.removeFirstSegments(1); |
438 |
outputLocation = outputLocation.makeRelative(); |
473 |
outputLocation = outputLocation.makeRelative(); |
Lines 441-455
Link Here
|
441 |
|
476 |
|
442 |
boolean hasExtraAttributes = this.extraAttributes.length != 0; |
477 |
boolean hasExtraAttributes = this.extraAttributes.length != 0; |
443 |
boolean hasRestrictions = getAccessRuleSet() != null; // access rule set is null if no access rules |
478 |
boolean hasRestrictions = getAccessRuleSet() != null; // access rule set is null if no access rules |
444 |
writer.printTag(TAG_CLASSPATHENTRY, parameters, indent, newLine, !hasExtraAttributes && !hasRestrictions /*close tag if no extra attributes and no restriction*/); |
479 |
ArrayList unknownChildren = unknownXmlElements != null ? unknownXmlElements.children : null; |
|
|
480 |
boolean hasUnknownChildren = unknownChildren != null; |
481 |
writer.printTag( |
482 |
TAG_CLASSPATHENTRY, |
483 |
parameters, |
484 |
indent, |
485 |
newLine, |
486 |
!hasExtraAttributes && !hasRestrictions && !hasUnknownChildren/*close tag if no extra attributes, no restriction and no unknown children*/); |
445 |
|
487 |
|
446 |
if (hasExtraAttributes) |
488 |
if (hasExtraAttributes) |
447 |
encodeExtraAttributes(writer, indent, newLine); |
489 |
encodeExtraAttributes(writer, indent, newLine); |
448 |
|
490 |
|
449 |
if (hasRestrictions) |
491 |
if (hasRestrictions) |
450 |
encodeAccessRules(writer, indent, newLine); |
492 |
encodeAccessRules(writer, indent, newLine); |
|
|
493 |
|
494 |
if (hasUnknownChildren) |
495 |
encodeUnknownChildren(writer, indent, newLine, unknownChildren); |
451 |
|
496 |
|
452 |
if (hasExtraAttributes || hasRestrictions) |
497 |
if (hasExtraAttributes || hasRestrictions || hasUnknownChildren) |
453 |
writer.endTag(TAG_CLASSPATHENTRY, indent); |
498 |
writer.endTag(TAG_CLASSPATHENTRY, indent); |
454 |
} |
499 |
} |
455 |
|
500 |
|
Lines 496-506
Link Here
|
496 |
|
541 |
|
497 |
} |
542 |
} |
498 |
|
543 |
|
499 |
public static IClasspathEntry elementDecode(Element element, IJavaProject project) { |
544 |
private void encodeUnknownChildren(XMLWriter writer, boolean indent, boolean newLine, ArrayList unknownChildren) { |
|
|
545 |
for (int i = 0, length = unknownChildren.size(); i < length; i++) { |
546 |
String child = (String) unknownChildren.get(i); |
547 |
writer.printString(child, indent, newLine); |
548 |
} |
549 |
} |
550 |
|
551 |
public static IClasspathEntry elementDecode(Element element, IJavaProject project, Map unknownElements) { |
500 |
|
552 |
|
501 |
IPath projectPath = project.getProject().getFullPath(); |
553 |
IPath projectPath = project.getProject().getFullPath(); |
502 |
String kindAttr = element.getAttribute(TAG_KIND); |
554 |
NamedNodeMap attributes = element.getAttributes(); |
503 |
String pathAttr = element.getAttribute(TAG_PATH); |
555 |
NodeList children = element.getChildNodes(); |
|
|
556 |
boolean[] foundChildren = new boolean[children.getLength()]; |
557 |
String kindAttr = removeAttribute(TAG_KIND, attributes); |
558 |
String pathAttr = removeAttribute(TAG_PATH, attributes); |
504 |
|
559 |
|
505 |
// ensure path is absolute |
560 |
// ensure path is absolute |
506 |
IPath path = new Path(pathAttr); |
561 |
IPath path = new Path(pathAttr); |
Lines 511-539
Link Here
|
511 |
// source attachment info (optional) |
566 |
// source attachment info (optional) |
512 |
IPath sourceAttachmentPath = |
567 |
IPath sourceAttachmentPath = |
513 |
element.hasAttribute(TAG_SOURCEPATH) |
568 |
element.hasAttribute(TAG_SOURCEPATH) |
514 |
? new Path(element.getAttribute(TAG_SOURCEPATH)) |
569 |
? new Path(removeAttribute(TAG_SOURCEPATH, attributes)) |
515 |
: null; |
570 |
: null; |
516 |
if (kind != IClasspathEntry.CPE_VARIABLE && sourceAttachmentPath != null && !sourceAttachmentPath.isAbsolute()) { |
571 |
if (kind != IClasspathEntry.CPE_VARIABLE && sourceAttachmentPath != null && !sourceAttachmentPath.isAbsolute()) { |
517 |
sourceAttachmentPath = projectPath.append(sourceAttachmentPath); |
572 |
sourceAttachmentPath = projectPath.append(sourceAttachmentPath); |
518 |
} |
573 |
} |
519 |
IPath sourceAttachmentRootPath = |
574 |
IPath sourceAttachmentRootPath = |
520 |
element.hasAttribute(TAG_ROOTPATH) |
575 |
element.hasAttribute(TAG_ROOTPATH) |
521 |
? new Path(element.getAttribute(TAG_ROOTPATH)) |
576 |
? new Path(removeAttribute(TAG_ROOTPATH, attributes)) |
522 |
: null; |
577 |
: null; |
523 |
|
578 |
|
524 |
// exported flag (optional) |
579 |
// exported flag (optional) |
525 |
boolean isExported = element.getAttribute(TAG_EXPORTED).equals("true"); //$NON-NLS-1$ |
580 |
boolean isExported = removeAttribute(TAG_EXPORTED, attributes).equals("true"); //$NON-NLS-1$ |
526 |
|
581 |
|
527 |
// inclusion patterns (optional) |
582 |
// inclusion patterns (optional) |
528 |
IPath[] inclusionPatterns = decodePatterns(element, TAG_INCLUDING); |
583 |
IPath[] inclusionPatterns = decodePatterns(attributes, TAG_INCLUDING); |
529 |
if (inclusionPatterns == null) inclusionPatterns = INCLUDE_ALL; |
584 |
if (inclusionPatterns == null) inclusionPatterns = INCLUDE_ALL; |
530 |
|
585 |
|
531 |
// exclusion patterns (optional) |
586 |
// exclusion patterns (optional) |
532 |
IPath[] exclusionPatterns = decodePatterns(element, TAG_EXCLUDING); |
587 |
IPath[] exclusionPatterns = decodePatterns(attributes, TAG_EXCLUDING); |
533 |
if (exclusionPatterns == null) exclusionPatterns = EXCLUDE_NONE; |
588 |
if (exclusionPatterns == null) exclusionPatterns = EXCLUDE_NONE; |
534 |
|
589 |
|
535 |
// access rules (optional) |
590 |
// access rules (optional) |
536 |
IAccessRule[] accessRules = decodeAccessRules(element); |
591 |
NodeList attributeList = getChildAttributes(TAG_ACCESS_RULES, children, foundChildren); |
|
|
592 |
IAccessRule[] accessRules = decodeAccessRules(attributeList); |
537 |
|
593 |
|
538 |
// backward compatibility |
594 |
// backward compatibility |
539 |
if (accessRules == null) { |
595 |
if (accessRules == null) { |
Lines 541-565
Link Here
|
541 |
} |
597 |
} |
542 |
|
598 |
|
543 |
// combine access rules (optional) |
599 |
// combine access rules (optional) |
544 |
boolean combineAccessRestrictions = !element.getAttribute(TAG_COMBINE_ACCESS_RULES).equals("false"); //$NON-NLS-1$ |
600 |
boolean combineAccessRestrictions = !removeAttribute(TAG_COMBINE_ACCESS_RULES, attributes).equals("false"); //$NON-NLS-1$ |
545 |
|
601 |
|
546 |
// extra attributes (optional) |
602 |
// extra attributes (optional) |
547 |
IClasspathAttribute[] extraAttributes = decodeExtraAttributes(element); |
603 |
attributeList = getChildAttributes(TAG_ATTRIBUTES, children, foundChildren); |
|
|
604 |
IClasspathAttribute[] extraAttributes = decodeExtraAttributes(attributeList); |
548 |
|
605 |
|
549 |
// custom output location |
606 |
// custom output location |
550 |
IPath outputLocation = element.hasAttribute(TAG_OUTPUT) ? projectPath.append(element.getAttribute(TAG_OUTPUT)) : null; |
607 |
IPath outputLocation = element.hasAttribute(TAG_OUTPUT) ? projectPath.append(removeAttribute(TAG_OUTPUT, attributes)) : null; |
|
|
608 |
|
609 |
String[] unknownAttributes = null; |
610 |
ArrayList unknownChildren = null; |
611 |
|
612 |
if (unknownElements != null) { |
613 |
// unknown attributes |
614 |
int unknownAttributeLength = attributes.getLength(); |
615 |
if (unknownAttributeLength != 0) { |
616 |
unknownAttributes = new String[unknownAttributeLength*2]; |
617 |
for (int i = 0; i < unknownAttributeLength; i++) { |
618 |
Node attribute = attributes.item(i); |
619 |
unknownAttributes[i*2] = attribute.getNodeName(); |
620 |
unknownAttributes[i*2 + 1] = attribute.getNodeValue(); |
621 |
} |
622 |
} |
623 |
|
624 |
// unknown children |
625 |
for (int i = 0, length = foundChildren.length; i < length; i++) { |
626 |
if (!foundChildren[i]) { |
627 |
Node node = children.item(i); |
628 |
if (node.getNodeType() != Node.ELEMENT_NODE) continue; |
629 |
if (unknownChildren == null) |
630 |
unknownChildren = new ArrayList(); |
631 |
StringBuffer buffer = new StringBuffer(); |
632 |
decodeUnknownChild(node, buffer); |
633 |
unknownChildren.add(buffer.toString()); |
634 |
} |
635 |
} |
636 |
} |
551 |
|
637 |
|
552 |
// recreate the CP entry |
638 |
// recreate the CP entry |
553 |
IClasspathEntry entry = null; |
639 |
IClasspathEntry entry = null; |
554 |
switch (kind) { |
640 |
switch (kind) { |
555 |
|
641 |
|
556 |
case IClasspathEntry.CPE_PROJECT : |
642 |
case IClasspathEntry.CPE_PROJECT : |
557 |
entry = JavaCore.newProjectEntry( |
643 |
entry = new ClasspathEntry( |
558 |
path, |
644 |
IPackageFragmentRoot.K_SOURCE, |
559 |
accessRules, |
645 |
IClasspathEntry.CPE_PROJECT, |
560 |
combineAccessRestrictions, |
646 |
path, |
561 |
extraAttributes, |
647 |
ClasspathEntry.INCLUDE_ALL, // inclusion patterns |
562 |
isExported); |
648 |
ClasspathEntry.EXCLUDE_NONE, // exclusion patterns |
|
|
649 |
null, // source attachment |
650 |
null, // source attachment root |
651 |
null, // specific output folder |
652 |
isExported, |
653 |
accessRules, |
654 |
combineAccessRestrictions, |
655 |
extraAttributes); |
563 |
break; |
656 |
break; |
564 |
case IClasspathEntry.CPE_LIBRARY : |
657 |
case IClasspathEntry.CPE_LIBRARY : |
565 |
entry = JavaCore.newLibraryEntry( |
658 |
entry = JavaCore.newLibraryEntry( |
Lines 574-580
Link Here
|
574 |
// must be an entry in this project or specify another project |
667 |
// must be an entry in this project or specify another project |
575 |
String projSegment = path.segment(0); |
668 |
String projSegment = path.segment(0); |
576 |
if (projSegment != null && projSegment.equals(project.getElementName())) { // this project |
669 |
if (projSegment != null && projSegment.equals(project.getElementName())) { // this project |
577 |
return JavaCore.newSourceEntry(path, inclusionPatterns, exclusionPatterns, outputLocation, extraAttributes); |
670 |
entry = JavaCore.newSourceEntry(path, inclusionPatterns, exclusionPatterns, outputLocation, extraAttributes); |
578 |
} else { |
671 |
} else { |
579 |
if (path.segmentCount() == 1) { |
672 |
if (path.segmentCount() == 1) { |
580 |
// another project |
673 |
// another project |
Lines 586-592
Link Here
|
586 |
isExported); |
679 |
isExported); |
587 |
} else { |
680 |
} else { |
588 |
// an invalid source folder |
681 |
// an invalid source folder |
589 |
return JavaCore.newSourceEntry(path, inclusionPatterns, exclusionPatterns, outputLocation, extraAttributes); |
682 |
entry = JavaCore.newSourceEntry(path, inclusionPatterns, exclusionPatterns, outputLocation, extraAttributes); |
590 |
} |
683 |
} |
591 |
} |
684 |
} |
592 |
break; |
685 |
break; |
Lines 608-614
Link Here
|
608 |
break; |
701 |
break; |
609 |
case ClasspathEntry.K_OUTPUT : |
702 |
case ClasspathEntry.K_OUTPUT : |
610 |
if (!path.isAbsolute()) return null; |
703 |
if (!path.isAbsolute()) return null; |
611 |
return new ClasspathEntry( |
704 |
entry = new ClasspathEntry( |
612 |
ClasspathEntry.K_OUTPUT, |
705 |
ClasspathEntry.K_OUTPUT, |
613 |
IClasspathEntry.CPE_LIBRARY, |
706 |
IClasspathEntry.CPE_LIBRARY, |
614 |
path, |
707 |
path, |
Lines 621-631
Link Here
|
621 |
null, // no access rules |
714 |
null, // no access rules |
622 |
false, // no accessible files to combine |
715 |
false, // no accessible files to combine |
623 |
NO_EXTRA_ATTRIBUTES); |
716 |
NO_EXTRA_ATTRIBUTES); |
|
|
717 |
break; |
624 |
default : |
718 |
default : |
625 |
throw new Assert.AssertionFailedException(Messages.bind(Messages.classpath_unknownKind, kindAttr)); |
719 |
throw new Assert.AssertionFailedException(Messages.bind(Messages.classpath_unknownKind, kindAttr)); |
626 |
} |
720 |
} |
|
|
721 |
|
722 |
if (unknownAttributes != null || unknownChildren != null) { |
723 |
UnknownXmlElements unknownXmlElements = new UnknownXmlElements(); |
724 |
unknownXmlElements.attributes = unknownAttributes; |
725 |
unknownXmlElements.children = unknownChildren; |
726 |
unknownElements.put(path, unknownXmlElements); |
727 |
} |
728 |
|
627 |
return entry; |
729 |
return entry; |
628 |
} |
730 |
} |
|
|
731 |
|
732 |
public static NodeList getChildAttributes(String childName, NodeList children, boolean[] foundChildren) { |
733 |
for (int i = 0, length = foundChildren.length; i < length; i++) { |
734 |
Node node = children.item(i); |
735 |
if (childName.equals(node.getNodeName())) { |
736 |
foundChildren[i] = true; |
737 |
return node.getChildNodes(); |
738 |
} |
739 |
} |
740 |
return null; |
741 |
} |
742 |
|
743 |
|
744 |
private static String removeAttribute(String nodeName, NamedNodeMap nodeMap) { |
745 |
Node node = removeNode(nodeName, nodeMap); |
746 |
if (node == null) |
747 |
return ""; // //$NON-NLS-1$ |
748 |
return node.getNodeValue(); |
749 |
} |
750 |
|
751 |
private static Node removeNode(String nodeName, NamedNodeMap nodeMap) { |
752 |
try { |
753 |
return nodeMap.removeNamedItem(nodeName); |
754 |
} catch (DOMException e) { |
755 |
if (e.code != DOMException.NOT_FOUND_ERR) |
756 |
throw e; |
757 |
return null; |
758 |
} |
759 |
} |
629 |
|
760 |
|
630 |
/** |
761 |
/** |
631 |
* Encode some patterns into XML parameter tag |
762 |
* Encode some patterns into XML parameter tag |