Examples of Bag


Examples of com.hp.hpl.jena.rdf.model.Bag

    Object obj;
    if (value instanceof Collection) {
      Collection collection = (Collection) value;
      if (collection.isEmpty()) return;
      Bag bag = model.createBag(uri + "_" + property.getLocalName() + "_bag");
      for (Iterator i = collection.iterator(); i.hasNext();)
        bag.add(i.next());
      resource.addProperty(property, bag);
      obj = bag;
    } else {
      resource.addProperty(property, value.toString());
      obj = value;
    }

    Resource reification = model.createResource(uri + "_" + property.getLocalName() + "_reification");

    reification.addProperty(rdfSubject, resource);
    reification.addProperty(rdfPredicate, property);
    reification.addProperty(rdfObject, obj.toString());
    reification.addProperty(rdfType, rdfStatement);

    addPotentiallyNullReifiedStatement(reification, edmID, profAttr.getVersion());
    addPotentiallyNullReifiedStatement(reification, edmVersion, profAttr.getVersion());
    addPotentiallyNullReifiedStatement(reification, edmType, profAttr.getType());
    addPotentiallyNullReifiedStatement(reification, edmStatus, profAttr.getStatusID());
    addPotentiallyNullReifiedStatement(reification, edmSecurity, profAttr.getSecurityType());
    addPotentiallyNullReifiedStatement(reification, edmParent, profAttr.getParent());
    addPotentiallyNullReifiedStatement(reification, edmRegAuth, profAttr.getRegAuthority());

    List children = profAttr.getChildren();
    if (!children.isEmpty()) {
      Bag bag = model.createBag(uri + "_" + property.getLocalName() + "_childrenBag");
      for (Iterator i = children.iterator(); i.hasNext();)
        bag.add(i.next());
      reification.addProperty(edmChild, bag);
    }

    List revNotes = profAttr.getRevisionNotes();
    if (!revNotes.isEmpty()) {
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Bag

        // http://technet.microsoft.com/en-us/library/ms188059.aspx

        Collection<Object> invalidate = new ArrayList<Object>();
        ObjectContext context = runtime.getContext();

        Bag b1 = context.newObject(Bag.class);
        invalidate.add(b1);
        b1.setName("b1");

        Box bx1 = context.newObject(Box.class);
        invalidate.add(bx1);
        bx1.setName("big");
        bx1.setBag(b1);
View Full Code Here

Examples of org.apache.commons.collections.Bag

   */
  public static List enumObjectItems(String objectName, boolean english)
  {
    if (english)
      objectName = translate(objectName);
    Bag bag = new HashBag();
    int pdhStatus = Pdhdll.ERROR_SUCCESS;
    Memory szCounterListBuffer = null;
    IntByReference dwCounterListSize = new IntByReference();
    Memory szInstanceListBuffer = null;
    IntByReference dwInstanceListSize = new IntByReference();
    String szThisInstance = null;

    // Determine the required buffer size for the data.
    pdhStatus = Pdhdll.INSTANCE.PdhEnumObjectItemsA(null, // real time
        // source
        null, // local machine
        objectName, // object to enumerate
        szCounterListBuffer, // pass NULL and 0
        dwCounterListSize, // to get length required
        szInstanceListBuffer, // buffer size
        dwInstanceListSize, //
        Pdhdll.PERF_DETAIL_WIZARD, // counter detail level
        0);

    if (pdhStatus == Pdhdll.PDH_MORE_DATA)
    {
      // Allocate the buffers and try the call again.
      szCounterListBuffer = new Memory(dwCounterListSize.getValue() * 4);
      szInstanceListBuffer = new Memory((dwInstanceListSize.getValue() * 4));

      if ((szCounterListBuffer != null) && (szInstanceListBuffer != null))
      {
        pdhStatus = Pdhdll.INSTANCE.PdhEnumObjectItemsA(null, // real
            // time
            // source
            null, // local machine
            objectName, // object to enumerate
            szCounterListBuffer, // buffer to receive counter
            // list
            dwCounterListSize, szInstanceListBuffer, // buffer to
            // receive
            // instance
            // list
            dwInstanceListSize, Pdhdll.PERF_DETAIL_WIZARD, // counter
            // detail
            // level
            0);

        if (pdhStatus == Pdhdll.ERROR_SUCCESS)
        {
          // System.out.println ("Enumerating Processes:");

          // Walk the instance list. The list can contain one
          // or more null-terminated strings. The last string
          // is followed by a second null-terminator.
          int i = 0;
          for (szThisInstance = szInstanceListBuffer.getString(0); szThisInstance != null && szThisInstance.length() > 0; i += szThisInstance
              .length() + 1, szThisInstance = szInstanceListBuffer.getString(i))
          {
            // System.out.println( szThisInstance);
            bag.add(szThisInstance);

          }
        }
        else
        {
          System.out.println("PdhEnumObjectItems failed with " + Integer.toHexString(pdhStatus));
        }
      }
      else
      {
        System.out.println("Unable to allocate buffers");
        // pdhStatus = ERROR_OUTOFMEMORY;
      }

    }
    else
    {
      System.out.println("PdhEnumObjectItems failed with " + Integer.toHexString(pdhStatus));
    }

    List result = new ArrayList();
    for (Iterator it = bag.uniqueSet().iterator(); it.hasNext();)
    {
      String str = (String) it.next();
      result.add(str);
      // System.out.println(str);
      for (int i = 1; i < bag.getCount(str); i++)
      {
        result.add(str + "#" + i);
        // System.out.println(str+"#"+i);
      }
    }
View Full Code Here

Examples of org.apache.commons.collections.Bag

    public Bag makeBag() {
        return TransformedSortedBag.decorate(new TreeBag(), TestTransformedCollection.NOOP_TRANSFORMER);
    }

    public void testTransformedBag() {
        Bag bag = TransformedSortedBag.decorate(new TreeBag(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
        assertEquals(0, bag.size());
        Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
        for (int i = 0; i < els.length; i++) {
            bag.add(els[i]);
            assertEquals(i + 1, bag.size());
            assertEquals(true, bag.contains(new Integer((String) els[i])));
        }
       
        assertEquals(true, bag.remove(new Integer((String) els[0])));
       
    }
View Full Code Here

Examples of org.apache.commons.collections.Bag

     * @param other  the bag to retain
     * @return <code>true</code> if this call changed the collection
     */
    boolean retainAll(Bag other) {
        boolean result = false;
        Bag excess = new HashBag();
        Iterator i = uniqueSet().iterator();
        while (i.hasNext()) {
            Object current = i.next();
            int myCount = getCount(current);
            int otherCount = other.getCount(current);
            if (1 <= otherCount && otherCount <= myCount) {
                excess.add(current, myCount - otherCount);
            } else {
                excess.add(current, myCount);
            }
        }
        if (!excess.isEmpty()) {
            result = removeAll(excess);
        }
        return result;
    }
View Full Code Here

Examples of org.apache.commons.collections.Bag

            return true;
        }
        if (object instanceof Bag == false) {
            return false;
        }
        Bag other = (Bag) object;
        if (other.size() != size()) {
            return false;
        }
        for (Iterator it = map.keySet().iterator(); it.hasNext();) {
            Object element = it.next();
            if (other.getCount(element) != getCount(element)) {
                return false;
            }
        }
        return true;
    }
View Full Code Here

Examples of org.apache.commons.collections.Bag

        assertEquals(total, bag2.hashCode());
    }

    //-----------------------------------------------------------------------
    public void testEmptyBagSerialization() throws IOException, ClassNotFoundException {
        Bag bag = makeBag();
        if (!(bag instanceof Serializable && isTestSerialization())) return;
       
        byte[] objekt = writeExternalFormToBytes((Serializable) bag);
        Bag bag2 = (Bag) readExternalFormFromBytes(objekt);

        assertEquals("Bag should be empty",0, bag.size());
        assertEquals("Bag should be empty",0, bag2.size());
    }
View Full Code Here

Examples of org.apache.commons.collections.Bag

        assertEquals("Bag should be empty",0, bag.size());
        assertEquals("Bag should be empty",0, bag2.size());
    }

    public void testFullBagSerialization() throws IOException, ClassNotFoundException {
        Bag bag = makeBag();
        bag.add("A");
        bag.add("A");
        bag.add("B");
        bag.add("B");
        bag.add("C");
        int size = bag.size();
        if (!(bag instanceof Serializable && isTestSerialization())) return;
       
        byte[] objekt = writeExternalFormToBytes((Serializable) bag);
        Bag bag2 = (Bag) readExternalFormFromBytes(objekt);

        assertEquals("Bag should be same size", size, bag.size());
        assertEquals("Bag should be same size", size, bag2.size());
    }
