public class DocumentOrderingWrapper
extends java.lang.Object
faces-config
documents found on the classpath or configured explicitly via the
javax.faces.CONFIG_FILES
context init parameter.Modifier and Type | Class and Description |
---|---|
private static class |
DocumentOrderingWrapper.CircularDependencyException |
private static class |
DocumentOrderingWrapper.DocumentOrderingComparator |
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
AFTER
Constant for the
after element. |
private java.lang.String[] |
afterIds
The wrapped Document's before IDs.
|
private static java.lang.String |
BEFORE
Constant for the
before element. |
private java.lang.String[] |
beforeIds
The wrapped Document's before IDs.
|
private static java.util.Comparator<DocumentOrderingWrapper> |
COMPARATOR
Comparator implementation to aid in sorting faces-config
documents. |
private static int |
DO_NOT_SWAP
Return code indicating that no swap needs to occur for the elements
being compared.
|
private DocumentInfo |
documentInfo
The wrapped Document.
|
private java.lang.String |
id
The wrapped Document's ID.
|
private static java.util.logging.Logger |
LOGGER
Logger for this class.
|
private static int |
MAX_SORT_PASSED
This is the limit on the number of attempts made to sort the documents.
|
private static java.lang.String |
NAME
Constant for the
name element. |
private static java.lang.String |
ORDERING
Constant for the
ordering element. |
private static java.lang.String |
OTHERS
Constant for the
others element. |
private static java.lang.String |
OTHERS_KEY
Others keyword for sorting.
|
private static int |
SWAP
Return code indicating that element
n is to be swapped
with n + 1 |
Constructor and Description |
---|
DocumentOrderingWrapper(DocumentInfo document)
Constructs a new
DocumentOrderingWrapper for the specified
Document |
Modifier and Type | Method and Description |
---|---|
private void |
checkDuplicates(java.lang.String[] source,
java.lang.String[] searchTarget)
Ensure the IDs in
source aren't present in searchTarget . |
static <K,V extends java.lang.Comparable<? super V>> |
descendingByValue(java.util.Map<K,V> map) |
static boolean |
done(DocumentOrderingWrapper[] documents,
java.util.LinkedList<java.lang.String> ids) |
private static void |
enhanceOrderingData(DocumentOrderingWrapper[] wrappers)
Update before/after knowledge of all nodes in the array.
|
private java.util.Set<java.lang.String> |
extractIds(org.w3c.dom.Node n,
java.lang.String nodeName)
Extract and return a
Set of IDs contained within the provided
Node . |
java.lang.String[] |
getAfterIds() |
java.lang.String[] |
getBeforeIds() |
DocumentInfo |
getDocument() |
static java.util.HashMap<java.lang.String,DocumentOrderingWrapper> |
getDocumentHashMap(DocumentOrderingWrapper[] documents) |
java.lang.String |
getDocumentId() |
private java.lang.String |
getDocumentName(org.w3c.dom.Element documentElement) |
static java.util.LinkedList<java.lang.String> |
getIds(DocumentOrderingWrapper[] documents) |
private java.lang.String |
getNodeText(org.w3c.dom.Node node)
Return the textual content, if any, of the provided
Node . |
private void |
init()
Performs the initialization necessary to allow sorting of
faces-config documents. |
static int |
innerSort(DocumentOrderingWrapper[] documents) |
boolean |
isAfter(java.lang.String id) |
boolean |
isAfterOrdered() |
boolean |
isAfterOthers() |
boolean |
isBefore(java.lang.String id) |
boolean |
isBeforeOrdered() |
boolean |
isBeforeOthers() |
boolean |
isOrdered() |
static void |
preSort(DocumentOrderingWrapper[] documents) |
private static boolean |
search(java.lang.String[] ids,
java.lang.String id)
Simple helper method around
Arrays.binarySearch() . |
static void |
sort(DocumentOrderingWrapper[] documents)
Sort the provided array of
Document s per the requirements
of the 2.0 specification. |
static DocumentOrderingWrapper[] |
sort(DocumentOrderingWrapper[] documents,
java.util.List<java.lang.String> absoluteOrder)
Sort the provided array of
Document s per the order specified
in the List represented by absoluteOrder. |
java.lang.String |
toString() |
private static final java.util.logging.Logger LOGGER
private static java.util.Comparator<DocumentOrderingWrapper> COMPARATOR
Comparator
implementation to aid in sorting faces-config
documents.private static final int MAX_SORT_PASSED
private static final java.lang.String ORDERING
ordering
element.private static final java.lang.String BEFORE
before
element.private static final java.lang.String AFTER
after
element.private static final java.lang.String NAME
name
element.private static final java.lang.String OTHERS
others
element.private static final java.lang.String OTHERS_KEY
private static final int SWAP
n
is to be swapped
with n + 1
private static final int DO_NOT_SWAP
private DocumentInfo documentInfo
private java.lang.String id
private java.lang.String[] beforeIds
private java.lang.String[] afterIds
public DocumentOrderingWrapper(DocumentInfo document)
DocumentOrderingWrapper
for the specified
Document.
public DocumentInfo getDocument()
Document
public java.lang.String getDocumentId()
Document
's ID, if anypublic java.lang.String[] getBeforeIds()
Document's before IDs, if any
public java.lang.String[] getAfterIds()
Document
's after IDs, if anypublic boolean isBeforeOrdered()
true
if any before IDs are present, otherwise
false
public boolean isAfterOrdered()
true
if any after IDs are present, otherwise,
false
public boolean isOrdered()
true
if this document has any before or after IDs,
otherwise false
public boolean isBefore(java.lang.String id)
true
if this document is before the specified
id
, otherwise false
public boolean isAfter(java.lang.String id)
true
if this document is after the specified
id
, otherwise false
public boolean isAfterOthers()
true
if this document is after others, otherwise
false
public boolean isBeforeOthers()
true
if this document is before others, otherwise
false
public java.lang.String toString()
toString
in class java.lang.Object
public static DocumentOrderingWrapper[] sort(DocumentOrderingWrapper[] documents, java.util.List<java.lang.String> absoluteOrder)
Document
s per the order specified
in the List represented by absoluteOrder.documents
- Documents to sortabsoluteOrder
- the absolute order as specified in the /WEB-INF/faces-config.xmlpublic static void sort(DocumentOrderingWrapper[] documents)
Document
s per the requirements
of the 2.0 specification. Note, that this method only provides partial
ordering and not absolute ordering.public static boolean done(DocumentOrderingWrapper[] documents, java.util.LinkedList<java.lang.String> ids)
public static java.util.LinkedList<java.lang.String> getIds(DocumentOrderingWrapper[] documents)
public static int innerSort(DocumentOrderingWrapper[] documents)
private static void enhanceOrderingData(DocumentOrderingWrapper[] wrappers) throws DocumentOrderingWrapper.CircularDependencyException
private static boolean search(java.lang.String[] ids, java.lang.String id)
Arrays.binarySearch()
.ids
- an array of IDsid
- the ID to search forids
contains id
private void init()
Performs the initialization necessary to allow sorting of
faces-config
documents.
private java.lang.String getDocumentName(org.w3c.dom.Element documentElement)
private void checkDuplicates(java.lang.String[] source, java.lang.String[] searchTarget)
source
aren't present in searchTarget
.private java.util.Set<java.lang.String> extractIds(org.w3c.dom.Node n, java.lang.String nodeName)
Set
of IDs contained within the provided
Node
.private java.lang.String getNodeText(org.w3c.dom.Node node)
Node
.public static java.util.HashMap<java.lang.String,DocumentOrderingWrapper> getDocumentHashMap(DocumentOrderingWrapper[] documents)
public static void preSort(DocumentOrderingWrapper[] documents)
public static <K,V extends java.lang.Comparable<? super V>> java.util.Map<K,V> descendingByValue(java.util.Map<K,V> map)
Copyright © 2002-2013 Oracle America, Inc. All Rights Reserved.