Package jade.content.abs

Examples of jade.content.abs.AbsAggregate


  public AbsAggregate externalizeAggregate(String slotName, Object obj, ObjectSchema schema, Ontology referenceOnto) throws OntologyException {
    if (!(obj instanceof Collection)) {
      throw new NotAnAggregate();
    }
   
    AbsAggregate absAggregate = null;
    Collection c = (Collection) obj;
    if (!c.isEmpty() || schema.isMandatory(slotName)) {
      // Note that we ignore the aggregateType specified in the slot schema and we use SET for java.util.Set and SEQUENCE for java.util.List
      String aggregateType = null;
      if (obj instanceof List) {
View Full Code Here


    // FIXME: Here we should check for Long --> Integer casting, but how?
    return c;
  }

  private AbsAggregate externaliseCollection(Collection c, Ontology referenceOnto, String aggregateType) throws OntologyException {
    AbsAggregate ret = new AbsAggregate(aggregateType);

    try {
      Iterator it = c.iterator();
      while (it.hasNext()) {
        ret.add((AbsTerm)Ontology.externalizeSlotValue(it.next(), this, referenceOnto));
      }
    }
    catch (ClassCastException cce) {
      throw new OntologyException("Non term object in aggregate");
    }
View Full Code Here

    if (slotValue == null) {
      // This slot isn't an aggregate
      throw new NotAnAggregate();     
    }
   
    AbsAggregate absAggregate = null;
    Class valueClass = slotValue.getClass();
   
    // Check if slot is typized
    boolean slotTypized = false;
    if (schema != null) {
      SlotAccessData slotAccessData = accessors.get(new SlotKey(schema.getTypeName(), slotName));
      slotTypized = slotAccessData.isTypized();
    }

    // Try to manage as array
    if (valueClass.isArray() && valueClass != byte[].class) {
      // In the case of array and slot not typized --> throw exception
      // (Only java collection are permitted)
      if (!slotTypized) {
        throw new OntologyException("Impossible manage array into a not typized slot");
      }
     
      absAggregate = new AbsAggregate(BasicOntology.SEQUENCE);
      for (int i = 0; i < Array.getLength(slotValue); i++) {
        Object object = Array.get(slotValue, i);
        absAggregate.add((AbsTerm)Ontology.externalizeSlotValue(object, this, referenceOnto));
      }
    } else {
      Iterator iter;
      String aggregateType;
      if (slotValue instanceof java.util.Collection) {
        iter = ((java.util.Collection)slotValue).iterator();
        if (slotValue instanceof java.util.List) {
          aggregateType = BasicOntology.SEQUENCE;
        } else {
          aggregateType = BasicOntology.SET;
        }
      } else if (slotValue instanceof jade.util.leap.Collection) {
        // In the case of array and slot not typized --> throw exception
        // (Only java collection are permitted)
        if (!slotTypized) {
          throw new OntologyException("Impossible manage jade collection into a not typized slot");
        }

        iter = ((jade.util.leap.Collection)slotValue).iterator();
        if (slotValue instanceof jade.util.leap.List) {
          aggregateType = BasicOntology.SEQUENCE;
        } else {
          aggregateType = BasicOntology.SET;
        }
      } else {
        // This slot isn't an aggregate
        throw new NotAnAggregate();
      }
      if (iter.hasNext() || schema.isMandatory(slotName)) {
        absAggregate = new AbsAggregate(aggregateType);
        try {
          while (iter.hasNext()) {
            Object object = iter.next();
            absAggregate.add((AbsTerm)Ontology.externalizeSlotValue(object, this, referenceOnto));
          }
        } catch (ClassCastException cce) {
          throw new OntologyException("Non term object in aggregate");
        }
      }
View Full Code Here

TOP

Related Classes of jade.content.abs.AbsAggregate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.