本文整理汇总了Java中com.sun.org.apache.xpath.internal.objects.XNumber类的典型用法代码示例。如果您正苦于以下问题:Java XNumber类的具体用法?Java XNumber怎么用?Java XNumber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XNumber类属于com.sun.org.apache.xpath.internal.objects包,在下文中一共展示了XNumber类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: leapYear
import com.sun.org.apache.xpath.internal.objects.XNumber; //导入依赖的package包/类
/**
* The date:leap-year function returns true if the year given in a date
* is a leap year. If no argument is given, then the current local
* date/time, as returned by date:date-time is used as a default argument.
* The date/time string specified as the first argument must be a
* right-truncated string in the format defined as the lexical representation
* of xs:dateTime in one of the formats defined in
* <a href="http://www.w3.org/TR/xmlschema-2/">[XML Schema Part 2: Datatypes]</a>.
* The permitted formats are as follows:
* xs:dateTime (CCYY-MM-DDThh:mm:ss)
* xs:date (CCYY-MM-DD)
* xs:gYearMonth (CCYY-MM)
* xs:gYear (CCYY)
* If the date/time string is not in one of these formats, then NaN is returned.
*/
public static XObject leapYear(String datetimeIn)
throws ParseException
{
String[] edz = getEraDatetimeZone(datetimeIn);
String datetime = edz[1];
if (datetime == null)
return new XNumber(Double.NaN);
String[] formats = {dt, d, gym, gy};
double dbl = getNumber(datetime, formats, Calendar.YEAR);
if (dbl == Double.NaN)
return new XNumber(Double.NaN);
int yr = (int)dbl;
return new XBoolean(yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0));
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:ExsltDatetime.java
示例2: visitPredicate
import com.sun.org.apache.xpath.internal.objects.XNumber; //导入依赖的package包/类
/**
* Visit a predicate within a location path. Note that there isn't a
* proper unique component for predicates, and that the expression will
* be called also for whatever type Expression is.
*
* @param owner The owner of the expression, to which the expression can
* be reset if rewriting takes place.
* @param pred The predicate object.
* @return true if the sub expressions should be traversed.
*/
public boolean visitPredicate(ExpressionOwner owner, Expression pred)
{
m_predDepth++;
if(m_predDepth == 1)
{
if((pred instanceof Variable) ||
(pred instanceof XNumber) ||
(pred instanceof Div) ||
(pred instanceof Plus) ||
(pred instanceof Minus) ||
(pred instanceof Mod) ||
(pred instanceof Quo) ||
(pred instanceof Mult) ||
(pred instanceof com.sun.org.apache.xpath.internal.operations.Number) ||
(pred instanceof Function))
m_hasPositionalPred = true;
else
pred.callVisitors(owner, this);
}
m_predDepth--;
// Don't go have the caller go any further down the subtree.
return false;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:HasPositionalPredChecker.java
示例3: execute
import com.sun.org.apache.xpath.internal.objects.XNumber; //导入依赖的package包/类
/**
* Execute the function. The function must return
* a valid object.
* @param xctxt The current execution context.
* @return A valid XObject.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{
// DTMIterator nl = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
// // We should probably make a function on the iterator for this,
// // as a given implementation could optimize.
// int i = 0;
//
// while (DTM.NULL != nl.nextNode())
// {
// i++;
// }
// nl.detach();
DTMIterator nl = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
int i = nl.getLength();
nl.detach();
return new XNumber((double) i);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:FuncCount.java
示例4: execute
import com.sun.org.apache.xpath.internal.objects.XNumber; //导入依赖的package包/类
/**
* Execute the function. The function must return
* a valid object.
* @param xctxt The current execution context.
* @return A valid XObject.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{
DTMIterator nodes = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
double sum = 0.0;
int pos;
while (DTM.NULL != (pos = nodes.nextNode()))
{
DTM dtm = nodes.getDTM(pos);
XMLString s = dtm.getStringValue(pos);
if (null != s)
sum += s.toDouble();
}
nodes.detach();
return new XNumber(sum);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:FuncSum.java
示例5: execute
import com.sun.org.apache.xpath.internal.objects.XNumber; //导入依赖的package包/类
/**
* Test a node to see if it matches the given node test.
*
* @param xctxt XPath runtime context.
*
* @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
* {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
* {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
* {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
* {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt, int context)
throws javax.xml.transform.TransformerException
{
DTMIterator nl = m_functionExpr.asIterator(xctxt, context);
XNumber score = SCORE_NONE;
if (null != nl)
{
int n;
while (DTM.NULL != (n = nl.nextNode()))
{
score = (n == context) ? SCORE_OTHER : SCORE_NONE;
if (score == SCORE_OTHER)
{
context = n;
break;
}
}
// nl.detach();
}
nl.detach();
return score;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:FunctionPattern.java
示例6: execute
import com.sun.org.apache.xpath.internal.objects.XNumber; //导入依赖的package包/类
/**
* Execute the function. The function must return
* a valid object.
* @param xctxt The current execution context.
* @return A valid XObject.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{
final XObject obj = m_arg0.execute(xctxt);
final double val= obj.num();
if (val >= -0.5 && val < 0) return new XNumber(-0.0);
if (val == 0.0) return new XNumber(val);
return new XNumber(java.lang.Math.floor(val
+ 0.5));
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:FuncRound.java
示例7: Number
import com.sun.org.apache.xpath.internal.objects.XNumber; //导入依赖的package包/类
/**
*
* Number ::= [0-9]+('.'[0-9]+)? | '.'[0-9]+
*
*
* @throws javax.xml.transform.TransformerException
*/
protected void Number() throws javax.xml.transform.TransformerException
{
if (null != m_token)
{
// Mutate the token to remove the quotes and have the XNumber object
// already made.
double num;
try
{
// XPath 1.0 does not support number in exp notation
if ((m_token.indexOf('e') > -1)||(m_token.indexOf('E') > -1))
throw new NumberFormatException();
num = Double.valueOf(m_token).doubleValue();
}
catch (NumberFormatException nfe)
{
num = 0.0; // to shut up compiler.
error(XPATHErrorResources.ER_COULDNOT_BE_FORMATTED_TO_NUMBER,
new Object[]{ m_token }); //m_token+" could not be formatted to a number!");
}
m_ops.m_tokenQueue.setElementAt(new XNumber(num),m_queueMark - 1);
m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), m_queueMark - 1);
m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
nextToken();
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:XPathParser.java
注:本文中的com.sun.org.apache.xpath.internal.objects.XNumber类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论