Top Description Inners Fields Constructors Methods
com.sun.faces.facelets.el

public Class ELText

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.faces.facelets.el.ELText.ELTextComposite, com.sun.faces.facelets.el.ELText.ELTextVariable
Imports
java.io.IOException, .Writer, java.util.ArrayList, .List, com.sun.faces.el.ELUtils, com.sun.faces.util.HtmlUtils, .MessageUtils, jakarta.el.ELContext, .ELException, .ExpressionFactory, .ValueExpression, jakarta.faces.context.FacesContext, .ResponseWriter, jakarta.faces.view.Location

Handles parsing EL Strings in accordance with the EL-API Specification. The parser accepts either ${..} or #{..}.
Author
Jacob Hookom
Version
$Id$

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
protected final String

Constructor Summary

AccessConstructor and Description
public
ELText(String literal)

Method Summary

Modifier and TypeMethod and Description
public ELText

Returns:

an ELText instance
apply
(ExpressionFactory
the ExpressionFactory to use
factory
,
ELContext
the ELContext to use
ctx
)

Return an instance of this that is applicable given the ELContext and ExpressionFactory state.

private static int
findVarLength(char[] ca, int s)

public boolean

Returns:

true if the String is literal (doesn't contain #{..} or ${..})
isLiteral
()

If it's literal text

public static boolean

Returns:

true if the String is literal (doesn't contain #{..} or ${..})
isLiteral
(String
input String
in
)

Parses the passed string to determine if it's literal or not

public static ELText

Returns:

ELText instance that knows if the String was literal or not
parse
(String
String to parse
in
)

Factory method for creating an unvalidated ELText instance.

public static ELText
parse(String in, String alias)

public static ELText
public static ELText

Returns:

ELText that can be re-applied later
parse
(ExpressionFactory
ExpressionFactory to use
fact
,
ELContext
ELContext to validate against
ctx
,
String
String to parse
in
,
String
the alias
alias
)

Factory method for creating a validated ELText instance.

public String

Returns:

the evaluated String
toString
(ELContext
current ELContext state
ctx
)

Evaluates the ELText to a String

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
write(Writer
Writer to write to
out
,
ELContext
current ELContext state
ctx
)

Allow this instance to write to the passed Writer, given the ELContext state

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

literalback to summary
protected final String literal

Constructor Detail

ELTextback to summary
public ELText(String literal)

Method Detail

applyback to summary
public ELText apply(ExpressionFactory factory, ELContext ctx)

Return an instance of this that is applicable given the ELContext and ExpressionFactory state.

Parameters
factory:ExpressionFactory

the ExpressionFactory to use

ctx:ELContext

the ELContext to use

Returns:ELText

an ELText instance

findVarLengthback to summary
private static int findVarLength(char[] ca, int s) throws ELException
isLiteralback to summary
public boolean isLiteral()

If it's literal text

Returns:boolean

true if the String is literal (doesn't contain #{..} or ${..})

isLiteralback to summary
public static boolean isLiteral(String in)

Parses the passed string to determine if it's literal or not

Parameters
in:String

input String

Returns:boolean

true if the String is literal (doesn't contain #{..} or ${..})

parseback to summary
public static ELText parse(String in) throws ELException

Factory method for creating an unvalidated ELText instance.

Note

All expressions in the passed String are treated as com.sun.faces.facelets.el.ELText.LiteralValueExpression, with one exception: composite component expressions. These are treated as ContextualCompositeValueExpressions.

Parameters
in:String

String to parse

Returns:ELText

ELText instance that knows if the String was literal or not

Exceptions
ELException:
when an EL exception occurs
parseback to summary
public static ELText parse(String in, String alias) throws ELException
parseback to summary
public static ELText parse(ExpressionFactory fact, ELContext ctx, String in) throws ELException
parseback to summary
public static ELText parse(ExpressionFactory fact, ELContext ctx, String in, String alias) throws ELException

Factory method for creating a validated ELText instance. When an Expression is hit, it will use the ExpressionFactory to create a ValueExpression instance, resolving any functions at that time. Variables and properties will not be evaluated.

Parameters
fact:ExpressionFactory

ExpressionFactory to use

ctx:ELContext

ELContext to validate against

in:String

String to parse

alias:String

the alias

Returns:ELText

ELText that can be re-applied later

Exceptions
ELException:
when an EL exception occurs
toStringback to summary
public String toString(ELContext ctx) throws ELException

Evaluates the ELText to a String

Parameters
ctx:ELContext

current ELContext state

Returns:String

the evaluated String

Exceptions
ELException:
when an EL exception occurs
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.

Returns:String

a string representation of the object

Annotations
@Override
writeback to summary
public void write(Writer out, ELContext ctx) throws ELException, IOException

Allow this instance to write to the passed Writer, given the ELContext state

Parameters
out:Writer

Writer to write to

ctx:ELContext

current ELContext state

Exceptions
ELException:
when an EL exception occurs
IOException:
when an I/O exception occurs
writeTextback to summary
public void writeText(ResponseWriter out, ELContext ctx) throws ELException, IOException
com.sun.faces.facelets.el back to summary

private final Class ELText.ELTextComposite

extends ELText
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ELText[]
Inherited from com.sun.faces.facelets.el.ELText:
literal

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ELText
apply(ExpressionFactory
the ExpressionFactory to use
factory
,
ELContext
the ELContext to use
ctx
)

Overrides com.sun.faces.facelets.el.ELText.apply.

Return an instance of this that is applicable given the ELContext and ExpressionFactory state.

public boolean
isLiteral()

Overrides com.sun.faces.facelets.el.ELText.isLiteral.

If it's literal text

public String
toString(ELContext
current ELContext state
ctx
)

Overrides com.sun.faces.facelets.el.ELText.toString.

Evaluates the ELText to a String

public String
toString()

Overrides com.sun.faces.facelets.el.ELText.toString.

Returns a string representation of the object.

public void
write(Writer
Writer to write to
out
,
ELContext
current ELContext state
ctx
)

Overrides com.sun.faces.facelets.el.ELText.write.

Allow this instance to write to the passed Writer, given the ELContext state

public void
Inherited from com.sun.faces.facelets.el.ELText:
isLiteralparseparseparseparse

Field Detail

txtback to summary
private final ELText[] txt

Constructor Detail

ELTextCompositeback to summary
public ELTextComposite(ELText[] txt)

Method Detail

applyback to summary
public ELText apply(ExpressionFactory factory, ELContext ctx)

Overrides com.sun.faces.facelets.el.ELText.apply.

Doc from com.sun.faces.facelets.el.ELText.apply.

Return an instance of this that is applicable given the ELContext and ExpressionFactory state.

Parameters
factory:ExpressionFactory

the ExpressionFactory to use

ctx:ELContext

the ELContext to use

Returns:ELText

an ELText instance

Annotations
@Override
isLiteralback to summary
public boolean isLiteral()

Overrides com.sun.faces.facelets.el.ELText.isLiteral.

Doc from com.sun.faces.facelets.el.ELText.isLiteral.

If it's literal text

Returns:boolean

true if the String is literal (doesn't contain #{..} or ${..})

Annotations
@Override
toStringback to summary
public String toString(ELContext ctx)

Overrides com.sun.faces.facelets.el.ELText.toString.

Doc from com.sun.faces.facelets.el.ELText.toString.

Evaluates the ELText to a String

Parameters
ctx:ELContext

current ELContext state

Returns:String

the evaluated String

Annotations
@Override
toStringback to summary
public String toString()

Overrides com.sun.faces.facelets.el.ELText.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.

Returns:String

a string representation of the object

Annotations
@Override
writeback to summary
public void write(Writer out, ELContext ctx) throws ELException, IOException

Overrides com.sun.faces.facelets.el.ELText.write.

Doc from com.sun.faces.facelets.el.ELText.write.

Allow this instance to write to the passed Writer, given the ELContext state

Parameters
out:Writer

Writer to write to

ctx:ELContext

current ELContext state

Annotations
@Override
Exceptions
ELException:
when an EL exception occurs
IOException:
when an I/O exception occurs
writeTextback to summary
public void writeText(ResponseWriter out, ELContext ctx) throws ELException, IOException

Overrides com.sun.faces.facelets.el.ELText.writeText.

Annotations
@Override
com.sun.faces.facelets.el back to summary

private final Class ELText.ELTextVariable

extends ELText
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ValueExpression
Inherited from com.sun.faces.facelets.el.ELText:
literal

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ELText
apply(ExpressionFactory
the ExpressionFactory to use
factory
,
ELContext
the ELContext to use
ctx
)

Overrides com.sun.faces.facelets.el.ELText.apply.

Return an instance of this that is applicable given the ELContext and ExpressionFactory state.

public boolean
isLiteral()

Overrides com.sun.faces.facelets.el.ELText.isLiteral.

If it's literal text

public String
toString(ELContext
current ELContext state
ctx
)

Overrides com.sun.faces.facelets.el.ELText.toString.

Evaluates the ELText to a String

public void
write(Writer
Writer to write to
out
,
ELContext
current ELContext state
ctx
)

Overrides com.sun.faces.facelets.el.ELText.write.

Allow this instance to write to the passed Writer, given the ELContext state

public void
Inherited from com.sun.faces.facelets.el.ELText:
isLiteralparseparseparseparsetoString

Field Detail

veback to summary
private final ValueExpression ve

Constructor Detail

ELTextVariableback to summary
public ELTextVariable(ValueExpression ve)

Method Detail

applyback to summary
public ELText apply(ExpressionFactory factory, ELContext ctx)

Overrides com.sun.faces.facelets.el.ELText.apply.

Doc from com.sun.faces.facelets.el.ELText.apply.

Return an instance of this that is applicable given the ELContext and ExpressionFactory state.

Parameters
factory:ExpressionFactory

the ExpressionFactory to use

ctx:ELContext

the ELContext to use

Returns:ELText

an ELText instance

Annotations
@Override
isLiteralback to summary
public boolean isLiteral()

Overrides com.sun.faces.facelets.el.ELText.isLiteral.

Doc from com.sun.faces.facelets.el.ELText.isLiteral.

If it's literal text

Returns:boolean

true if the String is literal (doesn't contain #{..} or ${..})

Annotations
@Override
toStringback to summary
public String toString(ELContext ctx) throws ELException

Overrides com.sun.faces.facelets.el.ELText.toString.

Doc from com.sun.faces.facelets.el.ELText.toString.

Evaluates the ELText to a String

Parameters
ctx:ELContext

current ELContext state

Returns:String

the evaluated String

Annotations
@Override
Exceptions
ELException:
when an EL exception occurs
writeback to summary
public void write(Writer out, ELContext ctx) throws ELException, IOException

Overrides com.sun.faces.facelets.el.ELText.write.

Doc from com.sun.faces.facelets.el.ELText.write.

Allow this instance to write to the passed Writer, given the ELContext state

Parameters
out:Writer

Writer to write to

ctx:ELContext

current ELContext state

Annotations
@Override
Exceptions
ELException:
when an EL exception occurs
IOException:
when an I/O exception occurs
writeTextback to summary
public void writeText(ResponseWriter out, ELContext ctx) throws ELException, IOException

Overrides com.sun.faces.facelets.el.ELText.writeText.

Annotations
@Override
com.sun.faces.facelets.el back to summary

private final Class ELText.LiteralValueExpression

extends ValueExpression
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the Object to test for equality.
obj
)

Implements abstract jakarta.el.Expression.equals.

Determines whether the specified object is equal to this Expression.

public Class<T>
getExpectedType()

Implements abstract jakarta.el.ValueExpression.getExpectedType.

Returns the type the result of the expression will be coerced to after evaluation.

public String
getExpressionString()

Implements abstract jakarta.el.Expression.getExpressionString.

Returns the original String used to create this Expression, unmodified.

public Class<T>
getType(ELContext
The context of this evaluation.
context
)

Implements abstract jakarta.el.ValueExpression.getType.

Evaluates the expression relative to the provided context, and returns the most general type that is acceptable for an object to be passed as the value parameter in a future call to the setValue method.

public <T> T
getValue(ELContext
The context of this evaluation.
context
)

Implements abstract jakarta.el.ValueExpression.getValue.

Evaluates the expression relative to the provided context, and returns the resulting value.

public int
hashCode()

Implements abstract jakarta.el.Expression.hashCode.

Returns the hash code for this Expression.

public boolean
isLiteralText()

Implements abstract jakarta.el.Expression.isLiteralText.

Returns whether this expression was created from only literal text.

public boolean
isReadOnly(ELContext
The context of this evaluation.
context
)

Implements abstract jakarta.el.ValueExpression.isReadOnly.

Evaluates the expression relative to the provided context, and returns true if a call to setValue will always fail.

public void
setValue(ELContext
The context of this evaluation.
context
,
Object
The new value to be set.
value
)

Implements abstract jakarta.el.ValueExpression.setValue.

Evaluates the expression relative to the provided context, and sets the result to the provided value.

Inherited from jakarta.el.ValueExpression:
getValueReference

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides jakarta.el.ValueExpression.serialVersionUID.

textback to summary
private final String text

Constructor Detail

LiteralValueExpressionback to summary
public LiteralValueExpression(String text)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Implements abstract jakarta.el.Expression.equals.

Doc from jakarta.el.Expression.equals.

Determines whether the specified object is equal to this Expression.

The result is true if and only if the argument is not null, is an Expression object that is the of the same type (ValueExpression or MethodExpression), and has an identical parsed representation.

Note that two expressions can be equal if their expression Strings are different. For example, ${fn1:foo()} and ${fn2:foo()} are equal if their corresponding FunctionMappers mapped fn1:foo and fn2:foo to the same method.

Parameters
obj:Object

the Object to test for equality.

Returns:boolean

true if obj equals this Expression; false otherwise.

Annotations
@Override
getExpectedTypeback to summary
public Class<T> getExpectedType()

Implements abstract jakarta.el.ValueExpression.getExpectedType.

Doc from jakarta.el.ValueExpression.getExpectedType.

Returns the type the result of the expression will be coerced to after evaluation.

Returns:Class<T>

the expectedType passed to the ExpressionFactory.createValueExpression method that created this ValueExpression.

Annotations
@Override
getExpressionStringback to summary
public String getExpressionString()

Implements abstract jakarta.el.Expression.getExpressionString.

Doc from jakarta.el.Expression.getExpressionString.

Returns the original String used to create this Expression, unmodified.

This is used for debugging purposes but also for the purposes of comparison (e.g. to ensure the expression in a configuration file has not changed).

This method does not provide sufficient information to re-create an expression. Two different expressions can have exactly the same expression string but different function mappings. Serialization should be used to save and restore the state of an Expression.

Returns:String

The original expression String.

Annotations
@Override
getTypeback to summary
public Class<T> getType(ELContext context)

Implements abstract jakarta.el.ValueExpression.getType.

Doc from jakarta.el.ValueExpression.getType.

Evaluates the expression relative to the provided context, and returns the most general type that is acceptable for an object to be passed as the value parameter in a future call to the setValue method.

This is not always the same as getValue().getClass(). For example, in the case of an expression that references an array element, the getType method will return the element type of the array, which might be a superclass of the type of the actual element that is currently in the specified array element.

Parameters
context:ELContext

The context of this evaluation.

Returns:Class<T>

the most general acceptable type; otherwise undefined.

Annotations
@Override
getValueback to summary
public <T> T getValue(ELContext context)

Implements abstract jakarta.el.ValueExpression.getValue.

Doc from jakarta.el.ValueExpression.getValue.

Evaluates the expression relative to the provided context, and returns the resulting value.

The resulting value is automatically coerced to the type returned by getExpectedType(), which was provided to the ExpressionFactory when this expression was created.

Parameters
context:ELContext

The context of this evaluation.

Returns:T

The result of the expression evaluation.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Implements abstract jakarta.el.Expression.hashCode.

Doc from jakarta.el.Expression.hashCode.

Returns the hash code for this Expression.

See the note in the equals method on how two expressions can be equal if their expression Strings are different. Recall that if two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. Implementations must take special note and implement hashCode correctly.

Returns:int

The hash code for this Expression.

Annotations
@Override
isLiteralTextback to summary
public boolean isLiteralText()

Implements abstract jakarta.el.Expression.isLiteralText.

Doc from jakarta.el.Expression.isLiteralText.

Returns whether this expression was created from only literal text.

This method must return true if and only if the expression string this expression was created from contained no unescaped Jakarta Expression Language delimeters (${...} or #{...}).

Returns:boolean

true if this expression was created from only literal text; false otherwise.

Annotations
@Override
isReadOnlyback to summary
public boolean isReadOnly(ELContext context)

Implements abstract jakarta.el.ValueExpression.isReadOnly.

Doc from jakarta.el.ValueExpression.isReadOnly.

Evaluates the expression relative to the provided context, and returns true if a call to setValue will always fail.

Parameters
context:ELContext

The context of this evaluation.

Returns:boolean

true if the expression is read-only or false if not.

Annotations
@Override
setValueback to summary
public void setValue(ELContext context, Object value)

Implements abstract jakarta.el.ValueExpression.setValue.

Doc from jakarta.el.ValueExpression.setValue.

Evaluates the expression relative to the provided context, and sets the result to the provided value.

Parameters
context:ELContext

The context of this evaluation.

value:Object

The new value to be set.

Annotations
@Override