|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xpn.xwiki.wysiwyg.client.util.ResourceName
public class ResourceName
Stores a resource reference: the wiki, space, page and attached file name, if it's the case. It allows parsing from
and serializing to a string, in a org.xwiki.bridge.DocumentName form, i.e. wiki:Space.Page@attachment
. Note: As opposed to org.xwiki.bridge.DocumentName, this class is designed to also parse and process
relative references, such as attachment.png, or Page@filename@attachment.png, in which case
the missing values will be set to empty. Thus, relative references to resources can be stored and processed (@see
resolveRelativeTo(ResourceName)). However, the assumption that if a reference is relative then its specified
values are continuous (cannot have wiki specified, space missing and page specified).
FIXME: this logic should NOT be duplicated on the client, but since it's needed in frequent enough situations
(resolving relative links, resolving an attachment location: current page or another page), it's not worth making a
call to the server just to have such a string parsed or serialized.
TODO: should do most of the parsing on the server and send already modeled data to the client so that no parsing
whatsoever is needed on the client any longer.
| Constructor Summary | |
|---|---|
ResourceName()
Default constructor. |
|
ResourceName(java.lang.String serialized,
boolean asFile)
Builds a resource from the passed string representation, interpreted as a file or not, as specified by the asFile parameter. |
|
ResourceName(java.lang.String wiki,
java.lang.String space,
java.lang.String page,
java.lang.String file)
Builds a resource from the passed wiki, space, page and file. |
|
| Method Summary | |
|---|---|
void |
clear()
Clears this resource name, i.e. |
boolean |
equals(java.lang.Object obj)
|
void |
fromString(java.lang.String reference,
boolean asFile)
Parses the passed string as a string reference to this resource (i.e. |
java.lang.String |
getFile()
|
java.lang.String |
getPage()
|
ResourceName |
getRelativeTo(ResourceName resource)
Returns minimal representation of the current resource relative to the passed resource. |
java.lang.String |
getSpace()
|
java.lang.String |
getWiki()
|
int |
hashCode()
|
boolean |
matchesUpToPage(ResourceName resource)
Compares this resource with the passed resource to check if the values for the components match up to the page component, inclusive. |
ResourceName |
resolveRelativeTo(ResourceName resource)
Resolves the current resource relative to the passed resource. |
void |
setFile(java.lang.String file)
|
void |
setPage(java.lang.String page)
|
void |
setSpace(java.lang.String space)
|
void |
setWiki(java.lang.String wiki)
|
java.lang.String |
toString()
Creates the String representation of the resource, in the form wiki:Space.Page@file. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ResourceName()
public ResourceName(java.lang.String wiki,
java.lang.String space,
java.lang.String page,
java.lang.String file)
wiki - the wiki to build the resource forspace - the space to build the resource forpage - the page to build the resource forfile - the file to build the resource for
public ResourceName(java.lang.String serialized,
boolean asFile)
asFile parameter.
serialized - the serialized form of the resource referenceasFile - true if the serialized form should be interpreted as a file, false otherwise.| Method Detail |
|---|
public java.lang.String getWiki()
public void setWiki(java.lang.String wiki)
wiki - the wiki to setpublic java.lang.String getSpace()
public void setSpace(java.lang.String space)
space - the space to setpublic java.lang.String getPage()
public void setPage(java.lang.String page)
page - the page to setpublic java.lang.String getFile()
public void setFile(java.lang.String file)
file - the file to setpublic void clear()
public void fromString(java.lang.String reference,
boolean asFile)
wiki:Space.Page@attachment) and stores it in the current object.
reference - the string form of a resource reference, wiki:Space.Page@attachmentasFile - the passed reference should be parsed as a reference to an attached fileresolveRelativeTo(ResourceName)public ResourceName resolveRelativeTo(ResourceName resource)
resource - the resource to resolve relative to
public ResourceName getRelativeTo(ResourceName resource)
xwiki:Main.RecentChanges relative to xwiki:Main.WebHome will be RecentChanges; xwiki:XWiki.ClassSheet relative to xwiki:Main.WebHome will be XWiki.ClassSheet. This resource is
considered to be either fully specified, either relative to resource, so that any missing components are
considered to be the components from resource.
resource - the resource to which the relative resource is to be built
public java.lang.String toString()
wiki:Space.Page@file.
toString in class java.lang.ObjectfromString(String, boolean)public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean matchesUpToPage(ResourceName resource)
resource - the resource to compare this resource to
true if this resource matches up to the page component (inclusive) (if the resource referred by
this ResourceName is in the same page with the passed resource), or false otherwise
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||