Example usage for java.util Vector iterator

List of usage examples for java.util Vector iterator

Introduction

In this page you can find the example usage for java.util Vector iterator.

Prototype

public synchronized Iterator<E> iterator() 

Source Link

Document

Returns an iterator over the elements in this list in proper sequence.

Usage

From source file:org.energy_home.jemma.ah.internal.zigbee.InstallationStatus.java

/**
 * Called when a message has been received from ZigBee
 *//*w w  w .  j  ava 2 s. c o  m*/
public void notifyAPSMessage(APSMessageEvent msg) {
    if (enableNotifyFrameLogs)
        this.printAPSMessageEvent(msg);

    // forward the message to the peer device
    Address srcAddress = msg.getSourceAddress();
    String nodePid = getNodePid(srcAddress);

    if (nodePid == null) {
        log.debug("message discarded because the src node ieee address is not present");
        return;
    }

    if ((log != null) && (enableNotifyFrameLogs)) {
        log.debug(getIeeeAddressHex(srcAddress) + ": Thr " + Thread.currentThread().getId()
                + ": messageReceived()");
    }

    if (msg.getDestinationEndpoint() == 0xFF) {
        handleBroadcastMessages(msg);
        return;
    }

    rwLock.readLock().lock();

    if (enableLockingLogs) {
        if (rwLock.getReadLockCount() > 1) {
            log.debug("Thr: " + Thread.currentThread().getId() + ": There are multiple read lock"
                    + rwLock.getReadLockCount());
        }
    }

    // Drop messages that doesn't belong to the exported clusters
    if (enableNotifyFrameLogs)
        this.printAPSMessageEvent(msg);

    try {
        Vector devices = (Vector) ieee2devices.get(nodePid);

        ZclFrame zclFrame = new ZclFrame(msg.getData());

        int clusterID = msg.getClusterID();
        if (!checkGatewaySimpleDescriptor(clusterID, zclFrame)) {
            // FIXME: qui dovremmo dare un errore differente a seconda se il comando' e' generale e manufacturer specific
            IZclFrame zclResponseFrame = this.getDefaultResponse(zclFrame, ZCL.UNSUP_CLUSTER_COMMAND);
            log.error("APS message coming from clusterID 0x" + Hex.toHexString(clusterID, 4)
                    + ". This clusterId is not supported by the gateway");
            this.post(msg, zclResponseFrame);
            return;
        }

        if (devices != null) {
            Iterator it = devices.iterator();
            boolean epFound = false;
            while (it.hasNext()) {
                ZigBeeDeviceImpl device = (ZigBeeDeviceImpl) it.next();
                if (device.getEp() == msg.getSourceEndpoint()) {
                    if (enableNotifyFrameLogs) {
                        log.debug("notifyZclFrame() : Thr " + Thread.currentThread().getId() + " "
                                + msg.getClusterID() + " message to ep " + device.getEp());
                    }
                    try {
                        device.notifyZclFrame((short) msg.getClusterID(), zclFrame);
                    } catch (ZclException e) {
                        if (!zclFrame.isDefaultResponseDisabled()) {
                            IZclFrame zclResponseFrame = this.getDefaultResponse(zclFrame, e.getStatusCode());
                            this.post(msg, zclResponseFrame);
                            log.error(getIeeeAddressHex(srcAddress)
                                    + ": messageReceived(): Sent to device a default response with status code "
                                    + e.getStatusCode());
                        }
                    }

                    if (enableNotifyFrameLogs) {
                        log.debug("after notifyZclFrame() : Thr " + Thread.currentThread().getId() + " "
                                + msg.getClusterID() + " message to ep " + device.getEp());
                    }
                    epFound = true;

                    break;
                }
            }
            if (!epFound && log.isDebugEnabled())
                log.error("not found any matching ep for the incoming message");

        } else {
            IZclFrame zclResponseFrame;
            InstallationStatus installationStatus = this.getInstallingDevice(srcAddress);
            if (installationStatus != null) {
                log.error(getIeeeAddressHex(srcAddress)
                        + ": received a message from a node that is not installed. Reply with TIMEOUT");
                zclResponseFrame = this.getDefaultResponse(zclFrame, 0x94);
            } else {
                log.error("received a message from an unknown node " + getIeeeAddressHex(srcAddress)
                        + " . Reply with TIMEOUT");

                zclResponseFrame = this.getDefaultResponse(zclFrame, 0x94);
            }

            this.post(msg, zclResponseFrame);
        }
    } finally {
        if (enableLockingLogs) {
            log.debug("Thr: " + Thread.currentThread().getId() + ": unlocking and read lock count is: "
                    + rwLock.getReadLockCount());
        }
        rwLock.readLock().unlock();
    }

    if (enableNotifyFrameLogs) {
        log.debug(getIeeeAddressHex(msg.getSourceAddress()) + ": " + " Thr " + Thread.currentThread().getId()
                + ": leave notifyAPSMessage()");
    }
}

From source file:org.apache.axis2.description.WSDL11ToAxisServiceBuilder.java

/**
 * Look deeper in the imports to find the requested Message. Use a HashSet to make 
 * sure we don't traverse the same Definition object twice (avoid recursion).
 * /*from  w  ww .  j a  v a 2 s.  c o m*/
 * @param definition
 * @param message
 * @param instances
 * @return
 */
private Message getMessage(Definition definition, QName message, Set seen) {

    Message msg = definition.getMessage(message);

    if (msg != null) {
        if (log.isDebugEnabled()) {
            log.debug("getMessage returning = "
                    + ((message.getLocalPart() != null) ? message.getLocalPart() : "NULL"));
        }

        return msg;
    }

    seen.add(definition);

    Iterator iter = definition.getImports().values().iterator();

    while (iter.hasNext()) {
        Vector values = (Vector) iter.next();
        for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
            Import wsdlImport = (Import) valuesIter.next();
            Definition innerDefinition = wsdlImport.getDefinition();

            if (seen.contains(innerDefinition)) {
                continue; // Skip seen
            }
            Message result = getMessage(innerDefinition, message, seen);
            if (result != null) {
                return result;
            }
        }
    }

    if (log.isDebugEnabled()) {
        log.debug("getMessage: Unable to find message, returning NULL");
    }

    return null;
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

private void loadInformation(boolean sort, String str) {
    String address[] = str.split(":");
    HashSet<BigInteger> c = new HashSet<BigInteger>();
    for (int x = 0; x < address.length; x++) {
        try {/*from  w  w  w. j  av a  2s.  c om*/
            c.add(CommonLib.string2BigInteger(address[x]));
        } catch (Exception ex) {

        }
    }
    Vector<BigInteger> v = new Vector<BigInteger>();

    Iterator<BigInteger> it = c.iterator();
    while (it.hasNext()) {
        BigInteger element = it.next();
        v.add(element);
    }

    if (sort) {
        Collections.sort(v);
    }
    jTextArea1.setText("");
    Iterator<BigInteger> it2 = v.iterator();
    while (it2.hasNext()) {
        BigInteger element = it2.next();
        jTextArea1.setText(jTextArea1.getText() + "\n0x" + element.toString(16));
    }
}

From source file:org.apache.axis2.description.WSDL11ToAxisServiceBuilder.java

private void processTypes(Definition wsdlDefinition, AxisService axisService, Set visitedWSDLs)
        throws AxisFault {
    visitedWSDLs.add(wsdlDefinition.getDocumentBaseURI());
    // process all the types in all the wsdls
    Types types = wsdlDefinition.getTypes();
    if (types != null) {
        copyExtensibleElements(types.getExtensibilityElements(), wsdlDefinition, axisService, TYPES);
    }/*from www  . ja v  a 2 s .co m*/

    // process the types in other wsdls
    Iterator iter = wsdlDefinition.getImports().values().iterator();
    Vector values = null;
    Import wsdlImport = null;
    for (; iter.hasNext();) {
        values = (Vector) iter.next();
        for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
            wsdlImport = (Import) valuesIter.next();
            // process the types recuresiveilt
            Definition innerDefinition = wsdlImport.getDefinition();
            if (!visitedWSDLs.contains(innerDefinition.getDocumentBaseURI())) {
                processTypes(innerDefinition, axisService, visitedWSDLs);
            }
        }
    }
}

From source file:org.apache.axis2.description.WSDL11ToAxisServiceBuilder.java

/**
 * Populate a map of targetNamespace vs DOM schema element This is used to
 * grab the correct schema element when adding a new element
 *
 * @param definition/*from   w w w .  j av a 2  s. c  o m*/
 */

