|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwxtutils.accessutils
accessutils has only static methods and serve as a library for utilities that loads and saves data, calculate addresses and do some parsing.
Constructor Summary | |
accessutils()
Creates a new instance of accessutils |
Method Summary | |
static boolean |
appendToTextFile(java.net.URI theUri,
java.lang.String text,
long maxFileSize)
Append to a text file |
static java.net.URI |
calculateLocalUri(java.net.URI theUri,
java.net.URI thePageUri)
Find where theUri should be backed up. |
static org.w3c.dom.DocumentFragment |
expandFragmentFromAnyNode(org.w3c.dom.Node n)
Makes a DocumentFragment from the given node. |
static java.lang.String |
expandStringWithProperty(java.lang.String theValue,
java.util.HashMap props)
Identifies a _wx_property in a string and expands it. |
static boolean |
fetchByteFile(java.net.URI fromUri,
java.net.URI toUri)
Copy a file from one URI to an other, which must be a file |
static java.lang.String |
findEncoding(java.lang.String S,
java.lang.String defaultEncoding)
Investigate a string and find encoding This is not a full-blown version. |
static java.lang.String |
getAllText(org.w3c.dom.Node n)
Get content of all text-elements which are direct children of a node |
static java.lang.String |
getAllTextAndCdata(org.w3c.dom.Node n)
Get content of all text-elements and CDATA-elements which are direct children of a node |
static java.net.URI |
getCorrectedLink(java.lang.String path,
java.net.URI baseUri,
java.util.Vector altUris)
Produce an relative URI to a given anchor from a relative path to an other anchor. |
static java.net.URI |
getExistingAbsLink(java.lang.String path,
java.util.Vector altUris)
Try to find an existing absolute URI from a relative path and alternative (absolute) anchors |
static long |
getModificationTime(java.net.URI theUri)
Find out when a file identified by an URI was last modified |
static java.lang.String |
getNormalizedFilePath(java.lang.String path)
Identify absolute paths and correct paths to neutral form. |
static java.util.Vector |
getPIs(org.w3c.dom.Node n)
Find a list of all Processing Instructions below a node in a tree |
static java.util.Vector |
getPIs(org.w3c.dom.Node n,
java.lang.String target)
Produce a list of all Processing Instructions with a certain name below a node in a tree |
static java.net.URI |
getRelativeUri(java.net.URI newBase,
java.net.URI theUri)
Find reference from one URI to another |
static java.lang.String |
getTextFile(java.net.URI uri)
Read a String from an URI Throws IOException , URISyntaxException |
static java.lang.String |
getTextFileFromPath(java.lang.String path)
Read a String from a path Throws IOException , URISyntaxException |
static boolean |
isCommonAttribute(java.lang.String att,
java.lang.String common)
Find out if a string is starting with common Allow any number of ../ before common, but not common as other part of the string is identified |
static boolean |
legalDating(java.lang.String firstdate,
java.lang.String lastdate)
Control dates |
static boolean |
makeCatalog(java.net.URI theUri)
Check if a file exists, and make necessary catalogpath if it does not |
static org.w3c.dom.DocumentFragment |
makeDate(org.w3c.dom.Document doc,
command cmd)
Produce a Documentfragment with a single textnode telling the date |
static org.w3c.dom.DocumentFragment |
makeFragement(org.w3c.dom.Node n)
Makes a DocumentFragment with all the children of the given node, or the node itself if it is has no children. |
static boolean |
makeResource(java.net.URI theUri)
Establish a file |
static org.w3c.dom.DocumentFragment |
makeStamp(org.w3c.dom.Document doc,
command cmd)
Produce a Documentfragment with a referene, a-Element, to WXT as its only child. |
static org.w3c.dom.DocumentFragment |
makeTime(org.w3c.dom.Document doc,
command cmd)
Produce a Documentfragment with a single textnode telling the time |
static java.util.HashMap |
parseNameValues(java.lang.String data,
char quoteMark)
Parse for name-value pairs in a string and return them in a HashMap Expected input variants: (name1='value1',name2='value2') name1='value1',name2='value2' name1='value1' name2='value2' name1="value1" name2="value2" |
static boolean |
resourceExists(java.net.URI theUri)
Find out if a certain URI really address an existing resource, file or webpage |
static boolean |
saveTextFile(java.net.URI theUri,
java.lang.String text)
Save a text file |
static void |
setToDay()
Set the day to today |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public accessutils()
Method Detail |
public static void setToDay()
public static java.lang.String getAllText(org.w3c.dom.Node n)
n
- The node whose children are searched
public static java.lang.String getAllTextAndCdata(org.w3c.dom.Node n)
n
- The node whose children are searched
public static java.util.HashMap parseNameValues(java.lang.String data, char quoteMark)
Expected input variants:
(name1='value1',name2='value2')
name1='value1',name2='value2'
name1='value1' name2='value2'
name1="value1" name2="value2"
data
- The string to parsequoteMark
- How values are quoted: ' or "
public static java.lang.String expandStringWithProperty(java.lang.String theValue, java.util.HashMap props)
theValue
- The string to searchprops
- The candidate properties
public static java.lang.String getNormalizedFilePath(java.lang.String path)
c\:a\b\c.xxx - to - file:/c:/a/b/c.xxx
/a/b/c.xxx - to - file://a/b/c.xxx
FILE:/a/b/c.xxx - to - file://a/b/c.xxx
path
- The path to investigate
public static boolean isCommonAttribute(java.lang.String att, java.lang.String common)
Allow any number of ../ before common, but not common as other part of the string is identified
att
- The string to investigatecommon
- The name to look for
public static java.lang.String getTextFile(java.net.URI uri) throws java.io.IOException, java.net.MalformedURLException
uri
- The URI to read from
java.io.IOException
- when the text cannot be loaded
java.net.MalformedURLException
- when the URI is not wellformedpublic static java.lang.String getTextFileFromPath(java.lang.String path) throws java.io.IOException, java.net.URISyntaxException
path
- The path to read from
java.io.IOException
- when text is not loaded
java.net.URISyntaxException
- when path has bad formpublic static boolean makeCatalog(java.net.URI theUri)
theUri
- The URI for the file
public static boolean saveTextFile(java.net.URI theUri, java.lang.String text)
theUri
- The absolute URI to the filetext
- The text to write
public static boolean appendToTextFile(java.net.URI theUri, java.lang.String text, long maxFileSize)
theUri
- The absolute URI to the filetext
- The text to writemaxFileSize
- When file reach this size in bytes it is reset, -1 keeps it going forever
public static long getModificationTime(java.net.URI theUri)
theUri
- The resource we will investigate
public static java.lang.String findEncoding(java.lang.String S, java.lang.String defaultEncoding)
This is not a full-blown version. It depends on the ability to read and parse the first line in the file as an XML-heading with an encoding attribute as "normal" String.
defaultEncoding
- The encoding to use if we are not able to detect encoding in the stringS
- The string to investigate
public static boolean resourceExists(java.net.URI theUri)
theUri
- The URI we are looking for
public static boolean makeResource(java.net.URI theUri)
theUri
- The URI describing the file we want to establish
public static java.util.Vector getPIs(org.w3c.dom.Node n, java.lang.String target)
n
- The node defining the subtree we will investigatetarget
- The name of the PIs we are looking for
public static java.util.Vector getPIs(org.w3c.dom.Node n)
n
- The node defining the subtree
public static java.net.URI getRelativeUri(java.net.URI newBase, java.net.URI theUri)
newBase
- An absolute URItheUri
- An absolute URI
public static java.net.URI calculateLocalUri(java.net.URI theUri, java.net.URI thePageUri)
theUri
- The absolute address of a filethePageUri
- The absolute uri for the page that address the resource at theUri
public static org.w3c.dom.DocumentFragment makeFragement(org.w3c.dom.Node n) throws java.lang.Exception
n
- The node that defines the subtree
java.lang.Exception
- when for some reason we could not establish the fragmentpublic static org.w3c.dom.DocumentFragment expandFragmentFromAnyNode(org.w3c.dom.Node n) throws java.lang.Exception
n
- The node that defines the subtree
java.lang.Exception
- when for some reason we could not establish the fragmentpublic static org.w3c.dom.DocumentFragment makeDate(org.w3c.dom.Document doc, command cmd)
doc
- The Document that will own the elementcmd
- The command object that idenities the form we want
public static org.w3c.dom.DocumentFragment makeTime(org.w3c.dom.Document doc, command cmd)
doc
- The Document that will own the elementcmd
- The command object that idenities the form we want
public static org.w3c.dom.DocumentFragment makeStamp(org.w3c.dom.Document doc, command cmd)
doc
- The Document that will own the elementcmd
- The command object that decribes what we want
public static boolean fetchByteFile(java.net.URI fromUri, java.net.URI toUri)
fromUri
- Where to copy fromtoUri
- Where to copy to, must be file
public static java.net.URI getCorrectedLink(java.lang.String path, java.net.URI baseUri, java.util.Vector altUris)
path
- The string defining the URI we want to correctbaseUri
- The uri we will use as an anchor and relativize againstaltUris
- An array of uris we suspect may be current base
public static java.net.URI getExistingAbsLink(java.lang.String path, java.util.Vector altUris) throws java.lang.Exception
path
- The path that we will testaltUris
- The list of alternative absolute URIs
java.lang.Exception
- when no existing file can be found by any alternative or the path is misformedpublic static boolean legalDating(java.lang.String firstdate, java.lang.String lastdate) throws java.lang.NumberFormatException
firstdate
- First legal daylastdate
- Last legal day
java.lang.NumberFormatException
- when the dateformats is wrong. Should be:yyyymmdd
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |