List of usage examples for java.util Vector isEmpty
public synchronized boolean isEmpty()
From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java
/** * Transforms the Vector of the RepositoryType parameters into a RepositoryType Object.<br> * Structure of the parameters:<br> * Vector[name, uriFormat]/* w w w .ja v a2s.c o m*/ * </p> * * @param xmlRpcParameters a {@link java.util.Vector} object. * @return the RepositoryType. */ public static RepositoryType toRepositoryType(Vector<Object> xmlRpcParameters) { RepositoryType repositoryType = null; if (!xmlRpcParameters.isEmpty()) { repositoryType = RepositoryType.newInstance((String) xmlRpcParameters.get(REPOSITORY_TYPE_NAME_IDX)); @SuppressWarnings("unchecked") Hashtable<String, String> params = (Hashtable<String, String>) xmlRpcParameters .get(REPOSITORY_TYPE_REPOCLASSES_IDX); for (String env : params.keySet()) repositoryType.registerClassForEnvironment(params.get(env), EnvironmentType.newInstance(env)); repositoryType.setDocumentUrlFormat( toNullIfEmpty((String) xmlRpcParameters.get(REPOSITORY_TYPE_NAME_FORMAT_IDX))); repositoryType .setTestUrlFormat(toNullIfEmpty((String) xmlRpcParameters.get(REPOSITORY_TYPE_URI_FORMAT_IDX))); } return repositoryType; }
From source file:org.globus.ftp.test.FTPClientListTest.java
private void testList(boolean passive) throws Exception { FTPClient src = new FTPClient(TestEnv.serverFHost, TestEnv.serverFPort); src.authorize(TestEnv.serverFUser, TestEnv.serverFPassword); src.setType(Session.TYPE_ASCII);/*from ww w .j a va 2s.c om*/ src.changeDir(TestEnv.serverFDir); src.setPassiveMode(passive); boolean foundit = false; Vector v = src.list(); logger.debug("list received"); while (!v.isEmpty()) { FileInfo f = (FileInfo) v.remove(0); logger.info(f.toString()); if (f.getName().equals(TestEnv.serverFFile)) { foundit = true; } } src.close(); assertTrue("expected file not in the list", foundit); }
From source file:com.opensymphony.xwork2.util.ClassPathFinderTest.java
public void testFinder() { ClassPathFinder finder = new ClassPathFinder(); finder.setPattern("**/xwork-test-wildcard-*.xml"); Vector<String> found = finder.findMatches(); assertEquals(found.contains("com/opensymphony/xwork2/config/providers/xwork-test-wildcard-1.xml"), true); assertEquals(found.contains("com/opensymphony/xwork2/config/providers/xwork-test-wildcard-2.xml"), true); assertEquals(found.contains("com/opensymphony/xwork2/config/providers/xwork-test-wildcard-include.xml"), true);/*from ww w . jav a2s. c o m*/ assertEquals(found.contains("com/opensymphony/xwork2/config/providers/xwork-test-results.xml"), false); ClassPathFinder finder2 = new ClassPathFinder(); finder2.setPattern("com/*/xwork2/config/providers/xwork-test-wildcard-1.xml"); Vector<String> found2 = finder2.findMatches(); assertEquals(found2.contains("com/opensymphony/xwork2/config/providers/xwork-test-wildcard-1.xml"), true); assertEquals(found2.contains("com/opensymphony/xwork2/config/providers/xwork-test-wildcard-2.xml"), false); ClassPathFinder finder3 = new ClassPathFinder(); finder3.setPattern("com/opensymphony/xwork2/config/providers/xwork-test-wildcard-1.xml"); Vector<String> found3 = finder3.findMatches(); assertEquals(found3.contains("com/opensymphony/xwork2/config/providers/xwork-test-wildcard-1.xml"), true); assertEquals(found3.contains("com/opensymphony/xwork2/config/providers/xwork-test-wildcard-2.xml"), false); ClassPathFinder finder4 = new ClassPathFinder(); finder4.setPattern("no/matches/*"); Vector<String> found4 = finder4.findMatches(); assertEquals(found4.isEmpty(), true); }
From source file:com.brightcove.test.upload.HLS.Encrypted.HLSEncryptionUseCaseIntegrationTest.java
/** * Test does following checks 1. Verify the output when TTL Token on rendition is valid 2. * Verify the Rendition url has SSL support 3. Verify the output when TTL Token on rendition URL * are expired// ww w. j av a2 s. co m * @throws InterruptedException * @throws BadEnvironmentException * @throws JSONException * @throws MediaAPIError * @throws URISyntaxException * @throws MalformedURLException */ @Test public void testSSLTTLOnRendition() throws MalformedURLException, URISyntaxException, MediaAPIError, JSONException, BadEnvironmentException, InterruptedException { uploadMBRVideo(); AppleStreamingCheck appleCheck = new AppleStreamingCheck(); Vector rendition = retriveRenditionURL(mAccountInfo, mEnvironment, videoId); if (!rendition.isEmpty()) { appleCheck.assertTTL(rendition); appleCheck.assertURLAreSSLSecured(rendition); //appleCheck.assertTTLExpiration(rendition); } }
From source file:azkaban.common.utils.Utils.java
/** * Parse lines in byteArray and store the last *lineCount* lines in * *lastNLines*/*from www . ja v a 2 s .co m*/ * * @param byteArray source byte array * @param offset offset of the byte array * @param length length of the byte array * @param lineCount desired number of lines * @param lastNLines vector of last N lines * @return true indicates we get *lineCount* lines * false otherwise */ protected static boolean parseLinesFromLast(byte[] byteArray, int offset, int length, int lineCount, Vector<String> lastNLines) { if (lastNLines.size() > lineCount) return true; // convert byte array to string String lastNChars = new String(byteArray, offset, length); // reverse the string StringBuffer sb = new StringBuffer(lastNChars); lastNChars = sb.reverse().toString(); // tokenize the string using "\n" String[] tokens = lastNChars.split("\n"); // append lines to lastNLines for (int index = 0; index < tokens.length; index++) { StringBuffer sbLine = new StringBuffer(tokens[index]); String newline = sbLine.reverse().toString(); if (index == 0 && !lastNLines.isEmpty()) { // first line might not be a complete line int lineNum = lastNLines.size(); String halfLine = lastNLines.get(lineNum - 1); lastNLines.set(lineNum - 1, newline + halfLine); } else { lastNLines.add(newline); } if (lastNLines.size() > lineCount) { return true; } } return false; }
From source file:org.globus.ftp.test.FTPClientListTest.java
public void test2() throws Exception { logger.info("test two consective list, using both list functions"); FTPClient src = new FTPClient(TestEnv.serverFHost, TestEnv.serverFPort); src.authorize(TestEnv.serverFUser, TestEnv.serverFPassword); String output1 = null;//www.j a v a 2 s. c om String output2 = null; // using list() src.changeDir(TestEnv.serverFDir); Vector v = src.list(); logger.debug("list received"); StringBuffer output1Buffer = new StringBuffer(); while (!v.isEmpty()) { FileInfo f = (FileInfo) v.remove(0); output1Buffer.append(f.toString()).append("\n"); } output1 = output1Buffer.toString(); // using list(String,String, DataSink) HostPort hp2 = src.setPassive(); src.setLocalActive(); final ByteArrayOutputStream received2 = new ByteArrayOutputStream(1000); // unnamed DataSink subclass will write data channel content // to "received" stream. src.list("*", "-d", new DataSink() { public void write(Buffer buffer) throws IOException { logger.debug("received " + buffer.getLength() + " bytes of directory listing"); received2.write(buffer.getBuffer(), 0, buffer.getLength()); } public void close() throws IOException { }; }); // transfer done. Data is in received2 stream. output2 = received2.toString(); logger.debug(output2); src.close(); }
From source file:org.globus.ftp.test.MlsxTest.java
public void test3() throws Exception { logger.info("show mlsd output using GridFTPClient"); GridFTPClient src = new GridFTPClient(TestEnv.serverAHost, TestEnv.serverAPort); src.setAuthorization(TestEnv.getAuthorization(TestEnv.serverASubject)); src.authenticate(null); // use default creds src.setType(Session.TYPE_ASCII);/*w w w . j a v a 2 s . c o m*/ src.changeDir(TestEnv.serverADir); Vector v = src.mlsd(); logger.debug("mlsd received"); while (!v.isEmpty()) { MlsxEntry f = (MlsxEntry) v.remove(0); logger.info(f.toString()); } src.close(); }
From source file:org.springside.modules.security.springsecurity.cxf.SpringSecurityInInterceptor.java
/** * MessageWSS4J???./*from w w w . j a va2 s . c om*/ */ @SuppressWarnings("unchecked") private String getUserNameFromWSS4JResult(Message message) { Vector<WSHandlerResult> results = (Vector<WSHandlerResult>) message .getContextualProperty(WSHandlerConstants.RECV_RESULTS); if (results != null && !results.isEmpty()) { for (WSHandlerResult result : results) { for (WSSecurityEngineResult securityResult : (Vector<WSSecurityEngineResult>) result.getResults()) { int action = (Integer) securityResult.get(WSSecurityEngineResult.TAG_ACTION); if ((action & WSConstants.UT) > 0) { WSUsernameTokenPrincipal token = (WSUsernameTokenPrincipal) securityResult .get(WSSecurityEngineResult.TAG_PRINCIPAL); return token.getName(); } } } } return null; }
From source file:org.globus.ftp.test.MlsxTest.java
public void test4() throws Exception { logger.info("get mlsd output using GridFTPClient, EBlock, Image"); GridFTPClient src = new GridFTPClient(TestEnv.serverAHost, TestEnv.serverAPort); src.setAuthorization(TestEnv.getAuthorization(TestEnv.serverASubject)); src.authenticate(null); // use default creds src.setType(Session.TYPE_IMAGE);//from www . j av a 2 s.c o m src.setMode(GridFTPSession.MODE_EBLOCK); // server sends the listing over data channel. // so in EBlock, it must be active HostPort hp = src.setLocalPassive(); src.setActive(hp); src.changeDir(TestEnv.serverADir); Vector v = src.mlsd(); logger.debug("mlsd received"); while (!v.isEmpty()) { MlsxEntry f = (MlsxEntry) v.remove(0); logger.debug(f.toString()); } src.close(); }
From source file:com.swingtech.commons.util.ClassUtil.java
public static List getPropertyDescriptorsFromClass(final Class pClass, final String filterRegEx) { BeanInfo vBeanInfo = null;/* w w w.j a va 2 s. co m*/ PropertyDescriptor[] vPropDescList = null; PropertyDescriptor vPropDesc = null; String vPropName = null; final Vector vPropertyNameList = new Vector(); try { vBeanInfo = Introspector.getBeanInfo(pClass); } catch (final IntrospectionException e) { logger.warn("Utility.getPropertyNamesFromClass. Error trying to use Introspector", e); return null; } vPropDescList = vBeanInfo.getPropertyDescriptors(); for (int i = 0; i < vPropDescList.length; i++) { vPropDesc = vPropDescList[i]; vPropName = vPropDesc.getName(); if (Utility.isNullOrEmpty(filterRegEx) || vPropName.matches(filterRegEx)) { vPropertyNameList.add(vPropDesc); } } if (vPropertyNameList.isEmpty()) { return null; } return vPropertyNameList; }