org.erights.e.meta.java.net
Class URLSugar

java.lang.Object
  |
  +--org.erights.e.meta.java.net.URLSugar

public class URLSugar
extends Object

Untamed: A sweetener defining extra messages that may be e-sent to a URL.

Makes a URL act as if it implements org.erights.e.elib.serial.Loader.

Note that a URL of the form <protocol:path> grants access only to the resource named "path" starting with that protocol handler. By contrast, a URL of the form <protocol:path/> grants access to all resources whose names, starting at that protocol handler, begin with "path/". For example, <http://www.erights.org> evaluates to a URL which grants access to the erights.org home page, whereas <http://www.erights.org/> grants access to the whole website.

Note that the fileURL__uriGetter returns a URL, which therefore plays by the above rules, but that the file__uriGetter returns a File which doesn't. A File always allows prefixing separated by "/" but disallowing "..".


Constructor Summary
private URLSugar()
          prevent instantiation
 
Method Summary
static void __printOn(URL self, TextWriter out)
          Enabled: E URIs have angle brackets around them
static URL get(URL self, String suffix)
          Enabled: "implements" org.erights.e.elib.serial.Loader#get, but only if the body of this URL ends in a "/".
static String getBody(URL self)
          Enabled: Everything after 'protocol:'.
static BigInteger getCryptoHash(URL self)
          Enabled: A SHA hash of the binary content of the URL's contents.
static String getText(URL self)
          Enabled: Gets the contents of the url as String, normalizing newlines into '\n's.
static Twine getTwine(URL self)
          Enabled: Gets the contents of the url as Twine (a text string that remembers where it came from), normalizing newlines into '\n's.
static void iterate(URL self, AssocFunc func)
          Enabled: Enumerates lineNumber => String (text line) associations.
static void iterate(URL self, AssocFunc func, boolean isLocated)
          Enabled: Enumerates lineNumber => String/Twine (text line) associations.
static Object[] optUncall(URL self, Object obj)
          Enabled: "implements" org.erights.e.elib.serial.Loader#optUncall, but only if the body of this URL ends in a "/".
static BufferedReader textReader(URL self)
          Enabled: Open 'self' for reading text, decoding UTF-8 and turning platform newlines into '\n's
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLSugar

private URLSugar()
prevent instantiation

Method Detail

textReader

public static BufferedReader textReader(URL self)
                                 throws IOException
Enabled: Open 'self' for reading text, decoding UTF-8 and turning platform newlines into '\n's

IOException

iterate

public static void iterate(URL self,
                           AssocFunc func)
                    throws IOException
Enabled: Enumerates lineNumber => String (text line) associations.

Each text line ends with a "\n". isLocated defaults to false.

IOException

iterate

public static void iterate(URL self,
                           AssocFunc func,
                           boolean isLocated)
                    throws IOException
Enabled: Enumerates lineNumber => String/Twine (text line) associations.

Each text line ends with a "\n".

IOException

getText

public static String getText(URL self)
                      throws IOException
Enabled: Gets the contents of the url as String, normalizing newlines into '\n's.

IOException

getTwine

public static Twine getTwine(URL self)
                      throws IOException
Enabled: Gets the contents of the url as Twine (a text string that remembers where it came from), normalizing newlines into '\n's.

IOException

getCryptoHash

public static BigInteger getCryptoHash(URL self)
                                throws NoSuchAlgorithmException,
                                       IOException
Enabled: A SHA hash of the binary content of the URL's contents.

NoSuchAlgorithmException
IOException

getBody

public static String getBody(URL self)
Enabled: Everything after 'protocol:'.

Returns:

get

public static URL get(URL self,
                      String suffix)
Enabled: "implements" org.erights.e.elib.serial.Loader#get, but only if the body of this URL ends in a "/".

Parameters:
self -
suffix -
Returns:

optUncall

public static Object[] optUncall(URL self,
                                 Object obj)
Enabled: "implements" org.erights.e.elib.serial.Loader#optUncall, but only if the body of this URL ends in a "/".

Parameters:
self -
obj -
Returns:

__printOn

public static void __printOn(URL self,
                             TextWriter out)
                      throws IOException
Enabled: E URIs have angle brackets around them

IOException


comments?