Package org.apache.jena.sparql.util
Class Context
- java.lang.Object
-
- org.apache.jena.sparql.util.Context
-
- Direct Known Subclasses:
JsonLDReadContext,JsonLDWriteContext
public class Context extends java.lang.ObjectA class for setting and keeping named values. Used to pass implementation-specific parameters across general interfaces.
-
-
Field Summary
Fields Modifier and Type Field Description static ContextemptyContext
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Contextcopy()Return a copy of this context.booleanequals(java.lang.Object obj)<T> Tget(Symbol property)Get the object value of a property or nulljava.lang.Objectget(Symbol property, java.lang.Object defaultValue)Get the object value of a property - return the default value if not present .java.lang.StringgetAsString(Symbol property)Get the value a string (uses .toString() if the value is not null)java.lang.StringgetAsString(Symbol property, java.lang.String defaultValue)Get the value a string (uses .toString() if the value is not null) - supply a default string valueintgetInt(Symbol symbol, int defaultValue)Get the value as a long value.longgetLong(Symbol symbol, long defaultValue)Get the value as a long value.inthashCode()booleanhasValue(Symbol property, java.lang.Object value)Test whether a named value is a specific value (.equals)booleanhasValueAsString(Symbol property, java.lang.String value)Test whether a named value (as a string) has a specific string formbooleanhasValueAsString(Symbol property, java.lang.String value, boolean ignoreCase)Test whether a named value (as a string) has a specific string form - can ignore casebooleanisDefined(Symbol property)Is a property set?booleanisFalse(Symbol property)Is the value 'false' (either set to the string "false" or Boolean.FALSE)booleanisFalseOrUndef(Symbol property)Is the value 'false' (either set to the string "false" or Boolean.FALSE) or undefinedbooleanisTrue(Symbol property)Is the value 'true' (either set to the string "true" or Boolean.TRUE)booleanisTrueOrUndef(Symbol property)Is the value 'true' (either set to the string "true" or Boolean.TRUE) or undefined?booleanisUndef(Symbol property)Is a property not set?java.util.Set<Symbol>keys()Set of properties (as Symbols) currently definedstatic ContextmergeCopy(Context contextGlobal, Context contextLocal)Merge an outer (defaults to the system global context) and local context to produce a new context The new context is always a separate copy.voidput(Symbol property, java.lang.Object value)Store a named value - overwrites any previous set valuevoidputAll(Context other)voidremove(Symbol property)Remove any value associated with a propertyvoidset(Symbol property, boolean value)Store a named value - overwrites any previous set valuevoidset(Symbol property, java.lang.Object value)Store a named value - overwrites any previous set valuestatic voidsetCurrentDateTime(Context context)voidsetFalse(Symbol property)Set property value to be falsevoidsetIfUndef(Symbol property, java.lang.Object value)Store a named value only if it is not currently setvoidsetTrue(Symbol property)Set property value to be truestatic ContextsetupContextForDataset(Context globalContext, DatasetGraph dataset)Setup a context using another context and a dataset.intsize()Return the number of context itemsjava.lang.StringtoString()voidunset(Symbol property)Remove any value associated with a property - alternative method name
-
-
-
Field Detail
-
emptyContext
public static final Context emptyContext
-
-
Constructor Detail
-
Context
public Context()
Create an empty context
-
Context
public Context(Context cxt)
Create a context and initialize it with a copy of the named values of another one. Shallow copy: the values themselves are not copied
-
-
Method Detail
-
copy
public Context copy()
Return a copy of this context. Modifications of the copy do not affect the original context.
-
get
public <T> T get(Symbol property)
Get the object value of a property or null
-
get
public java.lang.Object get(Symbol property, java.lang.Object defaultValue)
Get the object value of a property - return the default value if not present .
-
put
public void put(Symbol property, java.lang.Object value)
Store a named value - overwrites any previous set value
-
set
public void set(Symbol property, java.lang.Object value)
Store a named value - overwrites any previous set value
-
set
public void set(Symbol property, boolean value)
Store a named value - overwrites any previous set value
-
setIfUndef
public void setIfUndef(Symbol property, java.lang.Object value)
Store a named value only if it is not currently set
-
remove
public void remove(Symbol property)
Remove any value associated with a property
-
unset
public void unset(Symbol property)
Remove any value associated with a property - alternative method name
-
isDefined
public boolean isDefined(Symbol property)
Is a property set?
-
isUndef
public boolean isUndef(Symbol property)
Is a property not set?
-
getAsString
public java.lang.String getAsString(Symbol property, java.lang.String defaultValue)
Get the value a string (uses .toString() if the value is not null) - supply a default string value
-
getAsString
public java.lang.String getAsString(Symbol property)
Get the value a string (uses .toString() if the value is not null)
-
getInt
public int getInt(Symbol symbol, int defaultValue)
Get the value as a long value. The context entry can be a string, Integer or Long.
-
getLong
public long getLong(Symbol symbol, long defaultValue)
Get the value as a long value. The context entry can be a string, Integer or Long.
-
putAll
public void putAll(Context other)
-
setTrue
public void setTrue(Symbol property)
Set property value to be true
-
setFalse
public void setFalse(Symbol property)
Set property value to be false
-
isTrue
public boolean isTrue(Symbol property)
Is the value 'true' (either set to the string "true" or Boolean.TRUE)
-
isTrueOrUndef
public boolean isTrueOrUndef(Symbol property)
Is the value 'true' (either set to the string "true" or Boolean.TRUE) or undefined?
-
isFalse
public boolean isFalse(Symbol property)
Is the value 'false' (either set to the string "false" or Boolean.FALSE)
-
isFalseOrUndef
public boolean isFalseOrUndef(Symbol property)
Is the value 'false' (either set to the string "false" or Boolean.FALSE) or undefined
-
hasValue
public boolean hasValue(Symbol property, java.lang.Object value)
Test whether a named value is a specific value (.equals)
-
hasValueAsString
public boolean hasValueAsString(Symbol property, java.lang.String value)
Test whether a named value (as a string) has a specific string form
-
hasValueAsString
public boolean hasValueAsString(Symbol property, java.lang.String value, boolean ignoreCase)
Test whether a named value (as a string) has a specific string form - can ignore case
-
keys
public java.util.Set<Symbol> keys()
Set of properties (as Symbols) currently defined
-
size
public int size()
Return the number of context items
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setupContextForDataset
public static Context setupContextForDataset(Context globalContext, DatasetGraph dataset)
Setup a context using another context and a dataset.
-
setCurrentDateTime
public static void setCurrentDateTime(Context context)
-
mergeCopy
public static Context mergeCopy(Context contextGlobal, Context contextLocal)
Merge an outer (defaults to the system global context) and local context to produce a new context The new context is always a separate copy.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-