TopoWeb Commons API

org.topoweb.net
Class OriTranslator

java.lang.Object
  |
  +--org.topoweb.net.OriTranslator

public class OriTranslator
extends java.lang.Object

Translates some standard URIs to Ori instances and viceversa. The following relation is supposed to hold:
For any OriTranslator trans and any Ori ori, the statement

      ori.equals(trans.toOri(trans.toUri(ori)))
 
either evaluates true or throws an IllegalArgumentException.

Author:
Babak Farhang

Nested Class Summary
static class OriTranslator.HierarchicalSchemeHandler
          Translates hierarchical URIs to Oris, and viceversa.
static class OriTranslator.MailtoSchemeHandler
          Translates mailto URLs to Oris, and viceversa.
static class OriTranslator.NewsSchemeHandler
          Translates news URLs to Oris, and viceversa.
static class OriTranslator.SchemeHandler
          ORI / URI translator that handles a specific URI scheme.
 
Constructor Summary
OriTranslator()
           
 
Method Summary
protected  OriTranslator.SchemeHandler getSchemeHandler(java.lang.String scheme)
          Returns the scheme handler for the given scheme.
 Ori toOri(java.net.URI uri)
          Converts and returns the given URI as an Ori instance.
 Ori toOri(java.net.URI uri, java.lang.StringBuffer work)
          Converts and returns the given URI as an Ori instance.
 java.net.URI toUri(Ori ori)
          Converts and returns the given Ori as a URI instance.
 java.net.URI toUri(Ori ori, java.lang.StringBuffer work)
          Converts and returns the given Ori as a URI instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OriTranslator

public OriTranslator()
Method Detail

toOri

public Ori toOri(java.net.URI uri)
          throws java.lang.IllegalArgumentException
Converts and returns the given URI as an Ori instance.

Parameters:
uri - the URI
Returns:
the ORI translation
Throws:
java.lang.IllegalArgumentException - if the URI scheme is not handled by this translator; if uri is relative

toOri

public Ori toOri(java.net.URI uri,
                 java.lang.StringBuffer work)
          throws java.lang.IllegalArgumentException
Converts and returns the given URI as an Ori instance.

Parameters:
uri - the URI
work - the work buffer (may be null)
Returns:
the ORI translation
Throws:
java.lang.IllegalArgumentException - if the URI scheme is not handled by this translator; if uri is relative

toUri

public java.net.URI toUri(Ori ori)
                   throws java.lang.IllegalArgumentException
Converts and returns the given Ori as a URI instance.

Parameters:
ori - the Ori
Returns:
the URI translation
Throws:
java.lang.IllegalArgumentException - if ori's scheme is not handled by this translator; if uri is relative

toUri

public java.net.URI toUri(Ori ori,
                          java.lang.StringBuffer work)
                   throws java.lang.IllegalArgumentException
Converts and returns the given Ori as a URI instance.

Parameters:
ori - the Ori
work - the work buffer (may be null)
Returns:
the URI translation
Throws:
java.lang.IllegalArgumentException - if ori's scheme is not handled by this translator; if uri is relative

getSchemeHandler

protected OriTranslator.SchemeHandler getSchemeHandler(java.lang.String scheme)
Returns the scheme handler for the given scheme. The string representation of a URI's and Ori's scheme is taken to be the same.

Parameters:
scheme - the scheme
Returns:
the scheme handler

TopoWeb Commons API

Copyright (C) 2002 Babak Farhang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.