Esempio n. 1
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;
  }
Esempio n. 2
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;
 }
Esempio n. 3
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;
  }
Esempio n. 4
0
 public <T extends Anim> void clearanims(Class<T> type) {
   for (Iterator<Anim> i = nanims.iterator(); i.hasNext(); ) {
     Anim a = i.next();
     if (type.isInstance(a)) i.remove();
   }
   for (Iterator<Anim> i = anims.iterator(); i.hasNext(); ) {
     Anim a = i.next();
     if (type.isInstance(a)) i.remove();
   }
 }
Esempio n. 5
0
  /**
   * Method for resolving member method information: aggregating all non-static methods and
   * combining annotations (to implement method-annotation inheritance)
   *
   * @param collectIgnored Whether to collect list of ignored methods for later retrieval
   */
  public void resolveMemberMethods(MethodFilter methodFilter, boolean collectIgnored) {
    _memberMethods = new AnnotatedMethodMap();
    AnnotatedMethodMap mixins = new AnnotatedMethodMap();
    // first: methods from the class itself
    _addMemberMethods(_class, methodFilter, _memberMethods, _primaryMixIn, mixins);

    // and then augment these with annotations from super-types:
    for (Class<?> cls : _superTypes) {
      Class<?> mixin = (_mixInResolver == null) ? null : _mixInResolver.findMixInClassFor(cls);
      _addMemberMethods(cls, methodFilter, _memberMethods, mixin, mixins);
    }
    // Special case: mix-ins for Object.class? (to apply to ALL classes)
    if (_mixInResolver != null) {
      Class<?> mixin = _mixInResolver.findMixInClassFor(Object.class);
      if (mixin != null) {
        _addMethodMixIns(methodFilter, _memberMethods, mixin, mixins);
      }
    }

    /* Any unmatched mix-ins? Most likely error cases (not matching
     * any method); but there is one possible real use case:
     * exposing Object#hashCode (alas, Object#getClass can NOT be
     * exposed, see [JACKSON-140])
     */
    if (!mixins.isEmpty()) {
      Iterator<AnnotatedMethod> it = mixins.iterator();
      while (it.hasNext()) {
        AnnotatedMethod mixIn = it.next();
        try {
          Method m = Object.class.getDeclaredMethod(mixIn.getName(), mixIn.getParameterClasses());
          if (m != null) {
            AnnotatedMethod am = _constructMethod(m);
            _addMixOvers(mixIn.getAnnotated(), am, false);
            _memberMethods.add(am);
          }
        } catch (Exception e) {
        }
      }
    }

    /* And last but not least: let's remove all methods that are
     * deemed to be ignorable after all annotations have been
     * properly collapsed.
     */
    Iterator<AnnotatedMethod> it = _memberMethods.iterator();
    while (it.hasNext()) {
      AnnotatedMethod am = it.next();
      if (_annotationIntrospector.isIgnorableMethod(am)) {
        it.remove();
        if (collectIgnored) {
          _ignoredMethods = ArrayBuilders.addToList(_ignoredMethods, am);
        }
      }
    }
  }
Esempio n. 6
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;
 }
