|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.plink.PlinkProcessor
public class PlinkProcessor
Adds purple links (ala Augment from bootstrap.org) to an XHTML document (or potentially any XML, if customized). For more extensive documentation see the plink home page.
The entire document by default will be plinked. The starting and
ending locations can be specified by metadata within the document
(see startingID and endingID for details).
Copyright 2001-2007 Murray Altheim. All Rights Reserved.
See LICENSE included with distribution, or in the source code for
this file.
| Field Summary | |
|---|---|
static String |
anchorElementName
A String containing the element type name of the link anchor (or target, default 'a'). |
static String |
bodyElementName
A String containing the element type name of the document body element (default 'body'). |
protected String |
defaultDivision
A String containing a whitespace-delimited list of element type names, used as the division elements for the processor (default includes the HTML heading elements). |
protected String |
defaultEmpty
A String containing a whitespace-delimited list of element type names, known to be declared EMPTY for use by the processor. |
protected String |
defaultSignificant
A String containing a whitespace-delimited list of element type names, used as the significant elements for the processor (default includes <p>, <li>, <dt>, and <img> elements). |
protected String |
defaultWrapper
A String containing a whitespace-delimited list of element type names, used as the wrapper elements for the processor. |
static String |
dPfx
The String used as a prefix to all assigned division ID values (default is 'd'). |
protected String |
endingID
A String indicating the ID to use as a termination point for adding links. |
static String |
headElementName
A String containing the element type name of the document-level metadata container (default 'head'). |
static String |
hPfx
The String used as a prefix to all assigned (hierarchical) SSN values (default 'hid'). |
static String |
idAttrName
A String containing the attribute name used for IDs (default 'id'). |
static String |
indicatorAttrName
A String containing the attribute name used to indicate plink markup (default 'class'). |
static String |
legacyAttrName
A String containing the attribute name used for legacy linking (default 'name'). |
static String |
linkElementName
A String containing the element type name of the link used to indicate schema namespaces. |
static String |
linkHref
A String containing the attribute name used for link URI references (default 'href'). |
static String |
metaElementName
A String containing the element type name of the metadata container (default 'meta'). |
static int |
MODE_AUGMENT
Internal mode setting - augment markup. |
static int |
MODE_NOOP
Internal mode setting - no function (pass through). |
static int |
MODE_REMOVE
Internal mode setting - remove markup. |
boolean |
padSpace
|
static String |
PFX_plink
A String containing the attribute namespace prefix value for plink (default 'plink'). |
static String |
PLINK_PROP
The base URI for Plink properties (includes hash character). |
static String |
plinkEndingIdAttr
A String containing the name of the plink ending ID attribute. |
static String |
plinkRevAttr
A String containing the name of the plink revision attribute, also used to determine if a document has been plinked. |
static String |
plinkSIDCountAttr
A String containing the name of the plink SID count attribute, used to avoid reuse of SID numbers (when a document is updated, the next SID created will be this value + 1). |
static String |
plinkStartingIdAttr
A String containing the name of the plink starting ID attribute. |
static String |
plinkStylesheetAttr
A String containing the name of the plink stylesheet attribute. |
static String |
SIDcDelim
The character used as the closing delimiter of a "Worker-Assigned Statement Label" (default is ')'). |
static String |
sidIndicator
A String containing the attribute value used to indicate plink SID links (default 'plinks'). |
static String |
SIDoDelim
The character used as the opening delimiter of a "Worker-Assigned Statement Label" (default is '('). |
static String |
sPfx
The String used as a prefix to all assigned statement (ie., sequential) ID values (default 'nid'). |
static String |
ssnIndicator
A String containing the attribute value used to indicate plink SSN links (default 'plink'). |
protected String |
startingID
A String indicating the first ID to use as a starting point for adding links. |
boolean |
useNbsp
|
static String |
XMLNS_plink
A String containing the namespace indicator used to indicate plink, http://www.bootstrap.org/plink. |
| Constructor Summary | |
|---|---|
PlinkProcessor()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
deplink(Document doc)
Processes the XmlDocument xmldoc to remove all plink
markup. |
void |
generateID(Element element)
Checks for the existence of an id attribute, and if missing or empty generates and adds it to the Element element. |
HashSet |
getDeclaredEmpty()
Returns the HashSet containing the list of elements declared EMPTY, as according to a parse of the DTD or a preset. |
String |
getEndingID()
Returns the ID of the element whose presence signals the ending of plink processing, null if this has not been set. |
Document |
getIndex()
Returns the Document populated with the index of links created. |
String |
getStartingID()
Returns the ID of the element whose presence signals the beginning of plink processing, null if this has not been set. |
static int |
parseMode(String arg)
Parses the String arg for either "augment" or "remove", returning a Plink mode MODE_AUGMENT or MODE_REMOVE, throwing a PlinkException if the string is null or not recognized. |
void |
plink(Document doc)
Processes the XmlDocument xmldoc to produce a plink
markup. |
void |
registerID(String id,
Element element)
Registers the value id for the Element element with the plink registry. |
void |
registerIDs(Document doc)
Obtains the existing ID list when in validation mode (since the processor only knows which attributes are IDs in this mode), otherwise scans all of Elements in the Document (assuming this is XHTML) for id attributes to obtain this list. |
void |
removePlink(Element element,
String indicator)
Removes the plink-created link direct children of Element element having an indicator attribute value starting with the String indicator (whose default is "plink"). |
void |
setBodyElementName(String name)
Sets the element type name expected to be the document body element. |
void |
setDivisionElements(String s)
Provided an or-group String of element types s (eg., 'h1|h2|h3'), sets them as the set of division elements to be used by this processor. |
void |
setEmptyElements(String s)
Provided an or-group String of element types s (eg., 'br|img|meta|link'), sets them as the set of empty elements (ie., those declared EMPTY) to be used by this processor. |
void |
setEndingID(String id)
Sets the ID of the element whose presence signals the ending of plink processing. |
void |
setHeadElementName(String name)
Sets the element type name expected to be the document head element. |
void |
setIDAttributeName(String name)
Sets the attribute name of the IDs created by the processor. |
void |
setIndex(String documentName)
Creates a new indexDocument as the Document to be populated with the index of links created, with name documentName. |
void |
setIndicatorAttributeName(String name)
Sets the attribute name of the plink indicator attributes created by the processor. |
void |
setLinkName(String name,
String attrName)
Sets the element type and attribute names of the links created by the processor. |
void |
setSignificantElements(String s)
Provided an or-group String of element types s (eg., 'p|blockquote|li'), sets them as the set of significant elements to be used by this processor. |
void |
setStartingID(String id)
Sets the ID of the element whose presence signals the beginning of plink processing. |
void |
setWrapperElements(String s)
Provided an or-group String of element types s (eg., 'div|ul|ol|dl'), sets them as the set of wrapper elements to be used by this processor. |
void |
updatePreviousPlink(Document doc)
After it has been determined that the provided document has already been processed, this will update the plink revision date attribute (defaulting to the contents of an plink.revision-date attribute on <meta> element). |
static boolean |
wasPlinked(Document doc)
Returns true if the provided document has already been processed, e.g., to avoid double-processing. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PLINK_PROP
public static final int MODE_NOOP
public static final int MODE_AUGMENT
public static final int MODE_REMOVE
public static String XMLNS_plink
public static String PFX_plink
public static String plinkRevAttr
public static String plinkSIDCountAttr
public static String plinkStylesheetAttr
public static String ssnIndicator
public static String sidIndicator
public static String hPfx
public static String dPfx
public static String sPfx
public static String SIDoDelim
public static String SIDcDelim
public static String linkElementName
public static String anchorElementName
public static String linkHref
public static String idAttrName
public static String legacyAttrName
public static String indicatorAttrName
public static String headElementName
public static String metaElementName
public static String bodyElementName
public static String plinkStartingIdAttr
protected String startingID
public static String plinkEndingIdAttr
protected String endingID
protected String defaultDivision
protected String defaultSignificant
protected String defaultWrapper
protected String defaultEmpty
public boolean useNbsp
public boolean padSpace
| Constructor Detail |
|---|
public PlinkProcessor()
throws ProcessException
ProcessException| Method Detail |
|---|
public void plink(Document doc)
throws PlinkException
xmldoc to produce a plink
markup. This is generally used only for XHTML source documents.
The mode is set to PlinkProcessor.MODE_AUGMENT.
PlinkException
public void deplink(Document doc)
throws PlinkException
xmldoc to remove all plink
markup. This is generally used only for XHTML source documents.
The mode is set to PlinkProcessor.MODE_REMOVE.
PlinkException
public static int parseMode(String arg)
throws PlinkException
PlinkException
public void setDivisionElements(String s)
throws PlinkException
PlinkException
public void setSignificantElements(String s)
throws PlinkException
Note that this method checks to be sure that none of the elements considered significant are also division elements, so this method should always be called after setDivisionElements.
PlinkException
public void setWrapperElements(String s)
throws PlinkException
Note that this method checks to be sure that none of the elements considered wrapper are also significant or division elements, so this method should always be called after setDivisionElements. Note that these are not checked against the significant set.
PlinkException
public void setEmptyElements(String s)
throws PlinkException
PlinkExceptionpublic HashSet getDeclaredEmpty()
public void setStartingID(String id)
throws PlinkException
PlinkExceptionpublic String getStartingID()
public void setEndingID(String id)
throws PlinkException
PlinkExceptionpublic String getEndingID()
public void setLinkName(String name,
String attrName)
throws PlinkException
PlinkException
public void setIDAttributeName(String name)
throws PlinkException
PlinkException
public void setIndicatorAttributeName(String name)
throws PlinkException
PlinkException
public void setBodyElementName(String name)
throws PlinkException
PlinkException
public void setHeadElementName(String name)
throws PlinkException
PlinkException
public void setIndex(String documentName)
throws PlinkException
PlinkExceptionpublic Document getIndex()
public void registerIDs(Document doc)
Note: the current implementation works only for XHTML, using the 'id' attribute value as an ID. Previous implementations relied upon Xerces' DocumentImpl, which provided access to the Document IDs.
public void registerID(String id,
Element element)
public void generateID(Element element)
public static boolean wasPlinked(Document doc)
public void updatePreviousPlink(Document doc)
throws PlinkException
PlinkException
public void removePlink(Element element,
String indicator)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||