本文整理汇总了Java中com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.String方法的典型用法代码示例。如果您正苦于以下问题:Java Type.String方法的具体用法?Java Type.String怎么用?Java Type.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type
的用法示例。
在下文中一共展示了Type.String方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Check that we either have no parameters or one parameter that is
* either a node or a node-set.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
// Check the argument type (if any)
switch(argumentCount()) {
case 0:
_paramType = Type.Node;
break;
case 1:
_paramType = _param.typeCheck(stable);
break;
default:
throw new TypeCheckError(this);
}
// The argument has to be a node, a node-set or a node reference
if ((_paramType != Type.NodeSet) &&
(_paramType != Type.Node) &&
(_paramType != Type.Reference)) {
throw new TypeCheckError(this);
}
return (_type = Type.String);
}
示例2: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Type check the two parameters for this function
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
// Check that the function was passed exactly two arguments
if (argumentCount() != 2) {
throw new TypeCheckError(ErrorMsg.ILLEGAL_ARG_ERR, getName(), this);
}
// The first argument must be a String, or cast to a String
_base = argument(0);
Type baseType = _base.typeCheck(stable);
if (baseType != Type.String)
_base = new CastExpr(_base, Type.String);
// The second argument must also be a String, or cast to a String
_token = argument(1);
Type tokenType = _token.typeCheck(stable);
if (tokenType != Type.String)
_token = new CastExpr(_token, Type.String);
return _type = Type.Boolean;
}
示例3: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Type check the two parameters for this function
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
// Check that the function was passed exactly two arguments
if (argumentCount() != 2) {
ErrorMsg err = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR,
getName(), this);
throw new TypeCheckError(err);
}
// The first argument must be a String, or cast to a String
_base = argument(0);
Type baseType = _base.typeCheck(stable);
if (baseType != Type.String)
_base = new CastExpr(_base, Type.String);
// The second argument must also be a String, or cast to a String
_token = argument(1);
Type tokenType = _token.typeCheck(stable);
if (tokenType != Type.String)
_token = new CastExpr(_token, Type.String);
return _type = Type.Boolean;
}
示例4: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
Type type = _select.typeCheck(stable);
// Prefer to handle the value as a node; fall back to String, otherwise
if (type != null && !type.identicalTo(Type.Node)) {
/***
*** %HZ% Would like to treat result-tree fragments in the same
*** %HZ% way as node sets for value-of, but that's running into
*** %HZ% some snags. Instead, they'll be converted to String
if (type.identicalTo(Type.ResultTree)) {
_select = new CastExpr(new CastExpr(_select, Type.NodeSet),
Type.Node);
} else
***/
if (type.identicalTo(Type.NodeSet)) {
_select = new CastExpr(_select, Type.Node);
} else {
_isString = true;
if (!type.identicalTo(Type.String)) {
_select = new CastExpr(_select, Type.String);
}
_isString = true;
}
}
return Type.Void;
}
示例5: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
for (int i = 0; i < argumentCount(); i++) {
final Expression exp = argument(i);
if (!exp.typeCheck(stable).identicalTo(Type.String)) {
setArgument(i, new CastExpr(exp, Type.String));
}
}
return _type = Type.String;
}
示例6: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final List<SyntaxTreeNode> contents = getContents();
final int n = contents.size();
for (int i = 0; i < n; i++) {
final Expression exp = (Expression)contents.get(i);
if (!exp.typeCheck(stable).identicalTo(Type.String)) {
contents.set(i, new CastExpr(exp, Type.String));
}
}
return _type = Type.String;
}
示例7: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final Type tselect = _select.typeCheck(stable);
if (tselect instanceof NodeType ||
tselect instanceof NodeSetType ||
tselect instanceof ReferenceType ||
tselect instanceof ResultTreeType) {
// falls through
}
else {
_select = new CastExpr(_select, Type.String);
}
return Type.Void;
}
示例8: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
*
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
_langType = _lang.typeCheck(stable);
if (!(_langType instanceof StringType)) {
_lang = new CastExpr(_lang, Type.String);
}
return Type.Boolean;
}
示例9: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Run type checks on the attributes; expression must return a string
* which we will use as a sort key
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final Type tselect = _select.typeCheck(stable);
// If the sort data-type is not set we use the natural data-type
// of the data we will sort
if (!(tselect instanceof StringType)) {
_select = new CastExpr(_select, Type.String);
}
_order.typeCheck(stable);
_caseOrder.typeCheck(stable);
_dataType.typeCheck(stable);
return Type.Void;
}
示例10: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final int argc = argumentCount();
if (argc > 1) {
ErrorMsg err = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, this);
throw new TypeCheckError(err);
}
if (argc > 0) {
argument().typeCheck(stable);
}
return _type = Type.String;
}
示例11: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
// Inform stylesheet to instantiate a DecimalFormat object
getStylesheet().numberFormattingUsed();
final Type tvalue = _value.typeCheck(stable);
if (tvalue instanceof RealType == false) {
_value = new CastExpr(_value, Type.Real);
}
final Type tformat = _format.typeCheck(stable);
if (tformat instanceof StringType == false) {
_format = new CastExpr(_format, Type.String);
}
if (argumentCount() == 3) {
final Type tname = _name.typeCheck(stable);
if (_name instanceof LiteralExpr) {
final LiteralExpr literal = (LiteralExpr) _name;
_resolvedQName =
getParser().getQNameIgnoreDefaultNs(literal.getValue());
}
else if (tname instanceof StringType == false) {
_name = new CastExpr(_name, Type.String);
}
}
return _type = Type.String;
}
示例12: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Typing rules: see XSLT Reference by M. Kay page 345.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final Type tleft = _left.typeCheck(stable);
final Type tright = _right.typeCheck(stable);
if (tleft.isSimple() && tright.isSimple()) {
if (tleft != tright) {
if (tleft instanceof BooleanType) {
_right = new CastExpr(_right, Type.Boolean);
}
else if (tright instanceof BooleanType) {
_left = new CastExpr(_left, Type.Boolean);
}
else if (tleft instanceof NumberType ||
tright instanceof NumberType) {
_left = new CastExpr(_left, Type.Real);
_right = new CastExpr(_right, Type.Real);
}
else { // both compared as strings
_left = new CastExpr(_left, Type.String);
_right = new CastExpr(_right, Type.String);
}
}
}
else if (tleft instanceof ReferenceType) {
_right = new CastExpr(_right, Type.Reference);
}
else if (tright instanceof ReferenceType) {
_left = new CastExpr(_left, Type.Reference);
}
// the following 2 cases optimize @attr|.|.. = 'string'
else if (tleft instanceof NodeType && tright == Type.String) {
_left = new CastExpr(_left, Type.String);
}
else if (tleft == Type.String && tright instanceof NodeType) {
_right = new CastExpr(_right, Type.String);
}
// optimize node/node
else if (tleft instanceof NodeType && tright instanceof NodeType) {
_left = new CastExpr(_left, Type.String);
_right = new CastExpr(_right, Type.String);
}
else if (tleft instanceof NodeType && tright instanceof NodeSetType) {
// compare(Node, NodeSet) will be invoked
}
else if (tleft instanceof NodeSetType && tright instanceof NodeType) {
swapArguments(); // for compare(Node, NodeSet)
}
else {
// At least one argument is of type node, node-set or result-tree
// Promote an expression of type node to node-set
if (tleft instanceof NodeType) {
_left = new CastExpr(_left, Type.NodeSet);
}
if (tright instanceof NodeType) {
_right = new CastExpr(_right, Type.NodeSet);
}
// If one arg is a node-set then make it the left one
if (tleft.isSimple() ||
tleft instanceof ResultTreeType &&
tright instanceof NodeSetType) {
swapArguments();
}
// Promote integers to doubles to have fewer compares
if (_right.getType() instanceof IntType) {
_right = new CastExpr(_right, Type.Real);
}
}
return _type = Type.Boolean;
}
示例13: getCompareValue
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Returns the value in an expression of the form 'step = value'.
* A value may be either a literal string or a variable whose
* type is string. Optimization if off if null is returned.
*/
public Expression getCompareValue() {
// Returned cached value if called more than once
if (_value != null) {
return _value;
}
// Nothing to to do if _exp is null
if (_exp == null) {
return null;
}
// Ignore if not an equality expression
if (_exp instanceof EqualityExpr) {
EqualityExpr exp = (EqualityExpr) _exp;
Expression left = exp.getLeft();
Expression right = exp.getRight();
// Return if left is literal string
if (left instanceof LiteralExpr) {
_value = left;
return _value;
}
// Return if left is a variable reference of type string
if (left instanceof VariableRefBase &&
left.getType() == Type.String)
{
_value = left;
return _value;
}
// Return if right is literal string
if (right instanceof LiteralExpr) {
_value = right;
return _value;
}
// Return if left is a variable reference whose type is string
if (right instanceof VariableRefBase &&
right.getType() == Type.String)
{
_value = right;
return _value;
}
}
return null;
}
示例14: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Type check the parameters for the id() or key() function.
* The index name (for key() call only) must be a string or convertable
* to a string, and the lookup-value must be a string or a node-set.
* @param stable The parser's symbol table
* @throws TypeCheckError When the parameters have illegal type
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final Type returnType = super.typeCheck(stable);
// Run type check on the key name (first argument) - must be a string,
// and if it is not it must be converted to one using string() rules.
if (_name != null) {
final Type nameType = _name.typeCheck(stable);
if (_name instanceof LiteralExpr) {
final LiteralExpr literal = (LiteralExpr) _name;
_resolvedQName =
getParser().getQNameIgnoreDefaultNs(literal.getValue());
}
else if (nameType instanceof StringType == false) {
_name = new CastExpr(_name, Type.String);
}
}
// Run type check on the value for this key. This value can be of
// any data type, so this should never cause any type-check errors.
// If the value is a reference, then we have to defer the decision
// of how to process it until run-time.
// If the value is known not to be a node-set, then it should be
// converted to a string before the lookup is done. If the value is
// known to be a node-set then this process (convert to string, then
// do lookup) should be applied to every node in the set, and the
// result from all lookups should be added to the resulting node-set.
_valueType = _value.typeCheck(stable);
if (_valueType != Type.NodeSet
&& _valueType != Type.Reference
&& _valueType != Type.String) {
_value = new CastExpr(_value, Type.String);
_valueType = _value.typeCheck(stable);
}
// If in a top-level element, create dependency to the referenced key
addParentDependency();
return returnType;
}
示例15: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Returns this attribute value's type (String).
* @param stable The compiler/parser's symbol table
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
return _type = Type.String;
}