예제 #1
0
  /**
   * Converts the form field values in the <tt>ffValuesIter</tt> into a caps string.
   *
   * @param ffValuesIter the {@link Iterator} containing the form field values.
   * @param capsBldr a <tt>StringBuilder</tt> to which the caps string representing the form field
   *     values is to be appended
   */
  private static void formFieldValuesToCaps(Iterator<String> ffValuesIter, StringBuilder capsBldr) {
    SortedSet<String> fvs = new TreeSet<String>();

    while (ffValuesIter.hasNext()) fvs.add(ffValuesIter.next());

    for (String fv : fvs) capsBldr.append(fv).append('<');
  }
예제 #2
0
 private void deleteJsonJobs(ApplicationInfo appInfo, List<CIJob> selectedJobs)
     throws PhrescoException {
   try {
     if (CollectionUtils.isEmpty(selectedJobs)) {
       return;
     }
     Gson gson = new Gson();
     List<CIJob> jobs = getJobs(appInfo);
     if (CollectionUtils.isEmpty(jobs)) {
       return;
     }
     // all values
     Iterator<CIJob> iterator = jobs.iterator();
     // deletable values
     for (CIJob selectedInfo : selectedJobs) {
       while (iterator.hasNext()) {
         CIJob itrCiJob = iterator.next();
         if (itrCiJob.getName().equals(selectedInfo.getName())) {
           iterator.remove();
           break;
         }
       }
     }
     writeJsonJobs(appInfo, jobs, CI_CREATE_NEW_JOBS);
   } catch (Exception e) {
     throw new PhrescoException(e);
   }
 }
예제 #3
0
  /**
   * Remove records telling what entity caps node a contact has.
   *
   * @param contact the contact
   */
  public void removeContactCapsNode(Contact contact) {
    Caps caps = null;
    String lastRemovedJid = null;

    Iterator<String> iter = userCaps.keySet().iterator();
    while (iter.hasNext()) {
      String jid = iter.next();

      if (StringUtils.parseBareAddress(jid).equals(contact.getAddress())) {
        caps = userCaps.get(jid);
        lastRemovedJid = jid;
        iter.remove();
      }
    }

    // fire only for the last one, at the end the event out
    // of the protocol will be one and for the contact
    if (caps != null) {
      UserCapsNodeListener[] listeners;
      synchronized (userCapsNodeListeners) {
        listeners = userCapsNodeListeners.toArray(NO_USER_CAPS_NODE_LISTENERS);
      }
      if (listeners.length != 0) {
        String nodeVer = caps.getNodeVer();

        for (UserCapsNodeListener listener : listeners)
          listener.userCapsNodeRemoved(lastRemovedJid, nodeVer, false);
      }
    }
  }
  /**
   * Closes given {@link #transportManagers} of this <tt>Conference</tt> and removes corresponding
   * channel bundle.
   */
  void closeTransportManager(TransportManager transportManager) {
    synchronized (transportManagers) {
      for (Iterator<IceUdpTransportManager> i = transportManagers.values().iterator();
          i.hasNext(); ) {
        if (i.next() == transportManager) {
          i.remove();
          // Presumably, we have a single association for
          // transportManager.
          break;
        }
      }

      // Close manager
      try {
        transportManager.close();
      } catch (Throwable t) {
        logger.warn(
            "Failed to close an IceUdpTransportManager of" + " conference " + getID() + "!", t);
        // The whole point of explicitly closing the
        // transportManagers of this Conference is to prevent memory
        // leaks. Hence, it does not make sense to possibly leave
        // TransportManagers open because a TransportManager has
        // failed to close.
        if (t instanceof InterruptedException) Thread.currentThread().interrupt();
        else if (t instanceof ThreadDeath) throw (ThreadDeath) t;
      }
    }
  }
 public void generate(JNIField field) {
   String name = field.getName();
   Iterator<File> keys = files.keySet().iterator();
   while (keys.hasNext()) {
     File key = keys.next();
     String str = files.get(key);
     if (str.indexOf(name) != -1) {
       int modifiers = field.getModifiers();
       String modifiersStr = Modifier.toString(modifiers);
       output("\t");
       output(modifiersStr);
       if (modifiersStr.length() > 0) output(" ");
       output(field.getType().getTypeSignature3(false));
       output(" ");
       output(field.getName());
       output(" = ");
       output(getFieldValue(field));
       outputln(";");
       usedCount++;
       return;
     }
   }
   unusedCount++;
   // output("NOT USED=" + field.toString() + " \n");
 }
