Example usage for java.util Vector elements

List of usage examples for java.util Vector elements

Introduction

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

Prototype

public Enumeration<E> elements() 

Source Link

Document

Returns an enumeration of the components of this vector.

Usage

From source file:org.apache.axis.message.SOAPHeader.java

/**
 * Return an Enumeration of headers which match the given namespace
 * and localPart.  Depending on the value of the accessAllHeaders
 * parameter, we will attempt to filter on the current engine's list
 * of actors.//from  www. ja v a2 s  . c  om
 * 
 * !!! NOTE THAT RIGHT NOW WE ALWAYS ASSUME WE'RE THE "ULTIMATE
 * DESTINATION" (i.e. we match on null actor).  IF WE WANT TO FULLY SUPPORT
 * INTERMEDIARIES WE'LL NEED TO FIX THIS.
 */
Enumeration getHeadersByName(String namespace, String localPart, boolean accessAllHeaders) {
    ArrayList actors = null;
    boolean firstTime = false;

    /** This might be optimizable by creating a custom Enumeration
     * which moves through the headers list (parsing on demand, again),
     * returning only the next one each time.... this is Q&D for now.
     */
    Vector v = new Vector();
    List headers = getChildren();
    if (headers == null) {
        return v.elements();
    }
    Iterator e = headers.iterator();
    SOAPHeaderElement header;
    String nextActor = getEnvelope().getSOAPConstants().getNextRoleURI();

    while (e.hasNext()) {
        header = (SOAPHeaderElement) e.next();
        if (header.getNamespaceURI().equals(namespace) && header.getName().equals(localPart)) {

            if (!accessAllHeaders) {
                if (firstTime) {
                    // Do one-time setup
                    MessageContext mc = MessageContext.getCurrentContext();
                    if (mc != null && mc.getAxisEngine() != null) {
                        actors = mc.getAxisEngine().getActorURIs();
                    }
                    firstTime = false;
                }

                String actor = header.getActor();
                if ((actor != null) && !nextActor.equals(actor)
                        && (actors == null || !actors.contains(actor))) {
                    continue;
                }
            }

            v.addElement(header);
        }
    }

    return v.elements();
}

From source file:org.mule.modules.hdfs.automation.testcases.AppendTestCases.java

@Category({ RegressionTests.class })
@Test//from   www . jav a2s  .  c  om
public void testAppend() {

    Vector<InputStream> inputStreams = new Vector<InputStream>();
    inputStreams.add((InputStream) getTestRunMessageValue("payloadRef"));

    InputStream inputStreamToAppend = getBeanFromContext("randomInputStream");
    inputStreams.add(inputStreamToAppend);
    upsertOnTestRunMessage("payloadRef", inputStreamToAppend);

    SequenceInputStream inputStreamsSequence = new SequenceInputStream(
            (Enumeration<InputStream>) inputStreams.elements());

    try {
        runFlowAndGetPayload("append");
        IOUtils.contentEquals(inputStreamsSequence, (InputStream) runFlowAndGetPayload("read"));

    } catch (Exception e) {
        fail(ConnectorTestUtils.getStackTrace(e));
    }

}

From source file:org.apache.jetspeed.services.resources.VariableResourcesService.java

/**
 * The purpose of this method is to get the configuration resource
 * with the given name as a vector, or a default value.
 *
 * @param name The resource name.//from  www  .j ava2  s  .  c o m
 * @param def The default value of the resource.
 * @return The value of the resource as a vector.
 */
public Vector getVector(String name, Vector def) {
    Vector std = getVector(name);
    if (std == null) {
        if (def != null) {
            std = new Vector();
            Enumeration en = def.elements();
            while (en.hasMoreElements()) {
                std.addElement(substituteString((String) en.nextElement()));
            }
        }
    }

    return std;
}

From source file:org.infoglue.deliver.portal.information.RenderRequestIG.java

public Enumeration getAttributeNames() {
    Vector v = new Vector();

    for (Enumeration enumeration = super.getAttributeNames(); enumeration.hasMoreElements();) {
        v.add(enumeration.nextElement());
    }//from www .  j a va  2s  . co  m
    for (Enumeration enumeration = super.getRequest().getAttributeNames(); enumeration.hasMoreElements();) {
        v.add(enumeration.nextElement());
    }
    return v.elements();
}

From source file:nl.nn.adapterframework.util.StringTagger.java

/**
 * Returns a Enumeration of the values as Vectors that contain
 * the seperated values.//from  w  ww  .  j  a  v a  2 s.  c o  m
 * Use {@link #elements} to get a list of single, unseparated, values.
 */
public Enumeration multiElements(String token) {
    Vector tmp = (Vector) multitokens.get(token);
    if (tmp != null) {
        return tmp.elements();
    } else {
        return null;
    }
}

