org.xbrlapi.impl
Class FragmentComparator
java.lang.Object
org.xbrlapi.impl.FragmentComparator
- All Implemented Interfaces:
- Comparator<Fragment>
public class FragmentComparator
- extends Object
- implements Comparator<Fragment>
Facilitates sorting of fragments so that
they can be organised into
complete XML document in the right order.
- Author:
- Geoffrey Shuetrim (geoff@galexy.net)
|
Method Summary |
int |
compare(Fragment f1,
Fragment f2)
Compare two fragment objects and order such that fragments in different documents
are grouped separately and so that the fragments are ordered from the closest to the end
of the document in document order to the closest to the beginning in document order. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FragmentComparator
public FragmentComparator()
compare
public int compare(Fragment f1,
Fragment f2)
throws ClassCastException
- Compare two fragment objects and order such that fragments in different documents
are grouped separately and so that the fragments are ordered from the closest to the end
of the document in document order to the closest to the beginning in document order.
Fragments are sorted:
- in INCREASING alphanumeric ordering of the URI of the document that the fragment belongs to; then
- in INCREASING order of the index of their parent fragment with root fragments being ordered first of all; then
- in DECREASING order of the XPath to the containing element in the parent fragment; then
- in INCREASING order of the fragment index which implies being in increasing order of the number of preceding sibling fragments.
This sorting rule implies that a set of child fragments will be sorted into the order
necessary for insertion into a parent fragment without the insertion of child fragments
causing the later fragment insertions to be done in the wrong place. This is because
the fragment insertions will be done from the end of the parent fragment, in document order
to the beginning of the parent fragment, again in document order.
- Specified by:
compare in interface Comparator<Fragment>
- Throws:
ClassCastException- See Also:
Comparator.compare(java.lang.Object, java.lang.Object)