예제 #6
0
  /**
   * Returns a map of MBeans with ObjectName as the key and MBeanInfo value of a given domain. If
   * domain is <tt>null</tt>, all MBeans are returned. If no MBean found, an empty map is returned.
   */
  public Map<ObjectName, MBeanInfo> getMBeans(String domain) throws IOException {

    ObjectName name = null;
    if (domain != null) {
      try {
        name = new ObjectName(domain + ":*");
      } catch (MalformedObjectNameException e) {
        // should not reach here
        assert (false);
      }
    }
    Set<ObjectName> mbeans = server.queryNames(name, null);
    Map<ObjectName, MBeanInfo> result = new HashMap<ObjectName, MBeanInfo>(mbeans.size());
    Iterator<ObjectName> iterator = mbeans.iterator();
    while (iterator.hasNext()) {
      Object object = iterator.next();
      if (object instanceof ObjectName) {
        ObjectName o = (ObjectName) object;
        try {
          MBeanInfo info = server.getMBeanInfo(o);
          result.put(o, info);
        } catch (IntrospectionException e) {
          // TODO: should log the error
        } catch (InstanceNotFoundException e) {
          // TODO: should log the error
        } catch (ReflectionException e) {
          // TODO: should log the error
        }
      }
    }
    return result;
  }
예제 #7
0
  public synchronized Collection<GarbageCollectorMXBean> getGarbageCollectorMXBeans()
      throws IOException {

    // TODO: How to deal with changes to the list??
    if (garbageCollectorMBeans == null) {
      ObjectName gcName = null;
      try {
        gcName = new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
      } catch (MalformedObjectNameException e) {
        // should not reach here
        assert (false);
      }
      Set<ObjectName> mbeans = server.queryNames(gcName, null);
      if (mbeans != null) {
        garbageCollectorMBeans = new ArrayList<GarbageCollectorMXBean>();
        Iterator<ObjectName> iterator = mbeans.iterator();
        while (iterator.hasNext()) {
          ObjectName on = (ObjectName) iterator.next();
          String name = GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=" + on.getKeyProperty("name");

          GarbageCollectorMXBean mBean =
              newPlatformMXBeanProxy(server, name, GarbageCollectorMXBean.class);
          garbageCollectorMBeans.add(mBean);
        }
      }
    }
    return garbageCollectorMBeans;
  }
  public ListIterator<ICFLibAnyObj> enumerateDetails(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFIterateNumberTypeRef.enumerateDetails() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext.getGenDef()");
    }

    List<ICFLibAnyObj> list = new LinkedList<ICFLibAnyObj>();

    if (genDef instanceof ICFBamNumberTypeObj) {
      Iterator<ICFBamTableColObj> elements =
          ((ICFBamNumberTypeObj) genDef).getOptionalChildrenRef().iterator();
      while (elements.hasNext()) {
        list.add(elements.next());
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), S_ProcName, "genContext.getGenDef()", genDef, "ICFBamNumberTypeObj");
    }

    return (list.listIterator());
  }
예제 #9
0
  public static int close() {
    int count = 0;

    Iterator iterator = m_notUsedConnection.iterator();
    while (iterator.hasNext()) {
      try {
        ((ConnectionWrapper) iterator.next()).close();
        count++;
      } catch (Exception e) {
      }
    }
    m_notUsedConnection.clear();

    iterator = m_usedUsedConnection.iterator();
    while (iterator.hasNext()) {
      try {
        ConnectionWrapper wrapper = (ConnectionWrapper) iterator.next();
        wrapper.close();
        if (DEBUG) {
          wrapper.debugInfo.printStackTrace();
        }
        count++;
      } catch (Exception e) {
      }
    }
    m_usedUsedConnection.clear();

    return count;
  }
예제 #10
0
  /**
   * This will invoke the <code>startElement</code> callback in the <code>ContentHandler</code>.
   *
   * @param element <code>Element</code> used in callbacks.
   * @param nsAtts <code>List</code> of namespaces to declare with the element or <code>null</code>.
   */
  private void startElement(Element element, Attributes nsAtts) throws JDOMException {
    String namespaceURI = element.getNamespaceURI();
    String localName = element.getName();
    String rawName = element.getQualifiedName();

    // Allocate attribute list.
    AttributesImpl atts = (nsAtts != null) ? new AttributesImpl(nsAtts) : new AttributesImpl();

    List attributes = element.getAttributes();
    Iterator i = attributes.iterator();
    while (i.hasNext()) {
      Attribute a = (Attribute) i.next();
      atts.addAttribute(
          a.getNamespaceURI(),
          a.getName(),
          a.getQualifiedName(),
          getAttributeTypeName(a.getAttributeType()),
          a.getValue());
    }

    try {
      contentHandler.startElement(namespaceURI, localName, rawName, atts);
    } catch (SAXException se) {
      throw new JDOMException("Exception in startElement", se);
    }
  }