private void populateSchemaMap(Definition definition, Set visitedWSDLs) {
    visitedWSDLs.add(definition.getDocumentBaseURI());
    // first process the types in the given wsdl
    Types types = definition.getTypes();
    Object extensibilityElement;
    if (types != null) {
        for (Iterator iterator = types.getExtensibilityElements().iterator(); iterator.hasNext();) {
            extensibilityElement = iterator.next();
            if (extensibilityElement instanceof Schema) {
                Element schemaElement = ((Schema) extensibilityElement).getElement();
                schemaMap.put(schemaElement.getAttribute(XSD_TARGETNAMESPACE), schemaElement);
            }
        }
    }

    // popualte the imports as well
    Iterator iter = definition.getImports().values().iterator();
    Vector values = null;
    Import wsdlImport = null;
    for (; iter.hasNext();) {
        values = (Vector) iter.next();
        for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
            wsdlImport = (Import) valuesIter.next();
            Definition innerDefinition = wsdlImport.getDefinition();
            if (!visitedWSDLs.contains(innerDefinition.getDocumentBaseURI())) {
                populateSchemaMap(innerDefinition, visitedWSDLs);
            }
        }
    }
}

From source file:org.apache.axis2.description.WSDL11ToAxisServiceBuilder.java

/**
 * returns the wsld defintion for the given component.
 * @param definition//  w  w w . j  a v  a 2s. c  o m
 * @param qname
 * @param componentType
 * @param visitedWSDLs
 * @return definition containing the component.
 */
private Definition getParentDefinition(Definition definition, QName qname, int componentType,
        Set visitedWSDLs) {
    visitedWSDLs.add(definition.getDocumentBaseURI());
    Definition newParentDefinition = null;
    // first find through imports
    Iterator iter = definition.getImports().values().iterator();
    Vector values = null;
    Import wsdlImport = null;
    for (; iter.hasNext();) {
        values = (Vector) iter.next();
        for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
            wsdlImport = (Import) valuesIter.next();
            Definition innerDefinition = wsdlImport.getDefinition();
            if (!visitedWSDLs.contains(innerDefinition.getDocumentBaseURI())) {
                newParentDefinition = getParentDefinition(innerDefinition, qname, componentType, visitedWSDLs);
                if (newParentDefinition != null) {
                    break;
                }
            }
        }
        if (newParentDefinition != null) {
            break;
        }
    }

    // if it not available in imports we check for the current definition.
    if (newParentDefinition == null) {
        // this can be in a imported wsdl
        if (isComponetAvailable(definition, qname, componentType)) {
            newParentDefinition = definition;
        }
    }

    return newParentDefinition;
}

From source file:org.apache.axis2.description.WSDL11ToAxisServiceBuilder.java

/**
* Process the policy definitions/* w  w  w.jav a 2s.  c  om*/
* 
* @param definition
*/
private void processPoliciesInDefintion(Definition definition, Set visitedWSDLs) {
    visitedWSDLs.add(definition.getDocumentBaseURI());
    List extElements = definition.getExtensibilityElements();
    ExtensibilityElement extElement;
    UnknownExtensibilityElement unknown = null;
    Policy policy = null;

    for (Iterator iterator = extElements.iterator(); iterator.hasNext();) {
        extElement = (ExtensibilityElement) iterator.next();

        if (extElement instanceof UnknownExtensibilityElement) {
            unknown = (UnknownExtensibilityElement) extElement;
            if (WSDLConstants.WSDL11Constants.POLICY.equals(unknown.getElementType())) {

                policy = (Policy) PolicyUtil.getPolicyComponent(unknown.getElement());
                String key;
                if ((key = policy.getName()) != null || (key = policy.getId()) != null) {
                    axisService.registerPolicy(key, policy);
                    //                        registry.register(key, policy);
                    //                        registry.register("#" + key, policy);
                }

            }
        }
    }
    // include policices in other imported wsdls
    Iterator iter = definition.getImports().values().iterator();
    Vector values = null;
    Import wsdlImport = null;
    for (; iter.hasNext();) {
        values = (Vector) iter.next();
        for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
            wsdlImport = (Import) valuesIter.next();
            Definition innerDefinition = wsdlImport.getDefinition();
            // find the binding recursively
            if (!visitedWSDLs.contains(innerDefinition.getDocumentBaseURI())) {
                processPoliciesInDefintion(innerDefinition, visitedWSDLs);
            }
        }
    }
}

From source file:org.apache.axis2.description.AxisService.java

/**
 * find the defintion object for given name
 * /*ww w .  j  a v a2  s.c  o m*/
 * @param parentDefinition
 * @param name
 * @return wsdl definition
 */