View Full Code Here

Examples of org.apache.commons.collections.Bag

     * Compare the current serialized form of the Bag
     * against the canonical version in CVS.
     */
    public void testEmptyBagCompatibility() throws IOException, ClassNotFoundException {
        // test to make sure the canonical form has been preserved
        Bag bag = makeBag();
        if(bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
            Bag bag2 = (Bag) readExternalFormFromDisk(getCanonicalEmptyCollectionName(bag));
            assertTrue("Bag is empty",bag2.size()  == 0);
            assertEquals(bag, bag2);
        }
    }
View Full Code Here

Examples of org.apache.commons.collections.Bag

     * Compare the current serialized form of the Bag
     * against the canonical version in CVS.
     */
    public void testFullBagCompatibility() throws IOException, ClassNotFoundException {
        // test to make sure the canonical form has been preserved
        Bag bag = makeBag();
        bag.add("A");
        bag.add("A");
        bag.add("B");
        bag.add("B");
        bag.add("C");
        if(bag instanceof Serializable && !skipSerializedCanonicalTests() && isTestSerialization()) {
            Bag bag2 = (Bag) readExternalFormFromDisk(getCanonicalFullCollectionName(bag));
            assertEquals("Bag is the right size",bag.size(), bag2.size());
            assertEquals(bag, bag2);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.