예제 #11
0
  /**
   * Set the object to be edited.
   *
   * @param value The object to be edited.
   */
  public void setObject(Object value) {
    if (!(_type.isInstance(value))) {
      throw new IllegalArgumentException(value.getClass() + " is not of type " + _type);
    }
    _value = value;

    // Disable event generation.
    _squelchChangeEvents = true;

    // Iterate over each property, doing a lookup on the associated editor
    // and setting the editor's value to the value of the property.
    Iterator it = _prop2Editor.keySet().iterator();
    while (it.hasNext()) {
      PropertyDescriptor desc = (PropertyDescriptor) it.next();
      PropertyEditor editor = (PropertyEditor) _prop2Editor.get(desc);
      Method reader = desc.getReadMethod();
      if (reader != null) {
        try {
          Object val = reader.invoke(_value, null);
          editor.setValue(val);
        } catch (IllegalAccessException ex) {
          ex.printStackTrace();
        } catch (InvocationTargetException ex) {
          ex.getTargetException().printStackTrace();
        }
      }
    }

    // Enable event generation.
    _squelchChangeEvents = false;
  }
예제 #12
0
    public boolean hasNext() {
      if (nextProc != null) return true;
      else {
        if (!names.hasNext()) return false;
        else {
          String processorName = names.next();

          Processor processor;
          try {
            try {
              processor = (Processor) (processorCL.loadClass(processorName).newInstance());
            } catch (ClassNotFoundException cnfe) {
              log.error("proc.processor.not.found", processorName);
              return false;
            } catch (ClassCastException cce) {
              log.error("proc.processor.wrong.type", processorName);
              return false;
            } catch (Exception e) {
              log.error("proc.processor.cant.instantiate", processorName);
              return false;
            }
          } catch (ClientCodeException e) {
            throw e;
          } catch (Throwable t) {
            throw new AnnotationProcessingError(t);
          }
          nextProc = processor;
          return true;
        }
      }
    }
  public ListIterator<ICFLibAnyObj> enumerateDetails(MssCFGenContext genContext) {
    final String S_ProcName = "CFAsteriskMssCFIterateHostNodeConfFile.enumerateDetails() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext.getGenDef()");
    }

    List<ICFLibAnyObj> list = new LinkedList<ICFLibAnyObj>();

    if (genDef instanceof ICFAsteriskHostNodeObj) {
      Iterator<ICFAsteriskConfigurationFileObj> elements =
          ((ICFAsteriskHostNodeObj) genDef).getOptionalComponentsConfFile().iterator();
      while (elements.hasNext()) {
        list.add(elements.next());
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), S_ProcName, "genContext.getGenDef()", genDef, "ICFAsteriskHostNodeObj");
    }

    return (list.listIterator());
  }
  public ListIterator<ICFLibAnyObj> enumerateDetails(MssCFGenContext genContext) {
    final String S_ProcName = "CFInternetMssCFIterateTSecGroupIncByGroup.enumerateDetails() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), S_ProcName, 1, "genContext.getGenDef()");
    }

    List<ICFLibAnyObj> list = new LinkedList<ICFLibAnyObj>();

    if (genDef instanceof ICFInternetTSecGroupObj) {
      Iterator<ICFSecurityTSecGroupIncludeObj> elements =
          ((ICFInternetTSecGroupObj) genDef).getRequiredChildrenIncByGroup().iterator();
      while (elements.hasNext()) {
        list.add(elements.next());
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), S_ProcName, "genContext.getGenDef()", genDef, "ICFInternetTSecGroupObj");
    }

    return (list.listIterator());
  }
예제 #15
0
    /**
     * Print this EmitterSet readably.
     *
     * @return a string describing this EmitterSet
     */
    public String toString() {
      StringBuffer s = new StringBuffer();
      s.append("Emitter Set of:\n");
      Iterator<EmitterDescriptor> i = emitters.iterator();
      while (i.hasNext()) s.append(i.next().toString() + "\n");

      s.append("-------------\n");
      return s.toString();
    }
