org.jplate.foundation.source.impl.defaults
Class DefaultSource<S>

java.lang.Object
  extended by org.jplate.foundation.source.impl.defaults.DefaultSource<S>
Type Parameters:
S - The real "source" (for instance, file, URL, etc).
All Implemented Interfaces:
java.io.Serializable, FormattableIfc, SourceIfc<S>

public final class DefaultSource<S>
extends java.lang.Object
implements SourceIfc<S>

Default implementation of SourceIfc.

The following are some examples on how to use this class:

Please note: Instances can also be created using DefaultSourceFactory. Doing so allows a greater degree of flexibility by not coupling code to this class.

Modifications:
   $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $
   $Revision: 479 $
   $Author: sfloess $
   $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/foundation/source/impl/defaults/DefaultSource.java $
    

See Also:
Serialized Form

Field Summary
private  int _column
          This is the column where something exists in source.
private  int _hashCode
          The hash code.
private  int _line
          This is the line where something exists in source.
private  org.apache.commons.logging.Log _log
          Used for logging.
private  S _source
          This is the source from whence something exists.
private static long serialVersionUID
          For serialization purposes.
static java.lang.String SOURCE_IS_NULL_MSG
          Denotes that source is null.
 
Fields inherited from interface org.jplate.foundation.source.SourceIfc
UNKNOWN_COLUMN, UNKNOWN_LINE
 
Constructor Summary
private DefaultSource()
          Default constructor not allowed.
  DefaultSource(S source, int line, int column)
          This constructor sets-up the source, line an column where something exists.
 
Method Summary
 boolean equals(java.lang.Object object)
          Determines object equality.
 int getColumn()
          Returns the column number in SourceIfc.getSource().
 int getLine()
          Returns the line number in SourceIfc.getSource().
 S getSource()
          Returns the actual "source." For instance if a source is defined by a File, the file represents the actual source.
 int hashCode()
          
 java.lang.String toString()
          This method returns a String representation of self.
 java.lang.String toString(java.lang.String prepend)
          Returns a string representation of self prepending prepend to each line.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SOURCE_IS_NULL_MSG

public static final java.lang.String SOURCE_IS_NULL_MSG
Denotes that source is null.

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
For serialization purposes.

See Also:
Constant Field Values

_log

private final transient org.apache.commons.logging.Log _log
Used for logging.


_source

private final S _source
This is the source from whence something exists.


_line

private final int _line
This is the line where something exists in source.


_column

private final int _column
This is the column where something exists in source.


_hashCode

private final int _hashCode
The hash code.

Constructor Detail

DefaultSource

public DefaultSource(S source,
                     int line,
                     int column)
This constructor sets-up the source, line an column where something exists.

Parameters:
source - The place from which something exists or originates (for instance a file).
line - The line number in source.
column - The column number in source.

DefaultSource

private DefaultSource()
Default constructor not allowed.

Throws:
java.lang.UnsupportedOperationException - if this constructor is called.
Method Detail

toString

public java.lang.String toString()
This method returns a String representation of self.

Overrides:
toString in class java.lang.Object
Returns:
A String representation of self.

toString

public java.lang.String toString(java.lang.String prepend)
Returns a string representation of self prepending prepend to each line.

Specified by:
toString in interface FormattableIfc
Parameters:
prepend - The text to prepend to each line as defined in the return value.
Returns:
A string representation of self who has prepend prepended to each line.

getSource

public S getSource()
Returns the actual "source." For instance if a source is defined by a File, the file represents the actual source.

Specified by:
getSource in interface SourceIfc<S>
Returns:
The source.

getLine

public int getLine()
Returns the line number in SourceIfc.getSource().

Specified by:
getLine in interface SourceIfc<S>
Returns:
The line number.

getColumn

public int getColumn()
Returns the column number in SourceIfc.getSource().

Specified by:
getColumn in interface SourceIfc<S>
Returns:
The column number.

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Determines object equality.

Overrides:
equals in class java.lang.Object
Parameters:
object - to compare.
Returns:
true if self is equal to object.