List of usage examples for java.util Vector elementAt
public synchronized E elementAt(int index)
From source file:org.apache.tools.ant.taskdefs.optional.net.FTPTaskMirrorImpl.java
/** * Creates all parent directories specified in a complete relative * pathname. Attempts to create existing directories will not cause * errors./*from ww w . ja v a2s . c o m*/ * * @param ftp the FTP client instance to use to execute FTP actions on * the remote server. * @param filename the name of the file whose parents should be created. * @throws IOException under non documented circumstances * @throws BuildException if it is impossible to cd to a remote directory * */ protected void createParents(FTPClient ftp, String filename) throws IOException, BuildException { File dir = new File(filename); if (dirCache.contains(dir)) { return; } Vector parents = new Vector(); String dirname; while ((dirname = dir.getParent()) != null) { File checkDir = new File(dirname); if (dirCache.contains(checkDir)) { break; } dir = checkDir; parents.addElement(dir); } // find first non cached dir int i = parents.size() - 1; if (i >= 0) { String cwd = ftp.printWorkingDirectory(); String parent = dir.getParent(); if (parent != null) { if (!ftp.changeWorkingDirectory(resolveFile(parent))) { throw new BuildException("could not change to " + "directory: " + ftp.getReplyString()); } } while (i >= 0) { dir = (File) parents.elementAt(i--); // check if dir exists by trying to change into it. if (!ftp.changeWorkingDirectory(dir.getName())) { // could not change to it - try to create it task.log("creating remote directory " + resolveFile(dir.getPath()), Project.MSG_VERBOSE); if (!ftp.makeDirectory(dir.getName())) { handleMkDirFailure(ftp); } if (!ftp.changeWorkingDirectory(dir.getName())) { throw new BuildException("could not change to " + "directory: " + ftp.getReplyString()); } } dirCache.add(dir); } ftp.changeWorkingDirectory(cwd); } }
From source file:org.apache.struts2.jasper.compiler.JspUtil.java
/** * Checks if all mandatory attributes are present and if all attributes * present have valid names. Checks attributes specified as XML-style * attributes as well as attributes specified using the jsp:attribute * standard action.//from w w w . ja v a2s .co m * * @param typeOfTag type of tag * @param n node * @param validAttributes valid attributes * @param err error dispatcher * @throws JasperException in case of Jasper errors */ public static void checkAttributes(String typeOfTag, Node n, ValidAttribute[] validAttributes, ErrorDispatcher err) throws JasperException { Attributes attrs = n.getAttributes(); Mark start = n.getStart(); boolean valid = true; // AttributesImpl.removeAttribute is broken, so we do this... int tempLength = (attrs == null) ? 0 : attrs.getLength(); Vector temp = new Vector(tempLength, 1); for (int i = 0; i < tempLength; i++) { String qName = attrs.getQName(i); if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:"))) temp.addElement(qName); } // Add names of attributes specified using jsp:attribute Node.Nodes tagBody = n.getBody(); if (tagBody != null) { int numSubElements = tagBody.size(); for (int i = 0; i < numSubElements; i++) { Node node = tagBody.getNode(i); if (node instanceof Node.NamedAttribute) { String attrName = node.getAttributeValue("name"); temp.addElement(attrName); // Check if this value appear in the attribute of the node if (n.getAttributeValue(attrName) != null) { err.jspError(n, "jsp.error.duplicate.name.jspattribute", attrName); } } else { // Nothing can come before jsp:attribute, and only // jsp:body can come after it. break; } } } /* * First check to see if all the mandatory attributes are present. * If so only then proceed to see if the other attributes are valid * for the particular tag. */ String missingAttribute = null; for (ValidAttribute validAttribute : validAttributes) { int attrPos; if (validAttribute.mandatory) { attrPos = temp.indexOf(validAttribute.name); if (attrPos != -1) { temp.remove(attrPos); valid = true; } else { valid = false; missingAttribute = validAttribute.name; break; } } } // If mandatory attribute is missing then the exception is thrown if (!valid) err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag, missingAttribute); // Check to see if there are any more attributes for the specified tag. int attrLeftLength = temp.size(); if (attrLeftLength == 0) return; // Now check to see if the rest of the attributes are valid too. String attribute = null; for (int j = 0; j < attrLeftLength; j++) { valid = false; attribute = (String) temp.elementAt(j); for (ValidAttribute validAttribute : validAttributes) { if (attribute.equals(validAttribute.name)) { valid = true; break; } } if (!valid) err.jspError(start, "jsp.error.invalid.attribute", typeOfTag, attribute); } // XXX *could* move EL-syntax validation here... (sb) }
From source file:cms.service.template.TemplateUtility.java
public Vector getGridColumnData(Vector rowData, String columnSeperator, int rowno) { StringTokenizer st = new StringTokenizer((String) rowData.elementAt(rowno), columnSeperator); Vector vRet = new Vector(); int count = 0; while (st.hasMoreTokens()) { vRet.addElement(st.nextToken()); count++;// w w w .ja v a2 s . c o m } if (count == 0) vRet.addElement(rowData.elementAt(rowno)); return (vRet); }
From source file:cms.service.template.TemplateUtility.java
public String parseInputValue(Vector vBuf, String sKey) { for (int i = 0; i < vBuf.size(); i++) { String strElm = new String(); strElm = (String) vBuf.elementAt(i); if (strElm.toUpperCase().startsWith(sKey.toUpperCase())) { int idx = strElm.indexOf("="); strElm = strElm.substring(idx + 1); return strElm; }/*from w ww . j ava2 s . c om*/ } return null; }
From source file:edu.lternet.pasta.dml.parser.eml.Eml200Parser.java
/** * Pulls the entity information out of the XML and stores it in a hash table. *//*from w w w .j av a 2 s. com*/ private void processEntities(CachedXPathAPI xpathapi, NodeList entitiesNodeList, String xpath, String packageId) throws SAXException, javax.xml.transform.TransformerException, Exception { // Make sure that entities is not null if (entitiesNodeList == null) { return; } int entityNodeListLength = entitiesNodeList.getLength(); numEntities = numEntities + entityNodeListLength; String entityName = ""; String entityDescription = ""; String entityOrientation = ""; String entityCaseSensitive = ""; String entityNumberOfRecords = "-1"; String onlineUrl = ""; String numHeaderLines = "0"; int numFooterLines = 0; String fieldDelimiter = null; String recordDelimiter = ""; String compressionMethod = ""; String encodingMethod = ""; String quoteCharacter = null; String literalCharacter = null; boolean isImageEntity = false; boolean isGZipDataFile = false; boolean isZipDataFile = false; boolean isTarDataFile = false; boolean isSimpleDelimited = true; boolean isCollapseDelimiters = false; TextComplexDataFormat[] formatArray = null; for (int i = 0; i < entityNodeListLength; i++) { if (xpath != null && (xpath.equals(SPATIALRASTERENTITY) || xpath.equals(SPATIALVECTORENTITY))) { isImageEntity = true; } //go through the entities and put the information into the hash. elementId++; Node entityNode = entitiesNodeList.item(i); String id = null; NamedNodeMap entityNodeAttributes = entityNode.getAttributes(); if (entityNodeAttributes != null) { Node idNode = entityNodeAttributes.getNamedItem(ID); if (idNode != null) { id = idNode.getNodeValue(); } } NodeList entityNodeChildren = entityNode.getChildNodes(); for (int j = 0; j < entityNodeChildren.getLength(); j++) { Node childNode = entityNodeChildren.item(j); String childName = childNode.getNodeName(); if (childName.equals("entityName")) { entityName = childNode.getFirstChild().getNodeValue(); } else if (childName.equals("entityDescription")) { entityDescription = childNode.getFirstChild().getNodeValue(); } else if (childName.equals("caseSensitive")) { entityCaseSensitive = childNode.getFirstChild().getNodeValue(); } else if (childName.equals("numberOfRecords")) { entityNumberOfRecords = childNode.getFirstChild().getNodeValue(); /*numRecords = (new Integer(entityNumberOfRecords)) .intValue();*/ } } NodeList attributeOrientationNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/attributeOrientation"); if (attributeOrientationNodeList != null && attributeOrientationNodeList.getLength() > 0) { entityOrientation = attributeOrientationNodeList.item(0).getFirstChild().getNodeValue(); } NodeList numHeaderLinesNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/numHeaderLines"); if ((numHeaderLinesNodeList != null) && (numHeaderLinesNodeList.getLength() > 0)) { Node numHeaderLinesNode = numHeaderLinesNodeList.item(0); if (numHeaderLinesNode != null) { numHeaderLines = numHeaderLinesNode.getFirstChild().getNodeValue(); } } NodeList numFooterLinesNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/numFooterLines"); if ((numFooterLinesNodeList != null) && (numFooterLinesNodeList.getLength() > 0)) { Node numFooterLinesNode = numFooterLinesNodeList.item(0); if (numFooterLinesNode != null) { String numFooterLinesStr = numFooterLinesNode.getFirstChild().getNodeValue(); numFooterLines = (new Integer(numFooterLinesStr.trim())).intValue(); } } // Here is the simple delimited data file NodeList fieldDelimiterNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/simpleDelimited/fieldDelimiter"); if (fieldDelimiterNodeList != null && fieldDelimiterNodeList.getLength() > 0) { fieldDelimiter = fieldDelimiterNodeList.item(0).getFirstChild().getNodeValue(); } NodeList collapseDelimitersNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/simpleDelimited/collapseDelimiters"); if (collapseDelimitersNodeList != null && collapseDelimitersNodeList.getLength() > 0) { String collapseDelimiters = collapseDelimitersNodeList.item(0).getFirstChild().getNodeValue(); if (collapseDelimiters.equalsIgnoreCase("yes")) { isCollapseDelimiters = true; } } NodeList quoteCharacterNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/simpleDelimited/quoteCharacter"); if (quoteCharacterNodeList != null && quoteCharacterNodeList.getLength() > 0) { quoteCharacter = quoteCharacterNodeList.item(0).getFirstChild().getNodeValue(); } NodeList literalCharacterNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/simpleDelimited/literalCharacter"); if (literalCharacterNodeList != null && literalCharacterNodeList.getLength() > 0) { literalCharacter = literalCharacterNodeList.item(0).getFirstChild().getNodeValue(); } // For complex format data file NodeList complexNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/complex"); if (complexNodeList != null && complexNodeList.getLength() > 0) { //log.debug("in handle complex text data format"); isSimpleDelimited = false; Node complexNode = complexNodeList.item(0); NodeList complexChildNodes = complexNode.getChildNodes(); int complexChildNodesLength = complexChildNodes.getLength(); Vector formatVector = new Vector(); for (int k = 0; k < complexChildNodesLength; k++) { Node complexChildNode = complexChildNodes.item(k); if (complexChildNode != null && complexChildNode.getNodeName().equals("textFixed")) { TextWidthFixedDataFormat textWidthFixedDataFormat = handleTextFixedDataFormatNode( complexChildNode); if (textWidthFixedDataFormat != null) { formatVector.add(textWidthFixedDataFormat); //complexFormatsNumber++; } } else if (complexChildNode != null && complexChildNode.getNodeName().equals("textDelimited")) { TextDelimitedDataFormat textDelimitedDataFormat = handleComplexDelimitedDataFormatNode( complexChildNode); if (textDelimitedDataFormat != null) { formatVector.add(textDelimitedDataFormat); //complexFormatsNumber++; } } } // Transfer vector to array numberOfComplexFormats = formatVector.size(); formatArray = new TextComplexDataFormat[numberOfComplexFormats]; for (int j = 0; j < numberOfComplexFormats; j++) { formatArray[j] = (TextComplexDataFormat) formatVector.elementAt(j); } } NodeList recordDelimiterNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/recordDelimiter"); if ((recordDelimiterNodeList != null) && (recordDelimiterNodeList.getLength() > 0)) { recordDelimiter = recordDelimiterNodeList.item(0).getFirstChild().getNodeValue(); } else { recordDelimiter = "\\r\\n"; } // Get the distribution information NodeList urlNodeList = xpathapi.selectNodeList(entityNode, "physical/distribution/online/url"); if (urlNodeList != null && urlNodeList.getLength() > 0) { onlineUrl = urlNodeList.item(0).getFirstChild().getNodeValue(); if (isDebugging) { //log.debug("The url is "+ onlineUrl); } } // Get the compressionMethod information NodeList compressionMethodNodeList = xpathapi.selectNodeList(entityNode, "physical/compressionMethod"); if (compressionMethodNodeList != null && compressionMethodNodeList.getLength() > 0) { compressionMethod = compressionMethodNodeList.item(0).getFirstChild().getNodeValue(); if (isDebugging) { //log.debug("Compression method is "+compressionMethod); } if (compressionMethod != null && compressionMethod.equals(Entity.GZIP)) { isGZipDataFile = true; } else if (compressionMethod != null && compressionMethod.equals(Entity.ZIP)) { isZipDataFile = true; } } // Get encoding method info (mainly for tar file) NodeList encodingMethodNodeList = xpathapi.selectNodeList(entityNode, "physical/encodingMethod"); if (encodingMethodNodeList != null && encodingMethodNodeList.getLength() > 0) { encodingMethod = encodingMethodNodeList.item(0).getFirstChild().getNodeValue(); if (isDebugging) { //log.debug("encoding method is "+encodingMethod); } if (encodingMethod != null && encodingMethod.equals(Entity.TAR)) { isTarDataFile = true; } } if (entityOrientation.trim().equals("column")) { entityOrientation = Entity.COLUMNMAJOR; } else { entityOrientation = Entity.ROWMAJOR; } if (entityCaseSensitive.equals("yes")) { entityCaseSensitive = "true"; } else { entityCaseSensitive = "false"; } entityObject = new Entity(id, entityName.trim(), entityDescription.trim(), new Boolean(entityCaseSensitive), entityOrientation, new Integer(entityNumberOfRecords).intValue()); entityObject.setNumHeaderLines((new Integer(numHeaderLines)).intValue()); entityObject.setNumFooterLines(numFooterLines); entityObject.setSimpleDelimited(isSimpleDelimited); // For simple delimited data file if (fieldDelimiter != null) { entityObject.setFieldDelimiter(fieldDelimiter); } if (quoteCharacter != null) { entityObject.setQuoteCharacter(quoteCharacter); } if (literalCharacter != null) { entityObject.setLiteralCharacter(literalCharacter); } entityObject.setCollapseDelimiters(isCollapseDelimiters); entityObject.setRecordDelimiter(recordDelimiter); entityObject.setURL(onlineUrl); entityObject.setCompressionMethod(compressionMethod); entityObject.setIsImageEntity(isImageEntity); entityObject.setHasGZipDataFile(isGZipDataFile); entityObject.setHasZipDataFile(isZipDataFile); entityObject.setHasTarDataFile(isTarDataFile); entityObject.setPackageId(packageId); try { NodeList attributeListNodeList = xpathapi.selectNodeList(entityNode, "attributeList"); processAttributeList(xpathapi, attributeListNodeList, entityObject); entityObject.setDataFormatArray(formatArray); } catch (Exception e) { throw new Exception("Error parsing attributes: " + e.getMessage()); } //entityHash.put(Integer.toString(elementId), entityObject); emlDataPackage.add(entityObject); //fileHash.put(elementId, onlineUrl); } // end for loop }
From source file:org.ecoinformatics.datamanager.parser.eml.Eml200Parser.java
/** * Pulls the entity information out of the XML and stores it in a hash table. *//*w w w . ja v a 2 s . c o m*/ private void processEntities(CachedXPathAPI xpathapi, NodeList entitiesNodeList, String xpath, String packageId) throws SAXException, javax.xml.transform.TransformerException, Exception { // Make sure that entities is not null if (entitiesNodeList == null) { return; } int entityNodeListLength = entitiesNodeList.getLength(); numEntities = numEntities + entityNodeListLength; String entityName = ""; String entityDescription = ""; String entityOrientation = ""; String entityCaseSensitive = ""; String entityNumberOfRecords = "-1"; String onlineUrl = ""; String numHeaderLines = "0"; int numFooterLines = 0; String fieldDelimiter = null; String recordDelimiter = ""; String compressionMethod = ""; String encodingMethod = ""; String quoteCharacter = null; String literalCharacter = null; boolean isImageEntity = false; boolean isGZipDataFile = false; boolean isZipDataFile = false; boolean isTarDataFile = false; boolean isSimpleDelimited = true; boolean isCollapseDelimiters = false; TextComplexDataFormat[] formatArray = null; for (int i = 0; i < entityNodeListLength; i++) { if (xpath != null && (xpath.equals(SPATIALRASTERENTITY) || xpath.equals(SPATIALVECTORENTITY))) { isImageEntity = true; } //go through the entities and put the information into the hash. elementId++; Node entityNode = entitiesNodeList.item(i); String id = null; NamedNodeMap entityNodeAttributes = entityNode.getAttributes(); if (entityNodeAttributes != null) { Node idNode = entityNodeAttributes.getNamedItem(ID); if (idNode != null) { id = idNode.getNodeValue(); } } NodeList entityNodeChildren = entityNode.getChildNodes(); for (int j = 0; j < entityNodeChildren.getLength(); j++) { Node childNode = entityNodeChildren.item(j); String childName = childNode.getNodeName(); if (childName.equals("entityName")) { entityName = childNode.getFirstChild().getNodeValue(); } else if (childName.equals("entityDescription")) { entityDescription = childNode.getFirstChild().getNodeValue(); } else if (childName.equals("caseSensitive")) { entityCaseSensitive = childNode.getFirstChild().getNodeValue(); } else if (childName.equals("numberOfRecords")) { entityNumberOfRecords = childNode.getFirstChild().getNodeValue(); /*numRecords = (new Integer(entityNumberOfRecords)) .intValue();*/ } } NodeList attributeOrientationNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/attributeOrientation"); if (attributeOrientationNodeList != null && attributeOrientationNodeList.getLength() > 0) { entityOrientation = attributeOrientationNodeList.item(0).getFirstChild().getNodeValue(); } NodeList numHeaderLinesNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/numHeaderLines"); if ((numHeaderLinesNodeList != null) && (numHeaderLinesNodeList.getLength() > 0)) { Node numHeaderLinesNode = numHeaderLinesNodeList.item(0); if (numHeaderLinesNode != null) { numHeaderLines = numHeaderLinesNode.getFirstChild().getNodeValue(); } } NodeList numFooterLinesNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/numFooterLines"); if ((numFooterLinesNodeList != null) && (numFooterLinesNodeList.getLength() > 0)) { Node numFooterLinesNode = numFooterLinesNodeList.item(0); if (numFooterLinesNode != null) { String numFooterLinesStr = numFooterLinesNode.getFirstChild().getNodeValue(); numFooterLines = (new Integer(numFooterLinesStr.trim())).intValue(); } } // Here is the simple delimited data file NodeList fieldDelimiterNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/simpleDelimited/fieldDelimiter"); if (fieldDelimiterNodeList != null && fieldDelimiterNodeList.getLength() > 0) { fieldDelimiter = fieldDelimiterNodeList.item(0).getFirstChild().getNodeValue(); } NodeList collapseDelimitersNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/simpleDelimited/collapseDelimiters"); if (collapseDelimitersNodeList != null && collapseDelimitersNodeList.getLength() > 0) { String collapseDelimiters = collapseDelimitersNodeList.item(0).getFirstChild().getNodeValue(); if (collapseDelimiters.equalsIgnoreCase("yes")) { isCollapseDelimiters = true; } } NodeList quoteCharacterNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/simpleDelimited/quoteCharacter"); if (quoteCharacterNodeList != null && quoteCharacterNodeList.getLength() > 0) { quoteCharacter = quoteCharacterNodeList.item(0).getFirstChild().getNodeValue(); } NodeList literalCharacterNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/simpleDelimited/literalCharacter"); if (literalCharacterNodeList != null && literalCharacterNodeList.getLength() > 0) { literalCharacter = literalCharacterNodeList.item(0).getFirstChild().getNodeValue(); } // For complex format data file NodeList complexNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/complex"); if (complexNodeList != null && complexNodeList.getLength() > 0) { //log.debug("in handle complex text data format"); isSimpleDelimited = false; Node complexNode = complexNodeList.item(0); NodeList complexChildNodes = complexNode.getChildNodes(); int complexChildNodesLength = complexChildNodes.getLength(); Vector formatVector = new Vector(); for (int k = 0; k < complexChildNodesLength; k++) { Node complexChildNode = complexChildNodes.item(k); if (complexChildNode != null && complexChildNode.getNodeName().equals("textFixed")) { TextWidthFixedDataFormat textWidthFixedDataFormat = handleTextFixedDataFormatNode( complexChildNode); if (textWidthFixedDataFormat != null) { formatVector.add(textWidthFixedDataFormat); //complexFormatsNumber++; } } else if (complexChildNode != null && complexChildNode.getNodeName().equals("textDelimited")) { TextDelimitedDataFormat textDelimitedDataFormat = handleComplexDelimitedDataFormatNode( complexChildNode); if (textDelimitedDataFormat != null) { formatVector.add(textDelimitedDataFormat); //complexFormatsNumber++; } } } // Transfer vector to array numberOfComplexFormats = formatVector.size(); formatArray = new TextComplexDataFormat[numberOfComplexFormats]; for (int j = 0; j < numberOfComplexFormats; j++) { formatArray[j] = (TextComplexDataFormat) formatVector.elementAt(j); } } NodeList recordDelimiterNodeList = xpathapi.selectNodeList(entityNode, "physical/dataFormat/textFormat/recordDelimiter"); if ((recordDelimiterNodeList != null) && (recordDelimiterNodeList.getLength() > 0)) { recordDelimiter = recordDelimiterNodeList.item(0).getFirstChild().getNodeValue(); } else { recordDelimiter = "\\r\\n"; } // Get the distribution information NodeList urlNodeList = xpathapi.selectNodeList(entityNode, "physical/distribution/online/url"); if (urlNodeList != null && urlNodeList.getLength() > 0) { onlineUrl = urlNodeList.item(0).getFirstChild().getNodeValue(); if (isDebugging) { //log.debug("The url is "+ onlineUrl); } } // Get the compressionMethod information NodeList compressionMethodNodeList = xpathapi.selectNodeList(entityNode, "physical/compressionMethod"); if (compressionMethodNodeList != null && compressionMethodNodeList.getLength() > 0) { compressionMethod = compressionMethodNodeList.item(0).getFirstChild().getNodeValue(); if (isDebugging) { //log.debug("Compression method is "+compressionMethod); } if (compressionMethod != null && compressionMethod.equals(Entity.GZIP)) { isGZipDataFile = true; } else if (compressionMethod != null && compressionMethod.equals(Entity.ZIP)) { isZipDataFile = true; } } // Get encoding method info (mainly for tar file) NodeList encodingMethodNodeList = xpathapi.selectNodeList(entityNode, "physical/encodingMethod"); if (encodingMethodNodeList != null && encodingMethodNodeList.getLength() > 0) { encodingMethod = encodingMethodNodeList.item(0).getFirstChild().getNodeValue(); if (isDebugging) { //log.debug("encoding method is "+encodingMethod); } if (encodingMethod != null && encodingMethod.equals(Entity.TAR)) { isTarDataFile = true; } } if (entityOrientation.trim().equals("column")) { entityOrientation = Entity.COLUMNMAJOR; } else { entityOrientation = Entity.ROWMAJOR; } if (entityCaseSensitive.equals("yes")) { entityCaseSensitive = "true"; } else { entityCaseSensitive = "false"; } entityObject = new Entity(id, entityName.trim(), entityDescription.trim(), new Boolean(entityCaseSensitive), entityOrientation, new Integer(entityNumberOfRecords).intValue()); entityObject.setNumHeaderLines((new Integer(numHeaderLines)).intValue()); entityObject.setNumFooterLines(numFooterLines); entityObject.setSimpleDelimited(isSimpleDelimited); // For simple delimited data file if (fieldDelimiter != null) { entityObject.setDelimiter(fieldDelimiter); } if (quoteCharacter != null) { entityObject.setQuoteCharacter(quoteCharacter); } if (literalCharacter != null) { entityObject.setLiteralCharacter(literalCharacter); } entityObject.setCollapseDelimiters(isCollapseDelimiters); entityObject.setRecordDelimiter(recordDelimiter); entityObject.setURL(onlineUrl); entityObject.setCompressionMethod(compressionMethod); entityObject.setIsImageEntity(isImageEntity); entityObject.setHasGZipDataFile(isGZipDataFile); entityObject.setHasZipDataFile(isZipDataFile); entityObject.setHasTarDataFile(isTarDataFile); entityObject.setPackageId(packageId); try { NodeList attributeListNodeList = xpathapi.selectNodeList(entityNode, "attributeList"); processAttributeList(xpathapi, attributeListNodeList, entityObject); entityObject.setDataFormatArray(formatArray); } catch (Exception e) { throw new Exception("Error parsing attributes: " + e.getMessage()); } //entityHash.put(Integer.toString(elementId), entityObject); emlDataPackage.add(entityObject); //fileHash.put(elementId, onlineUrl); } // end for loop }
From source file:org.eclipse.swt.examples.fileviewer.FileViewer.java
/** * Notifies the application components that a new current directory has been * selected//from w ww. ja v a 2 s. c o m * * @param dir * the directory that was selected, null is ignored */ void notifySelectedDirectory(File dir, boolean select) { if (dir == null) return; // Log.i("notifySelectedDirectory:" + dir.getPath()); if (currentDirectory != null && dir.equals(currentDirectory)) return; currentDirectory = dir; notifySelectedFiles(null); /* * Shell: Sets the title to indicate the selected directory */ shell.setText(getResourceString("Title", new Object[] { mDeviceName, currentDirectory.getPath() })); /* * Table view: Displays the contents of the selected directory. */ workerUpdate(dir, false); /* * Combo view: Sets the combo box to point to the selected directory. */ final File[] comboRoots = (File[]) combo.getData(COMBODATA_ROOTS); int comboEntry = -1; if (comboRoots != null) { for (int i = 0; i < comboRoots.length; ++i) { if (dir.equals(comboRoots[i])) { comboEntry = i; break; } } } if (comboEntry == -1) combo.setText(dir.getPath()); else combo.select(comboEntry); /* * Tree view: If not already expanded, recursively expands the parents * of the specified directory until it is visible. */ Vector /* of File */ path = new Vector(); // Build a stack of paths from the root of the tree while (dir != null) { path.add(dir); dir = dir.getParentFile(); } // Recursively expand the tree to get to the specified directory TreeItem[] items = tree.getItems(); TreeItem lastItem = null; for (int i = path.size() - 1; i >= 0; --i) { final File pathElement = (File) path.elementAt(i); // Search for a particular File in the array of tree items // No guarantee that the items are sorted in any recognizable // fashion, so we'll // just sequential scan. There shouldn't be more than a few thousand // entries. TreeItem item = null; for (int k = 0; k < items.length; ++k) { item = items[k]; if (item.isDisposed()) continue; final File itemFile = (File) item.getData(TREEITEMDATA_FILE); if (itemFile != null && itemFile.equals(pathElement)) break; } if (item == null) break; lastItem = item; if (i != 0 && !item.getExpanded()) { treeExpandItem(item); item.setExpanded(true); } items = item.getItems(); } if (select) tree.setSelection((lastItem != null) ? new TreeItem[] { lastItem } : new TreeItem[0]); }
From source file:com.netscape.cms.servlet.csadmin.ConfigurationUtils.java
public static byte[] getX509Cert(String nickname, Vector<Vector<Object>> cert_collection) throws CertificateException { for (int i = 0; i < cert_collection.size(); i++) { Vector<Object> v = cert_collection.elementAt(i); byte[] b = (byte[]) v.elementAt(0); X509CertImpl impl = null;/*from w ww . j av a 2 s . c o m*/ impl = new X509CertImpl(b); Principal subjectdn = impl.getSubjectDN(); if (LDAPDN.equals(subjectdn.toString(), nickname)) return b; } return null; }
From source file:de.juwimm.cms.remote.ClientServiceSpringImpl.java
private String getParents4View(ViewComponentHbm viewComponent) { try {//from w w w.jav a 2 s . c o m if (viewComponent.getParent().isRoot()) { return "\\"; } } catch (Exception ex) { return "\\"; } Vector<ViewComponentHbm> vec = new Vector<ViewComponentHbm>(); ViewComponentHbm parentView = viewComponent.getParent(); while (parentView.getAssignedUnit() == null) { vec.addElement(parentView); parentView = parentView.getParent(); try { if (parentView.isRoot()) { break; } } catch (Exception ex) { break; } } if (parentView.getAssignedUnit() != null) { vec.addElement(parentView); } StringBuffer sb = new StringBuffer("\\"); for (int i = vec.size() - 1; i > -1; i--) { sb.append((vec.elementAt(i)).getUrlLinkName()); if (i != 0) { sb.append("\\"); } } sb.append("\\").append(viewComponent.getUrlLinkName()); return sb.toString(); }
From source file:cms.service.template.TemplateUtility.java
public String[] getGridDataArray(String data, String rowseperator, String columnSeperator) { Vector rowData = getGridRowData(data, rowseperator); String[] retStr = new String[1]; int count = 0; for (int i = 0; i < rowData.size(); i++) { StringTokenizer st = new StringTokenizer((String) rowData.elementAt(i), columnSeperator); int length = st.countTokens() * rowData.size(); retStr = new String[length]; while (st.hasMoreTokens()) { //logger.info("Col value="+st.nextToken()); retStr[count] = st.nextToken(); count++;//from www. j a v a2s. co m } if (count == 0) retStr[count] = (String) rowData.elementAt(i); } return (retStr); }