|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.activemath.omdocjdom.ID
public class ID
This implements the ID interface in the simplest manner.
As the whole subject of object oriented IDs in OMdoc
is rather unprecise, the implementation is perfectly candid
and based on the following convention for a globally unique URI:
mbase://collection/theory/namembase://collection/name mbase://collection/theory/
| Nested Class Summary | |
|---|---|
protected static class |
ID.PoolableRE
|
| Field Summary | |
|---|---|
String |
collection
|
static org.apache.regexp.REProgram |
fullURIPatternProgram
This initailizes the pattern |
String |
mid
|
String |
name
|
protected static SimplePool |
rePool
|
String |
theory
|
| Constructor Summary | |
|---|---|
ID(ID baseID,
String path)
Reads the ID using the pattern and the baseID to make a relative ID. |
|
ID(ID baseID,
String theory,
String name)
Tries to return the ID of the node with the same collection but with given theory and name. |
|
ID(String absolutePath)
Makes an ID by extracting the informations from the string given which is supposed to be a properly formatted mbase URI obeying the patther mbase://collection/theory/name. |
|
ID(String baseCollection,
String collectionAbsolute)
|
|
ID(String collection,
String theory,
String name,
String mid)
Plain constructor acting as a record constructor (stores the fields, period). |
|
| Method Summary | |
|---|---|
Object |
clone()
|
boolean |
equals(ID id)
A central piece in the storage facilities of IDs. |
boolean |
equals(Object id)
Dispatches to equals(ID). |
String |
expressShortestRef(ID toID)
|
static String |
expressShortestRef(OJElement from,
OJElement to)
Computes the shortest-possible value for a reference contained as an attribute or a child's attribute of the from element to the to element. |
String |
getCollection()
The first of the fields of this record. |
String |
getFullyQualifiedID()
Returns mbase://collection/theoryID/name or, if the theory is null, mbase://collection/name:mid |
String |
getMID()
The fourth of the fields of this record. |
String |
getName()
The third of the fields of this record. |
String |
getRelativePart()
Returns the part after the collection, that is theory/name or /name |
String |
getTheory()
The second of the fields of this record. |
ID |
getTheoryID()
Returns the ID made of the same collection and theory, or null if no theory exists. |
int |
hashCode()
Takes the or of all hashcodes. |
IID |
internStrings()
Computes an equal id with all components interned string. |
boolean |
isAbsolute()
Evaluates wether the id thus built is absolute, that is, has non-null collection and (name or theory). |
static ID |
makeAbsoluteID(String simply)
This supports "mbase://" or "http://" |
static ID |
makeCollectionRelativeID(String collectionName,
String path)
Splits the path given with slahes, if any, then creates a link that follows the policy given under makeRelativeID(org.activemath.omdocjdom.ID, java.lang.String) but with the given collection. |
static org.apache.regexp.RE |
makePattern()
Prepares a ID.PoolableRE regular expression object to parse a string URL. |
static ID |
makeRelativeID(ID base,
String path)
Produces an ID that is relative to the base. |
String |
toString()
Returns a representative (long) text describing all the fields, including its null fields. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final String collection
public final String theory
public final String name
public final String mid
public static org.apache.regexp.REProgram fullURIPatternProgram
protected static SimplePool rePool
| Constructor Detail |
|---|
public ID(ID baseID,
String path)
IllegalArgumentException - if the syntax is not correct though not all checks are made !
public ID(ID baseID,
String theory,
String name)
baseID - Can't be nulltheory - may be null in which case the reference is understood to be in the no-theory worldname - can't be null (as part of the normal specification of IDs).public ID(String absolutePath)
mbase://collection/theory/name.
It does so using the regexp pattern ((mbase://)([^/]+)/)?(/?([^/]+)/)?([^/]+)
and extracts corresponding informations from the parenthesized contents numbered 3, 5 and 6.
IllegalArgumentException - if the syntax is not correct (though not all checks are made).
public ID(String baseCollection,
String collectionAbsolute)
public ID(String collection,
String theory,
String name,
String mid)
IllegalArgumentException
if all three last parameters are null.
| Method Detail |
|---|
public static org.apache.regexp.RE makePattern()
ID.PoolableRE regular expression object to parse a string URL.
Is only used by constructors who need it without keeping this in store.
The REProgram which is kernel of such regular expressions is stored
in fullURIPatternProgram, a static variable, and is re-used when it is not null.
The regular expression has the syntax ((mbase://)([^/]+)/)?(/?([^/]+)/)?([^/:]+)?(:(.+))*
which should match all possible ID string representations.
This method is made public mostly for debugging purposes. If having these objects is expensive, one should consier a more factory way with some pooling of RE's.
We need to move to OMDoc 1.1 references:
blop to go to element blop in the same theorycollectionURI#byctx(name@theory) [uri]#mythydocumentURI# to reference a whole OMDoc element at the root of the document hereby referred
(shouldn't be tolerated!)name@theory as an abberviation of #byctx(name@theory)
public static ID makeAbsoluteID(String simply)
public IID internStrings()
public static ID makeRelativeID(ID base,
String path)
null mid.
public static ID makeCollectionRelativeID(String collectionName,
String path)
makeRelativeID(org.activemath.omdocjdom.ID, java.lang.String) but with the given collection.
This method is a handcrafted parsing method... it may be fragile.
public String getFullyQualifiedID()
null, mbase://collection/name:mid
public String toString()
null fields.
toString in class Objectpublic String getRelativePart()
public String getCollection()
public String getTheory()
public ID getTheoryID()
public String getName()
public String getMID()
public boolean isAbsolute()
public static String expressShortestRef(OJElement from,
OJElement to)
null if there is no ID to give to the to element.public String expressShortestRef(ID toID)
public boolean equals(Object id)
equals(ID).
equals in class Objectpublic boolean equals(ID id)
null or equals using String.equals(java.lang.Object) method.
public int hashCode()
hashCode in class Objectpublic Object clone()
clone in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||