예제 #16
0
 /**
  * Run all remaining processors on the procStateList that have not already run this round with
  * an empty set of annotations.
  */
 public void runContributingProcs(RoundEnvironment re) {
   if (!onProcInterator) {
     Set<TypeElement> emptyTypeElements = Collections.emptySet();
     while (innerIter.hasNext()) {
       ProcessorState ps = innerIter.next();
       if (ps.contributed) callProcessor(ps.processor, emptyTypeElements, re);
     }
   }
 }
예제 #17
0
  /**
   * Returns whether the following token exists.
   *
   * @return result
   */
  private boolean more() {
    if (all) return tokens.hasNext();

    while (tokens.hasNext()) {
      currToken = tokens.next();
      if (!currToken.isMark() && !currToken.isAttachedWord()) return true;
    }
    return false;
  }
예제 #18
0
 public boolean testSizeAddAnother() {
   description = "add increases size by 1 if already in";
   Iterator it = c.iterator();
   precondition = new Boolean(it.hasNext());
   Object e = it.hasNext() ? it.next() : new Object();
   int s = c.size();
   c.add(e);
   return c.size() == s + 1;
 }
예제 #19
0
  boolean closeAndRemoveResourcesInSet(Set s, Method closeMethod) {
    boolean okay = true;

    Set temp;
    synchronized (s) {
      temp = new HashSet(s);
    }

    for (Iterator ii = temp.iterator(); ii.hasNext(); ) {
      Object rsrc = ii.next();
      try {
        closeMethod.invoke(rsrc, CLOSE_ARGS);
      } catch (Exception e) {
        Throwable t = e;
        if (t instanceof InvocationTargetException)
          t = ((InvocationTargetException) e).getTargetException();
        logger.log(MLevel.WARNING, "An exception occurred while cleaning up a resource.", t);
        // t.printStackTrace();
        okay = false;
      } finally {
        s.remove(rsrc);
      }
    }

    // We had to abandon the idea of simply iterating over s directly, because
    // our resource close methods sometimes try to remove the resource from
    // its parent Set. This is important (when the user closes the resources
    // directly), but leads to ConcurrenModificationExceptions while we are
    // iterating over the Set to close. So, now we iterate over a copy, but remove
    // from the original Set. Since removal is idempotent, it don't matter if
    // the close method already provoked a remove. Sucks that we have to copy
    // the set though.
    //
    // Original (direct iteration) version:
    //
    //  	synchronized (s)
    //  	    {
    //  		for (Iterator ii = s.iterator(); ii.hasNext(); )
    //  		    {
    //  			Object rsrc = ii.next();
    //  			try
    //  			    { closeMethod.invoke(rsrc, CLOSE_ARGS); }
    //  			catch (Exception e)
    //  			    {
    //  				Throwable t = e;
    //  				if (t instanceof InvocationTargetException)
    //  				    t = ((InvocationTargetException) e).getTargetException();
    //  				t.printStackTrace();
    //  				okay = false;
    //  			    }
    //  			finally
    //  			    { ii.remove(); }
    //  		    }
    //  	    }

    return okay;
  }
예제 #20
0
 /** Convert the attributes in the given XML Element into a Map of name/value pairs. */
 protected static Map createAttributeMap(Element el) {
   Log.debug("Creating attribute map for " + el);
   Map attributes = new HashMap();
   Iterator iter = el.getAttributes().iterator();
   while (iter.hasNext()) {
     Attribute att = (Attribute) iter.next();
     attributes.put(att.getName(), att.getValue());
   }
   return attributes;
 }
예제 #21
0
  private void doSetBindings(ELContext elContext, UIComponent component) {
    if (component == null) return;

    ValueExpression binding = component.getValueExpression("binding");

    if (binding != null) binding.setValue(elContext, component);

    Iterator<UIComponent> iter = component.getFacetsAndChildren();
    while (iter.hasNext()) doSetBindings(elContext, iter.next());
  }
예제 #22
0
 public boolean isChildOf(Keyword word) {
   Iterator parents = getParentIterator();
   while (parents.hasNext()) {
     Keyword par = (Keyword) parents.next();
     if (par == null) return (false);
     else if (par.equals(word)) return (true);
     else return (par.isChildOf(word));
   }
   return false;
 }
