Top Description Inners Fields Constructors Methods
uk.ac.ed.ph.snuggletex

public final Class SnuggleInput

extends Object
Class Inheritance
Imports
uk.ac.ed.ph.snuggletex.internal.util.ConstraintUtilities, java.io.File, .InputStream, .Reader, java.net.URI

Simple container for an input into SnuggleTeX.
Author
David McKain
Version
$Revision$

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
SnuggleInput.InputType

Enumerates the various types of inputs we support.

Field Summary

Modifier and TypeField and Description
private String
encoding

The encoding for this input, used for InputType#FILE and InputType#INPUT_STREAM.

private final File
private String
identifier

An "identifier" for this input.

private final InputStream
private final Reader
private final String
private String
private final SnuggleInput.InputType
type

The "type" of input encapsulated by an instance of this class.

private URI
uri

An (optional) URI for this input.

Constructor Summary

AccessConstructor and Description
public
SnuggleInput(final String string)

public
SnuggleInput(final String string, final String identifier)

public
SnuggleInput(final File file)

public
SnuggleInput(final File file, final String identifier)

public
SnuggleInput(final File file, final String identifier, String encoding)

public
SnuggleInput(final InputStream inputStream)

public
SnuggleInput(final InputStream inputStream, final String identifier)

public
SnuggleInput(final InputStream inputStream, final String identifier, final String encoding)

public
SnuggleInput(final Reader reader)

public
SnuggleInput(final Reader reader, final String identifier)

private
SnuggleInput(final SnuggleInput.InputType type, final String string, final File file, final InputStream inputStream, final Reader reader, final String identifier, final String encoding)

Method Summary

Modifier and TypeMethod and Description
private String
public String
public File
getFile()

Returns the File that provided this input if type is InputType#FILE, null otherwise.

public String
getIdentifier()

Returns the "identifier" for this input.

public InputStream
getInputStream()

Returns the InputStream that provided this input if type is InputType#INPUT_STREAM, null otherwise.

public Reader
getReader()

Returns the Reader that provided this input if type is InputType#READER, null otherwise.

public String
getString()

Returns the String that provided this input if type is InputType#STRING, null otherwise.

public SnuggleInput.InputType
getType()

Returns the "type" of input, represented by an instance of the InputType enumeration.

public URI
getURI()

Returns an (optional) URI for this input.

public void
setEncoding(String encoding)

public void
setIdentifier(String
new identifier, which may be null.
identifier
)

Sets the "identifier" for this input.

public void
setURI(URI
URI for this input, which may be null.
uri
)

Sets a URI for this input.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

encodingback to summary
private String encoding

The encoding for this input, used for InputType#FILE and InputType#INPUT_STREAM. If null, we use the platform default encoding.

fileback to summary
private final File file
identifierback to summary
private String identifier

An "identifier" for this input. This is used when formulating error messages. Clients can use as they require - e.g. as a kind of System ID, URL or File name.

This must not be null.

inputStreamback to summary
private final InputStream inputStream
readerback to summary
private final Reader reader
stringback to summary
private final String string
stringRepresentationback to summary
private String stringRepresentation
typeback to summary
private final SnuggleInput.InputType type

The "type" of input encapsulated by an instance of this class.

uriback to summary
private URI uri

An (optional) URI for this input. If provided, this can be used to help resolve links to other Resources.

Constructor Detail

SnuggleInputback to summary
public SnuggleInput(final String string)
SnuggleInputback to summary
public SnuggleInput(final String string, final String identifier)
SnuggleInputback to summary
public SnuggleInput(final File file)
SnuggleInputback to summary
public SnuggleInput(final File file, final String identifier)
SnuggleInputback to summary
public SnuggleInput(final File file, final String identifier, String encoding)
SnuggleInputback to summary
public SnuggleInput(final InputStream inputStream)
SnuggleInputback to summary
public SnuggleInput(final InputStream inputStream, final String identifier)
SnuggleInputback to summary
public SnuggleInput(final InputStream inputStream, final String identifier, final String encoding)
SnuggleInputback to summary
public SnuggleInput(final Reader reader)
SnuggleInputback to summary
public SnuggleInput(final Reader reader, final String identifier)
SnuggleInputback to summary
private SnuggleInput(final SnuggleInput.InputType type, final String string, final File file, final InputStream inputStream, final Reader reader, final String identifier, final String encoding)

Method Detail

buildStringRepresentationback to summary
private String buildStringRepresentation()
getEncodingback to summary
public String getEncoding()
getFileback to summary
public File getFile()

Returns the File that provided this input if type is InputType#FILE, null otherwise.

getIdentifierback to summary
public String getIdentifier()

Returns the "identifier" for this input. This is used when formulating error messages. You can use as you require - e.g. as a kind of System ID, URL or File name.

getInputStreamback to summary
public InputStream getInputStream()

Returns the InputStream that provided this input if type is InputType#INPUT_STREAM, null otherwise.

getReaderback to summary
public Reader getReader()

Returns the Reader that provided this input if type is InputType#READER, null otherwise.

getStringback to summary
public String getString()

Returns the String that provided this input if type is InputType#STRING, null otherwise.

getTypeback to summary
public SnuggleInput.InputType getType()

Returns the "type" of input, represented by an instance of the InputType enumeration.

getURIback to summary
public URI getURI()

Returns an (optional) URI for this input. If provided, this can be used to help resolve links to other SnuggleInputs.

setEncodingback to summary
public void setEncoding(String encoding)
setIdentifierback to summary
public void setIdentifier(String identifier)

Sets the "identifier" for this input. This is used when formulating error messages. You can use as you require - e.g. as a kind of System ID, URL or File name.

Parameters
identifier:String

new identifier, which may be null.

setURIback to summary
public void setURI(URI uri)

Sets a URI for this input. If provided, this can be used to help resolve links to other SnuggleInputs.

Parameters
uri:URI

URI for this input, which may be null.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
uk.ac.ed.ph.snuggletex back to summary

public final Enum SnuggleInput.InputType

extends Enum<SnuggleInput.InputType>
Class Inheritance

Enumerates the various types of inputs we support.

Field Summary

Modifier and TypeField and Description
public static final SnuggleInput.InputType
FILE

Input is read from a File using either a specified encoding or the platform default encoding

public static final SnuggleInput.InputType
INPUT_STREAM

Input is read from an InputStream using either a specified encoding or the platform default encoding

public static final SnuggleInput.InputType
READER

Input is read from a Reader

public static final SnuggleInput.InputType
STRING

Input is read from a String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SnuggleInput.InputType
public static SnuggleInput.InputType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FILEback to summary
public static final SnuggleInput.InputType FILE

Input is read from a File using either a specified encoding or the platform default encoding

INPUT_STREAMback to summary
public static final SnuggleInput.InputType INPUT_STREAM

Input is read from an InputStream using either a specified encoding or the platform default encoding

READERback to summary
public static final SnuggleInput.InputType READER

Input is read from a Reader

STRINGback to summary
public static final SnuggleInput.InputType STRING

Input is read from a String

Constructor Detail

InputTypeback to summary
private InputType()

Method Detail

valueOfback to summary
public static SnuggleInput.InputType valueOf(String name)
valuesback to summary
public static SnuggleInput.InputType[] values()