private Definition getWSDLDefinition(Definition parentDefinition, String name) {

    if (name == null)
        return parentDefinition;

    Definition importedDefinition = null;
    Iterator iter = parentDefinition.getImports().values().iterator();
    Vector values = null;
    Import wsdlImport = null;
    for (; iter.hasNext();) {
        values = (Vector) iter.next();
        for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
            wsdlImport = (Import) valuesIter.next();
            if (wsdlImport.getLocationURI().endsWith(name)) {
                importedDefinition = wsdlImport.getDefinition();
                break;
            } else {
                importedDefinition = getWSDLDefinition(wsdlImport.getDefinition(), name);
            }
            if (importedDefinition != null) {
                break;
            }
        }
        if (importedDefinition != null) {
            break;
        }
    }
    return importedDefinition;
}

From source file:org.apache.axis2.description.AxisService.java

/**
 * this procesdue recursively adjust the wsdl imports locations and the
 * schmea import and include locations./* w w w. ja  v a2s . c o  m*/
 * 
 * @param definition
 */
private void changeImportAndIncludeLocations(Definition definition) throws AxisFault {

    // adjust the schema locations in types section
    Types types = definition.getTypes();
    if (types != null) {
        List extensibilityElements = types.getExtensibilityElements();
        Object extensibilityElement = null;
        Schema schema = null;
        for (Iterator iter = extensibilityElements.iterator(); iter.hasNext();) {
            extensibilityElement = iter.next();
            if (extensibilityElement instanceof Schema) {
                schema = (Schema) extensibilityElement;
                changeLocations(schema.getElement());
            }
        }
    }

    Iterator iter = definition.getImports().values().iterator();
    Vector values = null;
    Import wsdlImport = null;
    String originalImprotString = null;
    for (; iter.hasNext();) {
        values = (Vector) iter.next();
        for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
            wsdlImport = (Import) valuesIter.next();
            originalImprotString = wsdlImport.getLocationURI();
            if (originalImprotString.indexOf("://") == -1 && originalImprotString.indexOf("?wsdl=") == -1) {
                wsdlImport.setLocationURI(this.getServiceEPR() + "?wsdl=" + originalImprotString);
            }
            changeImportAndIncludeLocations(wsdlImport.getDefinition());
        }
    }

}

From source file:de.juwimm.cms.remote.ContentServiceSpringImpl.java

/**
 * @see de.juwimm.cms.remote.ContentServiceSpring#getNotReferencedUnits(de.juwimm.cms.vo.ViewDocumentValue)
 *///from   w  w w.ja  v a  2 s  . c  o m
@Override
protected UnitValue[] handleGetNotReferencedUnits(ViewDocumentValue viewDocument) throws Exception {
    if (log.isInfoEnabled())
        log.info("starting getNotReferencedUnits for Site " + viewDocument.getSiteId() + " and Language "
                + viewDocument.getLanguage());
    try {
        Collection coll = super.getViewComponentHbmDao().findAllWithUnit(viewDocument.getViewDocumentId());
        Collection u = super.getUnitHbmDao().findAll(viewDocument.getSiteId());
        Vector<Integer> units = new Vector<Integer>();

        Iterator itUnits = u.iterator();
        while (itUnits.hasNext()) {
            UnitHbm unit = (UnitHbm) itUnits.next();
            units.add(unit.getUnitId());
        }

        Iterator it = coll.iterator();
        while (it.hasNext()) {
            ViewComponentHbm vcl = (ViewComponentHbm) it.next();
            try {
                units.remove(vcl.getAssignedUnit().getUnitId());
            } catch (Exception e) {
                if (log.isDebugEnabled()) {
                    log.debug("Could not remove assigned unit: " + e.getMessage());
                }
            }
        }

        UnitValue[] unitdaos = new UnitValue[units.size()];
        it = units.iterator();
        int i = 0;
        while (it.hasNext()) {
            Integer unitId = (Integer) it.next();
            UnitHbm ul = super.getUnitHbmDao().load(unitId);
            unitdaos[i++] = getUnitHbmDao().getDao(ul);
        }
        if (log.isDebugEnabled())
            log.debug("end getNotReferencedUnits for Site " + viewDocument.getSiteId() + " and Language "
                    + viewDocument.getLanguage());
        return unitdaos;
    } catch (Exception e) {
        log.warn("Error getNotReferencedUnits for Site " + viewDocument.getSiteId() + " and Language "
                + viewDocument.getLanguage() + ": " + e.getMessage(), e);
        throw new UserException(e.getMessage());
    }
}