Package java.util

Examples of java.util.SortedMap


    }
    }
 
  protected SortedMap getSortedProperties(String categoryName,Configuration configuration) {
        Properties props = configuration.getProperties(categoryName);
        SortedMap sm = new TreeMap();
        if (props != null) {
            Iterator nit = props.keySet().iterator();
            while (nit.hasNext()) {
                String name = (String) nit.next();
                String value = props.getProperty(name);
                sm.put(name,value);
            }
            return sm;
        }
        return null;
    }
View Full Code Here


      while (itEe.hasNext()) {
        final Map.Entry eE = (Map.Entry) itEe.next();
        final String pkgName = (String) eE.getKey();
        final Version pkgVersion = (Version) eE.getValue();

        SortedMap versions = (SortedMap) allExports.get(pkgName);
        if (null == versions) {
          versions = new TreeMap();
          allExports.put(pkgName, versions);
        }

        SortedSet exporters = (SortedSet) versions.get(pkgVersion);
        if (null == exporters) {
          exporters = new TreeSet();
          versions.put(pkgVersion, exporters);
        }
        exporters.add(ba);
      }
    }

    // For each bundle build the pkgProvidersMap
    for (Iterator itBa = allBundleArchives.iterator(); itBa.hasNext();) {
      final BundleArchive ba = (BundleArchive) itBa.next();

      final Iterator itIe = ba.pkgImportMap.entrySet().iterator();
      while (itIe.hasNext()) {
        final Map.Entry iE = (Map.Entry) itIe.next();
        final String pkgName = (String) iE.getKey();
        final VersionRange range = (VersionRange) iE.getValue();

        SortedMap versions = (SortedMap) allExports.get(pkgName);
        if (null != versions) {
          final Iterator itV = versions.entrySet().iterator();
          while (itV.hasNext()) {
            final Map.Entry vE = (Map.Entry) itV.next();
            final Version pkgVersion = (Version) vE.getKey();

            if (range.contains(pkgVersion)) {
View Full Code Here

        (MBeanAttributeMOTableInfo) getMBeanMOInfo(tableOID);
    if (mBeanInfo != null) {
      try {
        if (mBeanInfo.getKeyProvider() == null) {
          Set<ObjectInstance> mBeans = mBeanInfo.getMBeanNames(server);
          SortedMap indexes = new TreeMap();
          for (ObjectInstance mBean : mBeans) {
            Object key = mBeanInfo.getKey(server, mBean.getObjectName());
            OID index = mBeanInfo.getIndexSupport().mapToIndex(key);
            indexes.put(index, key);
          }
          return indexes.values().iterator();
        }
        else {
          MBeanAttributeKeyProvider keyProvider = mBeanInfo.getKeyProvider();
          return keyProvider.keyIterator(server);
        }
View Full Code Here

  {
    if (_sortedRows == null) {
      _sortedRows = new SortedMap[_rows.size()];

      for (int i = _rows.size() - 1; i >=0; i--) {
        SortedMap map = new TreeMap(String.CASE_INSENSITIVE_ORDER);
        _sortedRows[i] = map;
        Object []row = (Object []) _rows.get(i);

        for (int j = _columnNames.length - 1; j >= 0; j--)
          map.put(_columnNames[j], row[j]);
      }
    }

    return _sortedRows;
  }
View Full Code Here

     *
     * @param element
     * @return Returns the collection of attributes which are none namespace declarations
     */
    public Collection getAttributesWithoutNS(OMElement element) {
        SortedMap map = new TreeMap();
        Iterator itr = element.getAllAttributes();
        while (itr.hasNext()) {
            OMAttribute attribute = (OMAttribute) itr.next();
            if (!(attribute.getLocalName().equals("xmlns") ||
                    attribute.getLocalName().startsWith("xmlns:")))
                map.put(getExpandedName(attribute), attribute);
        }
        return map.values();
    }
View Full Code Here

*/
    if (HttpUtil.booleanVariableValue(in, "attributes", true)) {
      MBeanAttributeInfo[] attributes = info.getAttributes();
      if (attributes != null)
      {
        SortedMap sortedAttributes = new TreeMap();
        for (int i=0;i<attributes.length;i++)
        {
          Element attribute = document.createElement("Attribute");
          attribute.setAttribute("name", attributes[i].getName());
          attribute.setAttribute("type", attributes[i].getType());
          attribute.setAttribute("description", attributes[i].getDescription());
          attribute.setAttribute("strinit", String.valueOf(CommandProcessorUtil.canCreateParameterValue(attributes[i].getType())));
          if (attributes[i].isReadable() && attributes[i].isWritable())
          {
            attribute.setAttribute("availability", "RW");
          }
          if (attributes[i].isReadable() && !attributes[i].isWritable())
          {
            attribute.setAttribute("availability", "RO");
          }
          if (!attributes[i].isReadable() && attributes[i].isWritable())
          {
            attribute.setAttribute("availability", "WO");
          }
          try
          {
            Object attributeValue = server.getAttribute(objectName, attributes[i].getName());
            attribute.setAttribute("isnull", (attributeValue==null)?"true":"false");
            if (attributeValue != null)
            {
              attribute.setAttribute("value", attributeValue.toString());
              if (attributeValue.getClass().isArray())
              {
                attribute.setAttribute("aggregation", "array");
              }
              if (attributeValue instanceof java.util.Collection)
              {
                attribute.setAttribute("aggregation", "collection");
              }
              if (attributeValue instanceof java.util.Map)
              {
                attribute.setAttribute("aggregation", "map");
              }
            }
            else
            {
              attribute.setAttribute("value", "null");
            }

          }
          catch (JMException e)
          {
            attribute.setAttribute("value", e.getMessage());
          }
          sortedAttributes.put(attributes[i].getName(), attribute);
        }
        Iterator keys = sortedAttributes.keySet().iterator();
        while (keys.hasNext())
        {
          root.appendChild((Element)sortedAttributes.get(keys.next()));
        }
      }
    }
    if (HttpUtil.booleanVariableValue(in, "constructors", true))
    {
View Full Code Here

    {
      Map variables = in.getVariables();
      if (variables.containsKey("setall"))
      {
        Iterator keys = variables.keySet().iterator();
        SortedMap allAttributes = new TreeMap();
        while (keys.hasNext()) {
          String key = (String)keys.next();
          if (key.startsWith("value_"))
          {
            String attributeVariable = key.substring(6, key.length());
            String valueVariable = in.getVariable(key);
            Element attributeElement = setAttribute(document, attributeVariable, valueVariable, name);
            allAttributes.put(attributeVariable, attributeElement);
            operationElement.appendChild(attributeElement);
          }
        }
        keys = allAttributes.keySet().iterator();
        while (keys.hasNext()) {
          Element attributeElement = (Element)allAttributes.get(keys.next());
          operationElement.appendChild(attributeElement);
        }
      }
      else
      {
        Iterator keys = variables.keySet().iterator();
        SortedMap allAttributes = new TreeMap();
        while (keys.hasNext())
        {
          String key = (String)keys.next();
          if (key.startsWith("set_"))
          {
            String attributeVariable = key.substring(4, key.length());
            String valueVariable = in.getVariable("value_" + attributeVariable);
            Element attributeElement = setAttribute(document, attributeVariable, valueVariable, name);
            allAttributes.put(attributeVariable, attributeElement);
          }
        }
        keys = allAttributes.keySet().iterator();
        while (keys.hasNext()) {
          Element attributeElement = (Element)allAttributes.get(keys.next());
          operationElement.appendChild(attributeElement);
        }
      }
      //operationElement.setAttribute("result", "success");
    }
View Full Code Here

                Configuration[] configs = ca.listConfigurations(null);

                if (configs != null && configs.length > 0)
                {
                    Set factories = new HashSet();
                    SortedMap sm = new TreeMap();
                    for (int i = 0; i < configs.length; i++)
                    {
                        sm.put(configs[i].getPid(), configs[i]);
                        String fpid = configs[i].getFactoryPid();
                        if (null != fpid)
                        {
                            factories.add(fpid);
                        }
                    }
                    if (factories.isEmpty())
                    {
                        pw.println("Status: " + configs.length
                            + " configurations available");
                    }
                    else
                    {
                        pw.println("Status: " + configs.length + " configurations and "
                            + factories.size() + " factories available");
                    }
                    pw.println();

                    for (Iterator mi = sm.values().iterator(); mi.hasNext();)
                    {
                        this.printConfiguration(pw, (Configuration) mi.next());
                    }
                }
                else
View Full Code Here

    SortedMap getServices( String serviceClass, String serviceFilter, String locale,
        boolean ocdRequired ) throws InvalidSyntaxException
    {
        // sorted map of options
        SortedMap optionsFactory = new TreeMap( String.CASE_INSENSITIVE_ORDER );

        // find all ManagedServiceFactories to get the factoryPIDs
        ServiceReference[] refs = this.getBundleContext().getServiceReferences( serviceClass, serviceFilter );
        for ( int i = 0; refs != null && i < refs.length; i++ )
        {
            Object pidObject = refs[i].getProperty( Constants.SERVICE_PID );
            // only include valid PIDs
            if ( pidObject instanceof String && ConfigManager.isAllowedPid((String)pidObject) )
            {
                String pid = ( String ) pidObject;
                String name = pid;
                boolean haveOcd = !ocdRequired;
                final MetaTypeServiceSupport mtss = getMetaTypeSupport();
                if ( mtss != null )
                {
                    final ObjectClassDefinition ocd = mtss.getObjectClassDefinition( refs[i].getBundle(), pid, locale );
                    if ( ocd != null )
                    {
                        name = ocd.getName();
                        haveOcd = true;
                    }
                }

                if ( haveOcd )
                {
                    optionsFactory.put( pid, name );
                }
            }
        }

        return optionsFactory;
View Full Code Here

        assertEquals(m1.size(), m2.size());
        assertEquals(m1, m2);
   

    public void testCopySortedMaps() {
        SortedMap orig = new TreeMap();
        populate(orig);
        assertSortedMapsEqual(orig, (SortedMap) _mgr.copyMap(orig));

        orig = new TreeMap(new CustomComparator());
        populate(orig);
View Full Code Here

TOP

Related Classes of java.util.SortedMap

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.