Esempio n. 7
0
  /**
   * Returns an array containing all installed providers that satisfy the specified* selection
   * criteria, or null if no such providers have been installed. The returned providers are ordered
   * according to their <a href= "#insertProviderAt(java.security.Provider, int)">preference
   * order</a>.
   *
   * <p>The selection criteria are represented by a map. Each map entry represents a selection
   * criterion. A provider is selected iff it satisfies all selection criteria. The key for any
   * entry in such a map must be in one of the following two formats:
   *
   * <ul>
   *   <li><i>&lt;crypto_service>.&lt;algorithm_or_type></i>
   *       <p>The cryptographic service name must not contain any dots.
   *       <p>The value associated with the key must be an empty string.
   *       <p>A provider satisfies this selection criterion iff the provider implements the
   *       specified algorithm or type for the specified cryptographic service.
   *   <li><i>&lt;crypto_service>.&lt;algorithm_or_type> &lt;attribute_name></i>
   *       <p>The cryptographic service name must not contain any dots. There must be one or more
   *       space charaters between the <i>&lt;algorithm_or_type></i> and the
   *       <i>&lt;attribute_name></i>.
   *       <p>The value associated with the key must be a non-empty string. A provider satisfies
   *       this selection criterion iff the provider implements the specified algorithm or type for
   *       the specified cryptographic service and its implementation meets the constraint expressed
   *       by the specified attribute name/value pair.
   * </ul>
   *
   * <p>See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java
   * Cryptogaphy Architecture API Specification &amp; Reference </a> for information about standard
   * cryptographic service names, standard algorithm names and standard attribute names.
   *
   * @param filter the criteria for selecting providers. The filter is case-insensitive.
   * @return all the installed providers that satisfy the selection criteria, or null if no such
   *     providers have been installed.
   * @throws InvalidParameterException if the filter is not in the required format
   * @throws NullPointerException if filter is null
   * @see #getProviders(java.lang.String)
   */
  public static Provider[] getProviders(Map<String, String> filter) {
    // Get all installed providers first.
    // Then only return those providers who satisfy the selection criteria.
    Provider[] allProviders = Security.getProviders();
    Set keySet = filter.keySet();
    LinkedHashSet candidates = new LinkedHashSet(5);

    // Returns all installed providers
    // if the selection criteria is null.
    if ((keySet == null) || (allProviders == null)) {
      return allProviders;
    }

    boolean firstSearch = true;

    // For each selection criterion, remove providers
    // which don't satisfy the criterion from the candidate set.
    for (Iterator ite = keySet.iterator(); ite.hasNext(); ) {
      String key = (String) ite.next();
      String value = (String) filter.get(key);

      LinkedHashSet newCandidates = getAllQualifyingCandidates(key, value, allProviders);
      if (firstSearch) {
        candidates = newCandidates;
        firstSearch = false;
      }

      if ((newCandidates != null) && !newCandidates.isEmpty()) {
        // For each provider in the candidates set, if it
        // isn't in the newCandidate set, we should remove
        // it from the candidate set.
        for (Iterator cansIte = candidates.iterator(); cansIte.hasNext(); ) {
          Provider prov = (Provider) cansIte.next();
          if (!newCandidates.contains(prov)) {
            cansIte.remove();
          }
        }
      } else {
        candidates = null;
        break;
      }
    }

    if ((candidates == null) || (candidates.isEmpty())) return null;

    Object[] candidatesArray = candidates.toArray();
    Provider[] result = new Provider[candidatesArray.length];

    for (int i = 0; i < result.length; i++) {
      result[i] = (Provider) candidatesArray[i];
    }

    return result;
  }
 public String getDocString() {
   StringBuffer buf = new StringBuffer();
   buf.append("Example data: ");
   for (Iterator<String> it = sampleStrs.iterator(); it.hasNext(); ) {
     String tokStr = it.next();
     buf.append("'" + tokStr + "'");
     if (it.hasNext()) {
       buf.append(", ");
     }
   }
   return buf.toString();
 }
Esempio n. 9
0
 public static Class<?> commonSubType(Collection<?> objects) {
   Iterator<?> iterator = objects.iterator();
   if (!iterator.hasNext()) return null;
   Class<?> result = null;
   while (iterator.hasNext()) {
     Object candidate = iterator.next();
     if (candidate != null) {
       Class<?> candidateClass = candidate.getClass();
       if (result == null) result = candidateClass;
       else if (candidateClass != result && result.isAssignableFrom(candidateClass))
         result = candidateClass;
     }
   }
   return result;
 }