예제 #23
0
  /**
   * Given an IA32 opcode, return the set of opt compiler IA32_ operators that translate to it.
   * There is, by and large, a one-to-one mapping in each each IA332_ opt operator represents an
   * IA32 opcde, so this method might seem useless. However, there are some special cases, notably
   * for operand size. In this case, an opt operator of the form ADD__B would mean use the ADD IA32
   * opcode with a byte operand size.
   */
  private static Set<String> getMatchingOperators(String lowLevelOpcode) {
    Iterator<String> e = OperatorFormatTables.getOpcodes();
    Set<String> matchingOperators = new HashSet<String>();
    while (e.hasNext()) {
      String o = (String) e.next();
      if (o.equals(lowLevelOpcode) || o.startsWith(lowLevelOpcode + "__")) matchingOperators.add(o);
    }

    return matchingOperators;
  }
예제 #24
0
  /**
   * returns a list of all IA32_ opt compiler operators that do not correspond to real IA32 opcodes
   * handled by the assembler. These are all supposed to have been removed by the time the assembler
   * is called, so the assembler actually seeing such an opcode is an internal compiler error. This
   * set is used during generating of error checking code.
   *
   * @param emittedOpcodes the set of IA32 opcodes the assembler understands.
   * @return the set of IA32 opt operators that the assembler does not understand.
   */
  private static Set<String> getErrorOpcodes(Set<String> emittedOpcodes) {
    Iterator<String> e = OperatorFormatTables.getOpcodes();
    Set<String> errorOpcodes = new HashSet<String>();
    while (e.hasNext()) {
      String opcode = (String) e.next();
      if (!emittedOpcodes.contains(opcode)) errorOpcodes.add(opcode);
    }

    return errorOpcodes;
  }
예제 #25
0
 public static void batchRelateAll(
     ModelRoot modelRoot, boolean notifyChanges, boolean searchAllRoots, boolean relateProxies) {
   InstanceList instances = modelRoot.getInstanceList(InformalArgument_c.class);
   synchronized (instances) {
     Iterator<NonRootModelElement> cursor = instances.iterator();
     while (cursor.hasNext()) {
       final InformalArgument_c inst = (InformalArgument_c) cursor.next();
       inst.batchRelate(modelRoot, relateProxies, notifyChanges, searchAllRoots);
     }
   }
 }
예제 #26
0
 private void nudge() {
   for (Iterator<RecorderEvent> iter = pendingEvents.iterator(); iter.hasNext(); ) {
     RecorderEvent ev = iter.next();
     long instant = getSynchronizer().getLocalTime(ev.getSsrc(), ev.getRtpTimestamp());
     if (instant != -1) {
       iter.remove();
       ev.setInstant(instant);
       handler.handleEvent(ev);
     }
   }
 }
예제 #27
0
  /**
   * Fire a property change event to each listener.
   *
   * @param bean Bean being edited.
   * @param propName Name of the property.
   * @param oldValue Old value.
   * @param newValue New value.
   */
  protected void firePropertyChange(
      Object bean, String propName, Object oldValue, Object newValue) {

    PropertyChangeEvent e = new PropertyChangeEvent(bean, propName, oldValue, newValue);

    Iterator it = _changeListeners.iterator();
    while (it.hasNext()) {
      PropertyChangeListener l = (PropertyChangeListener) it.next();
      l.propertyChange(e);
    }
  }
예제 #28
0
파일: Macro.java 프로젝트: bramk/bnd
  String filter(String[] args, boolean include) {
    verifyCommand(args, String.format(_filterHelp, args[0]), null, 3, 3);

    Collection<String> list = new ArrayList<String>(Processor.split(args[1]));
    Pattern pattern = Pattern.compile(args[2]);

    for (Iterator<String> i = list.iterator(); i.hasNext(); ) {
      if (pattern.matcher(i.next()).matches() == include) i.remove();
    }
    return Processor.join(list);
  }
  /** Closes the {@link #transportManagers} of this <tt>Conference</tt>. */
  private void closeTransportManagers() {
    synchronized (transportManagers) {
      for (Iterator<IceUdpTransportManager> i = transportManagers.values().iterator();
          i.hasNext(); ) {
        IceUdpTransportManager transportManager = i.next();

        i.remove();
        closeTransportManager(transportManager);
      }
    }
  }
예제 #30
0
 public boolean testSizeRemove() {
   description = "remove decreases size by 1";
   Iterator it = c.iterator();
   precondition = new Boolean(it.hasNext());
   Object e = it.hasNext() ? it.next() : new Object();
   // precondition = new Boolean(c.contains(e));
   // precondition = Boolean.TRUE;
   int s = c.size();
   c.remove(e);
   return c.size() == s - 1;
 }