Tabnine Logo
ModelUtils.checkValues
Code IndexAdd Tabnine to your IDE (free)

How to use
checkValues
method
in
org.apache.stanbol.entityhub.servicesapi.util.ModelUtils

Best Java code snippets using org.apache.stanbol.entityhub.servicesapi.util.ModelUtils.checkValues (Showing top 14 results out of 315)

origin: org.apache.stanbol/org.apache.stanbol.entityhub.core

@SuppressWarnings("unchecked")
@Override
public void remove(String field, Object parsedValue) {
  if(field == null){
    throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
  } else if(field.isEmpty()){
    throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
  }
  Collection<Object> removeValues = new ArrayList<Object>();
  ModelUtils.checkValues(valueFactory, parsedValue, removeValues);
  Object values = representation.get(field);
  if(values == null) {
    return;
  } else if(removeValues.contains(values)){
    //in case this field has a single value and this values is part of
    //the values to remove -> remove the whole field
    representation.remove(field);
  } else if(values instanceof Collection<?>){
    if(((Collection<Object>)values).removeAll(removeValues) && //remove all Elements
        ((Collection<Object>)values).size()<2){ //if removed check for size
      if(((Collection<Object>)values).size()==1){
        //only one element remaining -> replace the collection with a Object
        representation.put(field, ((Collection<Object>)values).iterator().next());
      } else {
        //if no element remains, remove the field
        representation.remove(field);
      }
    }
  } //else ignore (single value for field && value not to be removed)
}
origin: apache/stanbol

@SuppressWarnings("unchecked")
@Override
public void remove(String field, Object parsedValue) {
  if(field == null){
    throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
  } else if(field.isEmpty()){
    throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
  }
  Collection<Object> removeValues = new ArrayList<Object>();
  ModelUtils.checkValues(valueFactory, parsedValue, removeValues);
  Object values = representation.get(field);
  if(values == null) {
    return;
  } else if(removeValues.contains(values)){
    //in case this field has a single value and this values is part of
    //the values to remove -> remove the whole field
    representation.remove(field);
  } else if(values instanceof Collection<?>){
    if(((Collection<Object>)values).removeAll(removeValues) && //remove all Elements
        ((Collection<Object>)values).size()<2){ //if removed check for size
      if(((Collection<Object>)values).size()==1){
        //only one element remaining -> replace the collection with a Object
        representation.put(field, ((Collection<Object>)values).iterator().next());
      } else {
        //if no element remains, remove the field
        representation.remove(field);
      }
    }
  } //else ignore (single value for field && value not to be removed)
}
origin: org.apache.stanbol/org.apache.stanbol.entityhub.core

ModelUtils.checkValues(valueFactory, parsedValue, newValues);
Object values = representation.get(field);
if(values != null){
origin: apache/stanbol

ModelUtils.checkValues(valueFactory, parsedValue, newValues);
Object values = representation.get(field);
if(values != null){
origin: org.apache.stanbol/org.apache.stanbol.entityhub.servicesapi

} else if(value instanceof Iterable<?>){
  for(Object current : (Iterable<?>)value){
    checkValues(valueFactory,current,results);
    checkValues(valueFactory,((Iterator<?>)value).next(),results);
    checkValues(valueFactory,((Enumeration<?>)value).nextElement(),results);
origin: apache/stanbol

} else if(value instanceof Iterable<?>){
  for(Object current : (Iterable<?>)value){
    checkValues(valueFactory,current,results);
    checkValues(valueFactory,((Iterator<?>)value).next(),results);
    checkValues(valueFactory,((Enumeration<?>)value).nextElement(),results);
origin: apache/stanbol

ModelUtils.checkValues(factory, value, values);
origin: org.apache.stanbol/org.apache.stanbol.entityhub.model.clerezza

ModelUtils.checkValues(valueFactory, value, values);
origin: org.apache.stanbol/org.apache.stanbol.entityhub.model.sesame

ModelUtils.checkValues(factory, value, values);
origin: org.apache.stanbol/org.apache.stanbol.entityhub.model.sesame

ModelUtils.checkValues(factory, parsedValue, values);
for(Object value : values){
  if (value instanceof Value){ //native support for Sesame types!
origin: apache/stanbol

ModelUtils.checkValues(valueFactory, value, values);
origin: org.apache.stanbol/org.apache.stanbol.entityhub.model.clerezza

Collection<Object> removeValues = new ArrayList<Object>();
ModelUtils.checkValues(valueFactory, parsedValue, removeValues);
origin: apache/stanbol

Collection<Object> removeValues = new ArrayList<Object>();
ModelUtils.checkValues(valueFactory, parsedValue, removeValues);
origin: apache/stanbol

ModelUtils.checkValues(factory, parsedValue, values);
for(Object value : values){
  if (value instanceof Value){ //native support for Sesame types!
org.apache.stanbol.entityhub.servicesapi.utilModelUtilscheckValues

Javadoc

Processes a value parsed as object to the representation. This processing includes:
  • Removal of null values
  • Converting URIs and URLs to Reference
  • Converting String[] with at least a single entry where the first entry is not null to Text (the second entry is used as language. Further entries are ignored.
  • Recursive calling of this Method if a Iterable (any Array or Collection), Iterator or Enumeration is parsed.
  • All other Objects are added to the result list
TODO: Maybe we need to enable an option to throw IllegalArgumentExceptionin case any of the parsed values is invalid. Currently invalid values are just ignored.

Popular methods of ModelUtils

  • asCollection
    Copies all elements of the parsed Iterator to a ArrayList. To use other Set implementations that Arr
  • getRepresentationInfo
    String representation of the parsed Representation inteded for DEBUG level loggings.
  • addToCollection
    Adds the elements of the Iterator to the parsed Collection
  • getNamespaceLocalName
    Splits up a URI in local name and namespace based on the following rules * If URI starts with "u
  • asSet
    Copies all elements of the parsed Iterator to a HashSet. To use other Set implementations that HashS
  • addToSet
    Adds the elements of the Iterator to the parsed Set
  • getAboutRepresentation
    Getter for the id of the Entity the parsed Representationare RdfResourceEnum#aboutRepresentation.
  • randomUUID
    TODO: Maybe we need a better way to generate unique IDs

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getResourceAsStream (ClassLoader)
  • getExternalFilesDir (Context)
  • putExtra (Intent)
  • Permission (java.security)
    Legacy security code; do not use.
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now