From source file:com.sixt.service.framework.servicetest.mockservice.MockHttpServletRequest.java

@Override
public Enumeration<String> getHeaders(String name) {
    Set<String> uniqueSet = new HashSet<>();
    for (String line : headers) {
        if (line.toLowerCase().startsWith(name.toLowerCase() + ":")) {
            int index = line.indexOf(':');
            uniqueSet.add(line.substring(index + 1).trim());
        }/* w  ww .  j av  a  2 s.  co  m*/
    }
    Vector<String> retval = new Vector<>(uniqueSet);
    return retval.elements();
}

From source file:extend.logback.access.spi.AccessEvent.java

@Override
public Enumeration getRequestHeaderNames() {
    // post-serialization
    if (httpRequest == null || httpRequest.headers == null) {
        Vector<String> list = new Vector<String>(getRequestHeaderMap().keySet());
        return list.elements();
    }/*  w  w  w . j  av a2  s . co  m*/
    Vector<String> list = new Vector<String>(httpRequest.headers.keySet());
    return list.elements();
}

From source file:org.apache.cxf.dosgi.singlebundle.SPIActivator.java

protected void register(final Bundle bundle) {
    Map<String, Callable<Class>> map = factories.get(bundle.getBundleId());

    Vector<URL> v = new Vector<URL>();
    try {/*from w w  w  .  j a  v  a 2  s  .  c o  m*/
        Resource[] resources = new OsgiBundleResourcePatternResolver(bundle)
                .getResources("classpath*:META-INF/services/*");
        for (Resource r : resources) {
            v.add(r.getURL());
        }
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    Enumeration<URL> e = v.elements();
    if (e != null) {
        while (e.hasMoreElements()) {
            final URL u = (URL) e.nextElement();
            final String url = u.toString();
            if (url.endsWith("/")) {
                continue;
            }
            final String factoryId = url.substring(url.lastIndexOf("/") + 1);
            if (map == null) {
                map = new HashMap<String, Callable<Class>>();
                factories.put(bundle.getBundleId(), map);
            }
            map.put(factoryId, new Callable<Class>() {
                public Class call() throws Exception {
                    BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream(), "UTF-8"));
                    String factoryClassName = br.readLine();
                    br.close();
                    return bundle.loadClass(factoryClassName);
                }
            });
        }
    }
    if (map != null) {
        for (Map.Entry<String, Callable<Class>> entry : map.entrySet()) {
            OsgiLocator.register(entry.getKey(), entry.getValue());
        }
    }
}

From source file:it.intecs.pisa.toolbox.util.URLReader.java

protected static String[] getSSESchemaDirectoryListingFromPortal(String baseUrl) {
    String[] listing;//from www  . j  a  v  a2 s. c  o m
    String[] fileListing;
    String[] directoryListing;
    String[] subDirectoryListing;
    Vector<String> subFolderFullListing;
    Enumeration<String> en;
    int i = 0;
    String url;

    subFolderFullListing = new Vector<String>();

    ToolboxConfiguration toolboxConfiguration;
    toolboxConfiguration = ToolboxConfiguration.getInstance();

    url = "http://" + toolboxConfiguration.getConfigurationValue(ToolboxConfiguration.SSE_PORTAL) + "/schemas/"
            + baseUrl;

    fileListing = getFileToDW(url);
    directoryListing = getDirectoryToDW(url);
    for (String subDir : directoryListing) {
        subDirectoryListing = getSSESchemaDirectoryListingFromPortal(subDir);
        for (String sub : subDirectoryListing) {
            System.out.println("ADDING " + sub);
            subFolderFullListing.add(sub);
        }
    }

    listing = new String[fileListing.length + subFolderFullListing.size()];
    en = subFolderFullListing.elements();
    for (String file : fileListing) {
        listing[i] = file;
        i++;
    }

    while (en.hasMoreElements()) {
        listing[i] = en.nextElement();
        i++;
    }
    return listing;
}

From source file:org.openhab.io.multimedia.internal.tts.TTSServiceGoogleTTS.java

/**
 * Converts the given sentences into audio and returns it as an {@link InputStream}.
 * /* w  w  w  . j  a v  a  2  s . c o  m*/
 * @param sentences
 *            The text to be converted to audio
 * @return {@link InputStream} with audio output
 * @throws IOException
 *             Exception if the connection could not be established properly
 */
private InputStream getSpeechForText(List<String> sentences) throws IOException {
    Vector<InputStream> inputStreams = new Vector<InputStream>(sentences.size());
    for (String sentence : sentences) {
        String encodedSentence = GoogleTTSTextProcessor.urlEncodeSentence(sentence);
        URL url = new URL(String.format(translateUrl, ttsLanguage, encodedSentence));
        inputStreams.add(getInputStreamFromUrl(url));
    }
    return new SequenceInputStream(inputStreams.elements());
}