Esempio n. 10
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;
  }
  /**
   * 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;
      }
    }
  }
Esempio n. 12
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;
  }
Esempio n. 13
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);
    }
  }
    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;
        }
      }
    }
Esempio n. 15
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);
      }
    }
  }
Esempio n. 16
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('<');
  }
Esempio n. 17
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);
   }
 }
  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());
  }
Esempio n. 19
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;
  }
  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 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");
 }
  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());
  }
Esempio n. 23
0
  /**
   * ** Prints all the default values from <code>RTKey</code> and {@link RTConfig} ** to the
   * specified <code>PrintStream</code>. Used for debugging/testing ** @param out The <code>
   * PrintStream</code>
   */
  public static void printDefaults(PrintStream out) {

    /* print standard runtime entries */
    Set<String> keyList = new OrderedSet<String>();
    String keyGrp = null;

    for (Iterator<Entry> v = RTKey.getRuntimeEntryMap().values().iterator(); v.hasNext(); ) {
      Entry rtk = v.next();
      if (rtk.isHelp()) {
        out.println("");
        out.println("# ===== " + rtk.getHelp());
      } else {
        Object dft = rtk.getDefault();
        out.println("# --- " + rtk.getHelp());
        out.println("# " + rtk.toString(dft));
        String key = rtk.getKey();
        keyList.add(key);
        if (!key.equals(CONFIG_FILE) && RTConfig.hasProperty(key)) {
          String val = RTConfig.getString(key, null);
          // if ((val != null) && ((dft == null) || !val.equals(dft.toString()))) {
          out.println(rtk.toString(val));
          // }
        }
      }
    }

    /* orphaned entries */
    RTProperties cmdLineProps = RTConfig.getConfigFileProperties();
    if (cmdLineProps != null) {
      boolean orphanHeader = false;
      for (Iterator i = cmdLineProps.keyIterator(); i.hasNext(); ) {
        Object k = i.next();
        if (!k.equals(COMMAND_LINE_CONF) && !keyList.contains(k)) {
          if (!orphanHeader) {
            out.println("");
            out.println("# ===== Other entries");
            orphanHeader = true;
          }
          Object v = cmdLineProps.getProperty(k, null);
          out.println(k + "=" + ((v != null) ? v : NULL_VALUE));
        }
      }
    }

    /* final blank line */
    out.println("");
  }
  public String[] getCleanSql() {
    if (cleanSql == null) {
      // loop over all foreign key constraints
      List dropForeignKeysSql = new ArrayList();
      List createForeignKeysSql = new ArrayList();
      Iterator iter = configuration.getTableMappings();
      while (iter.hasNext()) {
        Table table = (Table) iter.next();
        if (table.isPhysicalTable()) {
          Iterator subIter = table.getForeignKeyIterator();
          while (subIter.hasNext()) {
            ForeignKey fk = (ForeignKey) subIter.next();
            if (fk.isPhysicalConstraint()) {
              // collect the drop key constraint
              dropForeignKeysSql.add(
                  fk.sqlDropString(
                      dialect,
                      properties.getProperty(Environment.DEFAULT_CATALOG),
                      properties.getProperty(Environment.DEFAULT_SCHEMA)));
              createForeignKeysSql.add(
                  fk.sqlCreateString(
                      dialect,
                      mapping,
                      properties.getProperty(Environment.DEFAULT_CATALOG),
                      properties.getProperty(Environment.DEFAULT_SCHEMA)));
            }
          }
        }
      }

      List deleteSql = new ArrayList();
      iter = configuration.getTableMappings();
      while (iter.hasNext()) {
        Table table = (Table) iter.next();
        deleteSql.add("delete from " + table.getName());
      }

      List cleanSqlList = new ArrayList();
      cleanSqlList.addAll(dropForeignKeysSql);
      cleanSqlList.addAll(deleteSql);
      cleanSqlList.addAll(createForeignKeysSql);

      cleanSql = (String[]) cleanSqlList.toArray(new String[cleanSqlList.size()]);
    }
    return cleanSql;
  }
Esempio n. 25
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;
  }
 /**
  * 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);
     }
   }
 }
    /**
     * 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();
    }
Esempio n. 28
0
  private void load_snap_from_xml(Element snap, StructureCollection structs, LinkedList tempList)
      throws VisualizerLoadException {
    Iterator iterator = snap.getChildren().iterator();

    if (!iterator.hasNext()) throw new VisualizerLoadException("Ran out of elements");

    structs.loadTitle((Element) (iterator.next()), tempList, this);
    structs.calcDimsAndStartPts(tempList, this);

    if (!iterator.hasNext()) return;
    Element child = (Element) iterator.next();

    if (child.getName().compareTo("doc_url") == 0) {
      // load the doc_url
      add_a_documentation_URL(child.getText().trim());
      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    if (child.getName().compareTo("pseudocode_url") == 0) {
      // load the psuedocode_url
      add_a_pseudocode_URL(child.getText().trim());
      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    if (child.getName().compareTo("audio_text") == 0) {
      // load the psuedocode_url
      add_audio_text(child.getText().trim());
      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    // create & load the individual structures, hooking them into the StructureCollection.
    // linespernode : calculate it at end of loadStructure call
    while (child.getName().compareTo("question_ref") != 0) {
      StructureType child_struct = assignStructureType(child);
      child_struct.loadStructure(child, tempList, this);
      structs.addChild(child_struct);

      if (!iterator.hasNext()) return;
      child = (Element) iterator.next();
    }

    if (child.getName().compareTo("question_ref") == 0) {
      // set up question ref
      add_a_question_xml(child.getAttributeValue("ref"));
    } else
      // should never happen
      throw new VisualizerLoadException(
          "Expected question_ref element, but found " + child.getName());

    if (iterator.hasNext()) {
      child = (Element) iterator.next();
      throw new VisualizerLoadException(
          "Found " + child.getName() + " when expecting end of snap.");
    }
  } // load_snap_from_xml
  /**
   * 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;
  }
  /**
   * 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;
  }