You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/03/17 15:43:04 UTC
jena git commit: Deprecation cycle for asExprList(arg)
Repository: jena
Updated Branches:
refs/heads/master 46ed39c57 -> c7b83dbe6
Deprecation cycle for asExprList(arg)
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/c7b83dbe
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/c7b83dbe
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/c7b83dbe
Branch: refs/heads/master
Commit: c7b83dbe6490fb67a33d55ce2b5b06ba07646e15
Parents: 46ed39c
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Mar 17 13:07:07 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Mar 17 13:07:07 2016 +0000
----------------------------------------------------------------------
.../jena/sparql/pfunction/PropFuncArg.java | 85 +++++++++++---------
1 file changed, 49 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/c7b83dbe/jena-arq/src/main/java/org/apache/jena/sparql/pfunction/PropFuncArg.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/pfunction/PropFuncArg.java b/jena-arq/src/main/java/org/apache/jena/sparql/pfunction/PropFuncArg.java
index bf1280d..b2757e5 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/pfunction/PropFuncArg.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/pfunction/PropFuncArg.java
@@ -45,17 +45,15 @@ public class PropFuncArg extends PrintSerializableBase
private List<Node> argList = null ;
private Node arg = null ;
- public PropFuncArg(List<Node> argList, Node arg)
- {
+ public PropFuncArg(List<Node> argList, Node arg) {
// arg is always the argument, which may be a list in argList.
// If it's a list, remember that.
- if ( argList == null )
- {
+ if ( argList == null ) {
this.arg = arg ;
return ;
}
this.argList = argList ;
- // If the list is zero length, it's rdf:nil. Be careful!
+ // If the list is zero length, it's rdf:nil. Be careful!
if ( argList.isEmpty() )
this.arg = NodeConst.nodeNil ;
}
@@ -66,66 +64,81 @@ public class PropFuncArg extends PrintSerializableBase
public Node getArg() { return arg ; }
public List<Node> getArgList() { return argList ; }
public int getArgListSize() { return argList==null ? -1 : argList.size() ; }
- public Node getArg(int index)
- {
- if ( argList == null ) return null ;
+
+ public Node getArg(int index) {
+ if ( argList == null )
+ return null ;
return argList.get(index) ;
}
-
+
@Override
- public int hashCode()
- {
- if ( isNode() ) return arg.hashCode() ;
+ public int hashCode() {
+ if ( isNode() )
+ return arg.hashCode() ;
return argList.hashCode() ;
}
-
+
@Override
- public boolean equals(Object other)
- {
- if ( this == other ) return true ;
- if ( ! ( other instanceof PropFuncArg ) ) return false ;
+ public boolean equals(Object other) {
+ if ( this == other )
+ return true ;
+ if ( !(other instanceof PropFuncArg) )
+ return false ;
PropFuncArg pfArg = (PropFuncArg)other ;
if ( isNode() )
return arg.equals(pfArg.arg) ;
return argList.equals(pfArg.argList) ;
-
+
}
public boolean isList() { return argList != null ; }
public boolean isNode() { return arg != null ; }
- public ExprList asExprList()
- {
+
+ /** @deprecated To be removed - use {@link #asExprList()} */
+ @Deprecated
+ public ExprList asExprList(PropFuncArg pfArg) {
ExprList exprList = new ExprList() ;
- if ( isNode() )
- {
- Node n = getArg() ;
+ if ( pfArg.isNode() ) {
+ Node n = pfArg.getArg() ;
Expr expr = ExprUtils.nodeToExpr(n) ;
exprList.add(expr) ;
return exprList ;
}
- for ( Node n : getArgList() )
- {
- Expr expr = ExprUtils.nodeToExpr( n );
- exprList.add( expr );
+ for ( Node n : pfArg.getArgList() ) {
+ Expr expr = ExprUtils.nodeToExpr(n) ;
+ exprList.add(expr) ;
}
return exprList ;
}
+
+ public ExprList asExprList() {
+ ExprList exprList = new ExprList() ;
+ if ( isNode() ) {
+ Node n = getArg() ;
+ Expr expr = ExprUtils.nodeToExpr(n) ;
+ exprList.add(expr) ;
+ return exprList ;
+ }
+ for ( Node n : getArgList() ) {
+ Expr expr = ExprUtils.nodeToExpr(n) ;
+ exprList.add(expr) ;
+ }
+ return exprList ;
+ }
@Override
- public void output(final IndentedWriter out, final SerializationContext sCxt)
- {
+ public void output(final IndentedWriter out, final SerializationContext sCxt) {
if ( argList == null && arg == null )
out.print("<<null>>") ;
- if ( argList != null )
- {
+ if ( argList != null ) {
out.print("(") ;
boolean first = true ;
- for ( Node n : argList )
- {
- if ( ! first ) out.print(" ") ;
+ for ( Node n : argList ) {
+ if ( !first )
+ out.print(" ") ;
String str = FmtUtils.stringForNode(n, sCxt) ;
out.print(str) ;
first = false ;
@@ -137,11 +150,11 @@ public class PropFuncArg extends PrintSerializableBase
}
public static void addVars(Collection<Var> acc, PropFuncArg pfArg) {
- if (pfArg.isNode()) {
+ if ( pfArg.isNode() ) {
addVar(acc, pfArg.getArg()) ;
return ;
}
- for (Node n : pfArg.getArgList())
+ for ( Node n : pfArg.getArgList() )
addVar(acc, n) ;
}
}