本文整理汇总了Java中com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.Real方法的典型用法代码示例。如果您正苦于以下问题:Java Type.Real方法的具体用法?Java Type.Real怎么用?Java Type.Real使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type
的用法示例。
在下文中一共展示了Type.Real方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_value != null) {
Type tvalue = _value.typeCheck(stable);
if (tvalue instanceof RealType == false) {
_value = new CastExpr(_value, Type.Real);
}
}
if (_count != null) {
_count.typeCheck(stable);
}
if (_from != null) {
_from.typeCheck(stable);
}
if (_format != null) {
_format.typeCheck(stable);
}
if (_lang != null) {
_lang.typeCheck(stable);
}
if (_letterValue != null) {
_letterValue.typeCheck(stable);
}
if (_groupingSeparator != null) {
_groupingSeparator.typeCheck(stable);
}
if (_groupingSize != null) {
_groupingSize.typeCheck(stable);
}
return Type.Void;
}
示例3: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (argumentCount() > 0) {
argument().typeCheck(stable);
}
return _type = Type.Real;
}
示例4: 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;
}
示例5: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
/**
* Type check a predicate expression. If the type of the expression is
* number convert it to boolean by adding a comparison with position().
* Note that if the expression is a parameter, we cannot distinguish
* at compile time if its type is number or not. Hence, expressions of
* reference type are always converted to booleans.
*
* This method may be called twice, before and after calling
* <code>dontOptimize()</code>. If so, the second time it should honor
* the new value of <code>_canOptimize</code>.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
Type texp = _exp.typeCheck(stable);
// We need explicit type information for reference types - no good!
if (texp instanceof ReferenceType) {
_exp = new CastExpr(_exp, texp = Type.Real);
}
// A result tree fragment should not be cast directly to a number type,
// but rather to a boolean value, and then to a numer (0 or 1).
// Ref. section 11.2 of the XSLT 1.0 spec
if (texp instanceof ResultTreeType) {
_exp = new CastExpr(_exp, Type.Boolean);
_exp = new CastExpr(_exp, Type.Real);
texp = _exp.typeCheck(stable);
}
// Numerical types will be converted to a position filter
if (texp instanceof NumberType) {
// Cast any numerical types to an integer
if (texp instanceof IntType == false) {
_exp = new CastExpr(_exp, Type.Int);
}
if (_canOptimize) {
// Nth position optimization. Expression must not depend on context
_nthPositionFilter =
!_exp.hasLastCall() && !_exp.hasPositionCall();
// _nthDescendant optimization - only if _nthPositionFilter is on
if (_nthPositionFilter) {
SyntaxTreeNode parent = getParent();
_nthDescendant = (parent instanceof Step) &&
(parent.getParent() instanceof AbsoluteLocationPath);
return _type = Type.NodeSet;
}
}
// Reset optimization flags
_nthPositionFilter = _nthDescendant = false;
// Otherwise, expand [e] to [position() = e]
final QName position =
getParser().getQNameIgnoreDefaultNs("position");
final PositionCall positionCall =
new PositionCall(position);
positionCall.setParser(getParser());
positionCall.setParent(this);
_exp = new EqualityExpr(Operators.EQ, positionCall,
_exp);
if (_exp.typeCheck(stable) != Type.Boolean) {
_exp = new CastExpr(_exp, Type.Boolean);
}
return _type = Type.Boolean;
}
else {
// All other types will be handled as boolean values
if (texp instanceof BooleanType == false) {
_exp = new CastExpr(_exp, Type.Boolean);
}
return _type = Type.Boolean;
}
}
示例6: typeCheck
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; //导入方法依赖的package包/类
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
return _type = Type.Real;
}