List of usage examples for java.util Vector elementAt
public synchronized E elementAt(int index)
From source file:net.sf.mzmine.modules.visualization.ida.IDABottomPanel.java
/** * Returns a peak list with the top peaks defined by the parameter * "threshold"//from w w w .j a va2s .c om */ PeakList getTopThresholdPeakList(int threshold) { PeakList selectedPeakList = (PeakList) peakListSelector.getSelectedItem(); if (selectedPeakList == null) return null; SimplePeakList newList = new SimplePeakList(selectedPeakList.getName(), selectedPeakList.getRawDataFiles()); Vector<PeakListRow> peakRows = new Vector<PeakListRow>(); Range<Double> mzRange = selectedPeakList.getRowsMZRange(); Range<Double> rtRange = selectedPeakList.getRowsRTRange(); PeakThresholdMode selectedPeakOption = (PeakThresholdMode) thresholdCombo.getSelectedItem(); if (selectedPeakOption == PeakThresholdMode.TOP_PEAKS_AREA) { XYPlot xyPlot = masterFrame.getPlot().getXYPlot(); org.jfree.data.Range yAxis = xyPlot.getRangeAxis().getRange(); org.jfree.data.Range xAxis = xyPlot.getDomainAxis().getRange(); rtRange = Range.closed(xAxis.getLowerBound(), xAxis.getUpperBound()); mzRange = Range.closed(yAxis.getLowerBound(), yAxis.getUpperBound()); } for (PeakListRow peakRow : selectedPeakList.getRows()) { if (mzRange.contains(peakRow.getAverageMZ()) && rtRange.contains(peakRow.getAverageRT())) { peakRows.add(peakRow); } } Collections.sort(peakRows, new PeakListRowSorter(SortingProperty.Intensity, SortingDirection.Descending)); if (threshold > peakRows.size()) threshold = peakRows.size(); for (int i = 0; i < threshold; i++) { newList.addRow(peakRows.elementAt(i)); } return newList; }
From source file:JavaTron.AudioTron.java
/** * Create URI arguments//w w w.j a v a 2 s . co m * * @param buffer the buffer to append the output string to * @param args the input arguments */ private void createURIArgs(StringBuffer buffer, Vector args) throws UnsupportedEncodingException { for (int i = 0; i < args.size(); i += 2) { if (i > 0) { buffer.append("&"); } buffer.append(URLEncoder.encode(args.elementAt(i).toString(), "UTF-8")); buffer.append("="); buffer.append(URLEncoder.encode(args.elementAt(i + 1).toString(), "UTF-8")); } }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoCategorizedDocuments.java
@SuppressWarnings("unchecked") private void fetchChildrenForNotesDocument() throws NotesException { // LOGGER.info(getCallingMethod()+":"+"Start fetchChildrenForNotesDocument; Fetching children for doc with UNID=" // + this.getDocumentUniqueID()); Document curDoc = null;/*from www . jav a2 s.co m*/ String docID = null; Vector<IDAVResource> resMembers = null; this.setMembers(new Vector<IDAVResource>()); String notesURL = this.getInternalAddress(); DAVRepositoryDominoCategorizedDocuments repository = (DAVRepositoryDominoCategorizedDocuments) this .getRepository(); // LOGGER.info("Internal Address is "+notesURL); // LOGGER.info("PublicHref is "+this.getPublicHref()); curDoc = DominoProxy.getDocument(notesURL); // LOGGER.info(getCallingMethod()+":"+"Currdoc not null ; OK"); if (curDoc == null) { LOGGER.error("Could not retrieve the document"); return; } boolean readOnly = this.checkReadOnlyAccess(curDoc); Date curCreationDate = curDoc.getCreated().toJavaDate(); if (curDoc.hasItem("DAVCreated")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVCreated"); Object time = times.elementAt(0); if (time.getClass().getName().endsWith("DateTime")) { curCreationDate = ((DateTime) time).toJavaDate(); } } Date curChangeDate = curDoc.getLastModified().toJavaDate(); if (curDoc.hasItem("DAVModified")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVModified"); Object time = times.elementAt(0); if (time.getClass().getName().endsWith("DateTime")) { curChangeDate = ((DateTime) time).toJavaDate(); } } this.setCreationDate(curCreationDate); this.setLastModified(curChangeDate); this.setReadOnly(readOnly); // Read the repository list to get the view try { LOGGER.info(getCallingMethod() + ":" + "Currdoc not null ; OK; Has UNID=" + curDoc.getUniversalID()); docID = curDoc.getUniversalID(); LOGGER.info(getCallingMethod() + ":" + "Openend document " + docID); // No children if there are no attachments if (!curDoc.hasEmbedded()) { // folder ViewEntryCollection responses = repository .getAllEntriesByKey(curDoc.getItemValueString(repository.getPubHrefField())); LOGGER.info(getCallingMethod() + ":" + "Get Responses..."); int numOfResponses = responses.getCount(); LOGGER.info(getCallingMethod() + ":" + "Current doc has " + String.valueOf(numOfResponses) + " responses"); if (numOfResponses > 1) { resMembers = new Vector<IDAVResource>(numOfResponses - 1); LOGGER.info(getCallingMethod() + ":" + "Start Process responses"); lotus.domino.ViewEntry ve = responses.getFirstEntry(); ve = responses.getNextEntry(); Document docResp = null; while (ve != null) { docResp = ve.getDocument(); // if(docResp.getUniversalID()!=docID){ LOGGER.info(getCallingMethod() + ":" + "Doc response has unid=" + docResp.getUniversalID() + "; Try find attachment(s)"); Vector<String> allEmbedded = DominoProxy.evaluate("@AttachmentNames", docResp); int numOfAttachments = allEmbedded.isEmpty() ? 0 : (allEmbedded.get(0).toString().equals("") ? 0 : allEmbedded.size()); LOGGER.info(getCallingMethod() + ":" + "Doc has " + String.valueOf(numOfAttachments) + " attachment(s)"); if (numOfAttachments == 0) { // No attachments in here! LOGGER.info(getCallingMethod() + ":" + "Doc " + docResp.getUniversalID() + " response has no attachment; is a directory; Create resource for it"); DAVResourceDominoCategorizedDocuments resAtt = new DAVResourceDominoCategorizedDocuments( this.getRepository(), this.getPublicHref() + "/" + docResp.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())) .getDirectoryField()), true); resAtt.setup(docResp); if (resAtt != null) { LOGGER.info(getCallingMethod() + ":" + "Created DavResourceDomino Attachments from getDocumentResource-OK"); if (resAtt.filter()) { this.getMembers().add(resAtt); } resMembers.add(resAtt); LOGGER.info(getCallingMethod() + ":" + "Resource successfull added"); } } else { LOGGER.info(getCallingMethod() + ":" + "Doc response " + docResp.getUniversalID() + " has attachments >0; "); String curAttName = allEmbedded.get(0).toString(); if ((curAttName != null) && (!curAttName.equals(""))) { LOGGER.info(getCallingMethod() + ":" + "Doc response fitrst attachment has name " + curAttName); DAVResourceDominoCategorizedDocuments resAtt = new DAVResourceDominoCategorizedDocuments( this.getRepository(), this.getPublicHref() + "/" + curAttName, true); resAtt.setup(docResp); if (resAtt != null) { // Now add it to the Vector LOGGER.info(getCallingMethod() + ":" + "Created DAVResourceDominoDocuments with getAttachmentResource-OK!\n Start load resource"); // resMembers.add(curAttachment); if (resAtt.filter()) { this.getMembers().add(resAtt); } LOGGER.info(getCallingMethod() + ":" + "Resource successfull added"); Date viewDate = this.getLastModified(); Date docDate = resAtt.getLastModified(); if (viewDate == null || (docDate != null && viewDate.before(docDate))) { this.setLastModified(docDate); } LOGGER.info(getCallingMethod() + ":" + "Resource successfull updated last modified"); LOGGER.info(getCallingMethod() + ":" + "Processing complete attachment:" + curAttName); } } } LOGGER.info(getCallingMethod() + ":" + "Start recycling.."); // Document docTmp=docResp; // } //end // if(docResp.getUniversalID()!=curDoc.getUniversalID()){ ve = responses.getNextEntry(); // docTmp.recycle(); LOGGER.info(getCallingMethod() + ":" + "Recycling OK!"); } // end while } // end if numresp>0 try { LOGGER.info(getCallingMethod() + ":" + "Final recycling.."); if (curDoc != null) { curDoc.recycle(); } LOGGER.info(getCallingMethod() + ":" + "End FINAL recycling OK!"); } catch (Exception e) { LOGGER.error(e); } // Now save back the members to the main object LOGGER.info(getCallingMethod() + ":" + "Finish processing current doc as a directory; No more attachment(s) in it; Return!"); return; } // Get all attachments LOGGER.info(getCallingMethod() + ":" + "Current doc has attachments!"); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", curDoc); int numOfAttchments = allEmbedded.size(); if (numOfAttchments == 0) { // No attachments in here! LOGGER.info(getCallingMethod() + ":" + "Something wrong: Doc + " + docID + " has no attachments (@AttachmentNames)"); return; } LOGGER.info(getCallingMethod() + ":" + docID + " has " + new Integer(numOfAttchments).toString() + " attachment(s)"); // Initialize an empty vector at the right size // We might need to enlarge it if we have more attachments resMembers = new Vector<IDAVResource>(numOfAttchments); LOGGER.info(getCallingMethod() + ":" + "Start processing attachment(s).."); for (int i = 0; i < numOfAttchments; i++) { String curAttName = allEmbedded.get(i).toString(); DAVResourceDominoCategorizedDocuments curAttachment = getDocumentResource(curDoc); if (curAttachment != null) { // Now add it to the Vector LOGGER.info(getCallingMethod() + ":" + "Resource attachment successfully created!"); // resMembers.add(curAttachment); if (curAttachment.filter()) { this.getMembers().add(curAttachment); } LOGGER.info("Resource attachment successfully added: " + curAttName + "; OK!"); } else { LOGGER.error("Could not load attachment#" + curAttName + "#"); } } } catch (NotesException ne) { LOGGER.error(ne); } catch (Exception e) { LOGGER.error(e); } finally { try { LOGGER.info(getCallingMethod() + ":" + "Final block; Start Recycling!"); if (curDoc != null) { curDoc.recycle(); } } catch (Exception e) { LOGGER.error(e); } // Now save back the members to the main object // this.setMembers(resMembers); LOGGER.info("Completed reading attachments resources from Notes document; OK!"); } }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoCategorizedDocuments.java
private void setup(Document curDoc) { try {//from w w w .jav a2 s . c o m DAVRepositoryDominoCategorizedDocuments rep = (DAVRepositoryDominoCategorizedDocuments) this .getRepository(); LOGGER.info("Start setup with doc ..." + curDoc.getItemValueString(rep.getPubHrefField())); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", curDoc); // LOGGER.info(getCallingMethod()+":"+"All Embedded computed"); int numOfAttachments = allEmbedded.isEmpty() ? 0 : (allEmbedded.get(0).equals("") ? 0 : allEmbedded.size()); String docID = curDoc.getUniversalID(); this.setDocumentUniqueID(docID); LOGGER.info("Num of attachments=" + new Integer(numOfAttachments).toString()); boolean readOnly = this.checkReadOnlyAccess(curDoc); this.setReadOnly(readOnly); // LOGGER.info("Creation date for "+curDoc.getUniversalID()+" ="+curDoc.getCreated().toString()+"; Time zone="+curDoc.getCreated().getZoneTime()+"; Local time="+curDoc.getCreated().getLocalTime()); Date curCreationDate = curDoc.getCreated().toJavaDate(); // LOGGER.info("Current date in Java is "+curCreationDate.toString()+"Time zone="+new // Integer(curCreationDate.getTimezoneOffset()).toString()+"; Locale time is:"+curCreationDate.toLocaleString()); if (curDoc.hasItem("DAVCreated")) { // Item davCreated=curDoc.getFirstItem("DAVCreated"); @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVCreated"); if (times != null) { if (times.size() > 0) { Object time = times.elementAt(0); if (time != null) { if (time.getClass().getName().endsWith("DateTime")) { curCreationDate = ((DateTime) time).toJavaDate(); if (curCreationDate == null) { curCreationDate = curDoc.getCreated().toJavaDate(); } } } } } } Date curChangeDate = curDoc.getLastModified().toJavaDate(); if (curDoc.hasItem("DAVModified")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVModified"); if (times != null) { if (times.size() > 0) { Object time = times.elementAt(0); if (time != null) { if (time.getClass().getName().endsWith("DateTime")) { curChangeDate = ((DateTime) time).toJavaDate(); if (curChangeDate == null) { curChangeDate = curDoc.getLastModified().toJavaDate(); } } } } } } this.setCreationDate(curCreationDate); this.setLastModified(curChangeDate); // LOGGER.info("Creation date is set to "+this.getCreationDate().toString()); // LOGGER.info("Last modified date is set to "+this.getLastModified().toString()); String pubHRef = ((IDAVAddressInformation) this.getRepository()).getPublicHref(); // LOGGER.info("THIS getpublichref="+this.getPublicHref()); String curAttName = null; if (numOfAttachments == 0) { // LOGGER.info(getCallingMethod()+":"+"Start setting resource"); String name = curDoc.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())).getDirectoryField()); this.setName(name); if (this.getPublicHref().equals("")) { this.setPublicHref(pubHRef + curDoc.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())).getPubHrefField())); } this.setCollection(true); this.setInternalAddress( ((IDAVAddressInformation) this.getRepository()).getInternalAddress() + "/" + docID); this.setResourceType("NotesDocument"); this.setMember(false); this.setContentLength(0L); // this.fetchChildren(); } else { curAttName = allEmbedded.get(0).toString(); // LOGGER.info("Attachment name is "+curAttName); this.setMember(true); this.setResourceType("NotesAttachment"); if (this.getPublicHref().equals("")) { try { this.setPublicHref(pubHRef + curDoc.getItemValueString( ((DAVRepositoryDominoCategorizedDocuments) (this.getRepository())) .getPubHrefField())); } catch (Exception e) { LOGGER.error(e); } // this.setPublicHref( pubHRef+"/"+curAttName); } this.setInternalAddress(((IDAVAddressInformation) this.getRepository()).getInternalAddress() + "/" + docID + "/$File/" + curAttName); this.setCollection(false); this.setName(curAttName); EmbeddedObject curAtt = curDoc.getAttachment(curAttName); if (curAtt == null) { return; } Long curSize = new Long(curAtt.getFileSize()); this.setContentLength(curSize); } // LOGGER.info("Current res realized! pubHREF="+this.getPublicHref()+"; Internal Address="+this.getInternalAddress()+"; "); } catch (NotesException ne) { LOGGER.error("ERROR! Can not set; " + ne.getMessage()); } }
From source file:alter.vitro.vgw.service.query.wrappers.ResponseAggrMsg.java
/** * Constructor method./* w ww . j a va 2s.c o m*/ * Creates a new instance of ResponseAggrMsg * * @param queryDefID The unique ID for the query definition that this response belongs to. This is different from the queryId of the JXTA message that this * message replies to. * @param responderName The Name of the peer that sends this response. * @param responderPeerID The jxta unique Peer ID of the peer that sends this response. * @param allValuesVec A vector of ReqResultOverData objects, that contain results for a requested Function. * @param qCount the query count of the JXTA message that this response replies to. */ public ResponseAggrMsg(String queryDefID, String responderPeerID, String responderName, Vector<ReqResultOverData> allValuesVec, int qCount) { try { javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext .newInstance("alter.vitro.vgw.service.query.xmlmessages.response"); // create an object to marshal ObjectFactory theFactory = new ObjectFactory(); response = theFactory.createQueryResponseType(); } catch (javax.xml.bind.JAXBException je) { je.printStackTrace(); response = new QueryResponseType(); } setDeployStatus(DEPLOY_STATUS_SERVICE_UNKNOWN); response.setQueryDefID(queryDefID); response.setResponderPeerID(responderPeerID); response.setResponderName(responderName); response.setQueryCount(Integer.toString(qCount)); response.setMessageType(ResponseAggrMsg.getThisMsgType()); RespFunctionsListType rflType = new RespFunctionsListType(); response.setReqFunctionsList(rflType); // //RespFunctionsListType rflType = response.getReqFunctionsList(); List<RespFunctionType> rfList = rflType.getReqFunction(); // For every function in the Vector create a ReqResultOverData with all data values "timed out" for the sensors defined here! for (int i = 0; i < allValuesVec.size(); i++) { rfList.add(allValuesVec.elementAt(i)); } response.setReqFunctionsList(rflType); ServContinuationListType servContListType = new ServContinuationListType(); response.setServContList(servContListType); List<ServContReplcItemType> pListOfReplcItems = servContListType.getServContReplcItem(); // for (int i = 0; i < allReplceStructVec.size(); i++) { // pListOfReplcItems.add(allReplceStructVec.elementAt(i)); //} }
From source file:org.ecoinformatics.seek.datasource.darwincore.DarwinCoreDataSource.java
/** * //w w w . j a v a 2 s. c o m * @param vector * */ private Vector[] transformVectorToArray(Vector vector) { if (vector == null) { return null; } int size = vector.size(); Vector[] array = new Vector[size]; for (int i = 0; i < size; i++) { array[i] = (Vector) vector.elementAt(i); } return array; }
From source file:com.pingtel.sipviewer.SIPViewerFrame.java
protected void applyData(Vector vData) { m_model.clear();//from ww w . ja v a 2s . c o m if (m_sortBranchNodes) { // Do some magic to adjust for the case where the response // shows up just before the request. SipBranchData current = null; SipBranchData previous = null; String strCurrentBranchId; String strPreviousBranchId; for (int i = vData.size() - 1; i > 0; i--) { current = (SipBranchData) vData.elementAt(i); strCurrentBranchId = current.getThisBranchId(); previous = (SipBranchData) vData.elementAt(i - 1); strPreviousBranchId = current.getThisBranchId(); if ((strCurrentBranchId != null) && (strCurrentBranchId.length() > 0) && (strPreviousBranchId != null) && (strPreviousBranchId.length() > 0) && (strCurrentBranchId.equals(strPreviousBranchId)) && (current.isRequest()) && (!previous.isRequest()) && (current.getMethod() != "ack")) { vData.set(i, previous); vData.set(i - 1, current); System.out.println("Req/Resp swapped for branchID: " + strCurrentBranchId); } } } SipBranchData data = null; // loop over all the data elements and add them // to the model for (int i = 0; i < vData.size(); i++) { data = (SipBranchData) vData.elementAt(i); // pass in the for loop index since it is used // to set the displayIndex of each message, this // displayIndex is used to determine where the // message is displayed vertically and weather // it is visible or not (displayIndex of // -1 is invisible) addEntryToModel(data, i); } // Reset the scroll bar to the top. JScrollBar scroll = m_scrollPane.getVerticalScrollBar(); scroll.setValue(scroll.getMinimum()); // Revalidate to make sure the drawing pane is resized to match the // data. m_body.revalidate(); }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoDocuments.java
@SuppressWarnings("unchecked") private void fetchChildrenForNotesDocument() throws NotesException { // LOGGER.info(getCallingMethod()+":"+"Start fetchChildrenForNotesDocument; Fetching children for doc with UNID=" // + this.getDocumentUniqueID()); Document curDoc = null;//from ww w . j ava 2 s. c om // String docID = null; Vector<IDAVResource> resMembers = new Vector<IDAVResource>(); this.setMembers(resMembers); String notesURL = this.getInternalAddress(); // LOGGER.info("Internal Address is "+notesURL); // LOGGER.info("PublicHref is "+this.getPublicHref()); curDoc = DominoProxy.getDocument(notesURL); // LOGGER.info(getCallingMethod()+":"+"Currdoc not null ; OK"); if (curDoc == null) { LOGGER.error("Could not retrieve the document"); return; } boolean readOnly = this.checkReadOnlyAccess(curDoc); Date curCreationDate = curDoc.getCreated().toJavaDate(); if (curDoc.hasItem("DAVCreated")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVCreated"); Object time = times.elementAt(0); if (time.getClass().getName().endsWith("DateTime")) { curCreationDate = ((DateTime) time).toJavaDate(); } } Date curChangeDate = curDoc.getLastModified().toJavaDate(); if (curDoc.hasItem("DAVModified")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVModified"); Object time = times.elementAt(0); if (time.getClass().getName().endsWith("DateTime")) { curChangeDate = ((DateTime) time).toJavaDate(); } } this.setCreationDate(curCreationDate); this.setLastModified(curChangeDate); this.setReadOnly(readOnly); // Read the repository list to get the view try { // LOGGER.info(getCallingMethod()+":"+"Currdoc not null ; OK; Has UNID="+curDoc.getUniversalID()); // docID = curDoc.getUniversalID(); // LOGGER.info(getCallingMethod()+":"+"Openend document " + docID); // No children if there are no attachments if (!curDoc.hasEmbedded()) { // if(1==1){return;} // E.C. It is a directory, so fetch the children documents as // resources // LOGGER.info(getCallingMethod()+":"+"Current doc with unid="+curDoc.getUniversalID()+" has no embedded files. Try to find children"); DocumentCollection responses = curDoc.getResponses(); // LOGGER.info(getCallingMethod()+":"+"Get Responses..."); int numOfResponses = responses.getCount(); // LOGGER.info(getCallingMethod()+":"+"Current doc has "+String.valueOf(numOfResponses) // + " responses"); if (numOfResponses > 0) { resMembers = new Vector<IDAVResource>(numOfResponses); // LOGGER.info(getCallingMethod()+":"+"Start Process responses"); Document docResp = responses.getFirstDocument(); while (docResp != null) { // LOGGER.info(getCallingMethod()+":"+"Doc response has unid="+docResp.getUniversalID()+ // "; Try find attachment(s)"); Vector<String> allEmbedded = DominoProxy.evaluate("@AttachmentNames", docResp); int numOfAttachments = allEmbedded.isEmpty() ? 0 : (allEmbedded.get(0).toString().equals("") ? 0 : allEmbedded.size()); // LOGGER.info(getCallingMethod()+":"+"Doc has "+ // String.valueOf(numOfAttachments)+" attachment(s)"); if (numOfAttachments == 0) { // No attachments in here! // LOGGER.info(getCallingMethod()+":"+"Doc "+docResp.getUniversalID()+" response has no attachment; is a directory; Create resource for it"); DAVResourceDominoDocuments resAtt = new DAVResourceDominoDocuments(this.getRepository(), this.getPublicHref() + "/" + docResp.getItemValueString( ((DAVRepositoryDominoDocuments) (this.getRepository())) .getDirectoryField()), true); resAtt.setup(docResp); LOGGER.info(getCallingMethod() + ":" + "Created DavResourceDomino Attachments from getDocumentResource-OK"); this.getMembers().add(resAtt); // resMembers.add(resAtt); LOGGER.info(getCallingMethod() + ":" + "Resource successfull added"); } else { // LOGGER.info(getCallingMethod()+":"+"Doc response "+docResp.getUniversalID()+" has attachments >0; "); String curAttName = allEmbedded.get(0).toString(); if ((curAttName != null) && (!curAttName.equals(""))) { // LOGGER.info(getCallingMethod()+":"+"Doc response fitrst attachment has name "+curAttName); DAVResourceDominoDocuments resAtt = new DAVResourceDominoDocuments( this.getRepository(), this.getPublicHref() + "/" + curAttName, true); resAtt.setup(docResp); if (resAtt != null) { // Now add it to the Vector // LOGGER.info(getCallingMethod()+":"+"Created DAVResourceDominoDocuments with getAttachmentResource-OK!\n Start load resource"); // resMembers.add(curAttachment); this.getMembers().add(resAtt); // LOGGER.info(getCallingMethod()+":"+"Resource successfull added"); Date viewDate = this.getLastModified(); Date docDate = resAtt.getLastModified(); if (viewDate == null || (docDate != null && viewDate.before(docDate))) { this.setLastModified(docDate); } LOGGER.info(getCallingMethod() + ":" + "Resource successfull updated last modified"); // LOGGER.info(getCallingMethod()+":"+"Processing complete attachment:" // + curAttName); } } } // LOGGER.info(getCallingMethod()+":"+"Start recycling.."); docResp = responses.getNextDocument(docResp); // LOGGER.info(getCallingMethod()+":"+"Recycling OK!"); } // end while } // end if numresp>0 try { // LOGGER.info(getCallingMethod()+":"+"Final recycling.."); if (curDoc != null) { // curDoc.recycle(); } // LOGGER.info(getCallingMethod()+":"+"End FINAL recycling OK!"); } catch (Exception e) { LOGGER.error(e); } // Now save back the members to the main object // LOGGER.info(getCallingMethod()+":"+"Finish processing current doc as a directory; No more attachment(s) in it; Return!"); return; } // Get all attachments // LOGGER.info(getCallingMethod()+":"+"Current doc has attachments!"); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", curDoc); int numOfAttchments = allEmbedded.size(); if (numOfAttchments == 0) { // No attachments in here! // LOGGER.info(getCallingMethod()+":"+"Something wrong: Doc + "+docID // + " has no attachments (@AttachmentNames)"); return; } // LOGGER.info(getCallingMethod()+":"+docID + " has " + new // Integer(numOfAttchments).toString() + " attachment(s)"); // Initialize an empty vector at the right size // We might need to enlarge it if we have more attachments resMembers = new Vector<IDAVResource>(numOfAttchments); // LOGGER.info(getCallingMethod()+":"+"Start processing attachment(s).."); for (int i = 0; i < numOfAttchments; i++) { String curAttName = allEmbedded.get(i).toString(); DAVResourceDominoDocuments curAttachment = getDocumentResource(curDoc); if (curAttachment != null) { // Now add it to the Vector // LOGGER.info(getCallingMethod()+":"+"Resource attachment successfully created!"); // resMembers.add(curAttachment); this.getMembers().add(curAttachment); // LOGGER.info("Resource attachment successfully added: " + // curAttName+"; OK!"); } else { LOGGER.error("Could not load attachment#" + curAttName + "#"); } } } catch (NotesException ne) { LOGGER.error(ne); } catch (Exception e) { LOGGER.error(e); } finally { try { // LOGGER.info(getCallingMethod()+":"+"Final block; Start Recycling!"); if (curDoc != null) { // curDoc.recycle(); } } catch (Exception e) { LOGGER.error(e); } // Now save back the members to the main object // this.setMembers(resMembers); // LOGGER.info("Completed reading attachments resources from Notes document; OK!"); } }
From source file:net.sourceforge.floggy.persistence.Weaver.java
/** * DOCUMENT ME!/*from ww w .j a va2 s. c om*/ * * @throws CannotCompileException DOCUMENT ME! * @throws IOException DOCUMENT ME! * @throws NotFoundException DOCUMENT ME! */ protected void addPersistableMetadataManagerClass() throws CannotCompileException, IOException, NotFoundException { alreadyProcessedMetadatas.addAll(configuration.getPersistableMetadatas()); Set metadatas = alreadyProcessedMetadatas; StringBuffer buffer = new StringBuffer(); buffer.append("public static void init() throws Exception {\n"); buffer.append("rmsBasedMetadatas = new java.util.Hashtable();\n"); buffer.append("classBasedMetadatas = new java.util.Hashtable();\n"); buffer.append("java.util.Hashtable persistableImplementations = null;\n"); buffer.append("java.util.Vector indexMetadatas = null;\n"); buffer.append("java.util.Vector fields = null;\n"); for (Iterator iterator = metadatas.iterator(); iterator.hasNext();) { PersistableMetadata metadata = (PersistableMetadata) iterator.next(); boolean isAbstract = metadata.isAbstract(); String className = metadata.getClassName(); String superClassName = metadata.getSuperClassName(); String[] fieldNames = metadata.getFieldNames(); int[] fieldTypes = metadata.getFieldTypes(); Hashtable persistableImplementations = metadata.getPersistableImplementations(); String recordStoreName = metadata.getRecordStoreName(); int persistableStrategy = metadata.getPersistableStrategy(); Vector indexMetadatas = metadata.getIndexMetadatas(); String[] descendents = metadata.getDescendents(); StringBuffer fieldNamesBuffer = new StringBuffer("new String["); StringBuffer fieldTypesBuffer = new StringBuffer("new int["); boolean addHeader = true; for (int i = 0; i < fieldNames.length; i++) { if (addHeader) { fieldNamesBuffer.append("]{"); fieldTypesBuffer.append("]{"); addHeader = false; } fieldNamesBuffer.append("\""); fieldNamesBuffer.append(fieldNames[i]); fieldNamesBuffer.append("\","); fieldTypesBuffer.append(fieldTypes[i]); fieldTypesBuffer.append(","); } if (addHeader) { fieldNamesBuffer.append("0]"); fieldTypesBuffer.append("0]"); } else { fieldNamesBuffer.deleteCharAt(fieldNamesBuffer.length() - 1); fieldNamesBuffer.append("}"); fieldTypesBuffer.deleteCharAt(fieldTypesBuffer.length() - 1); fieldTypesBuffer.append("}"); } if ((persistableImplementations != null) && !persistableImplementations.isEmpty()) { buffer.append("persistableImplementations = new java.util.Hashtable();\n"); Enumeration enumeration = persistableImplementations.keys(); while (enumeration.hasMoreElements()) { String fieldName = (String) enumeration.nextElement(); String classNameOfField = (String) persistableImplementations.get(fieldName); buffer.append("persistableImplementations.put(\""); buffer.append(fieldName); buffer.append("\", \""); buffer.append(classNameOfField); buffer.append("\");\n"); } } else { buffer.append("persistableImplementations = null;\n"); } if ((indexMetadatas != null) && !indexMetadatas.isEmpty()) { buffer.append("indexMetadatas = new java.util.Vector();\n"); Enumeration enumeration = indexMetadatas.elements(); while (enumeration.hasMoreElements()) { IndexMetadata indexMetadata = (IndexMetadata) enumeration.nextElement(); buffer.append("fields = new java.util.Vector();\n"); Vector fields = indexMetadata.getFields(); for (int j = 0; j < fields.size(); j++) { buffer.append("fields.addElement(\""); buffer.append(fields.elementAt(j)); buffer.append("\");\n"); } buffer.append( "indexMetadatas.addElement(new net.sourceforge.floggy.persistence.impl.IndexMetadata(\""); buffer.append(indexMetadata.getRecordStoreName()); buffer.append("\", \""); buffer.append(indexMetadata.getName()); buffer.append("\", fields));\n"); } } else { buffer.append("indexMetadatas = null;\n"); } StringBuffer descendentsBuffer = new StringBuffer("new String["); addHeader = true; if (descendents != null) { for (int i = 0; i < descendents.length; i++) { if (addHeader) { descendentsBuffer.append("]{"); addHeader = false; } descendentsBuffer.append("\""); descendentsBuffer.append(descendents[i]); descendentsBuffer.append("\","); } } if (addHeader) { descendentsBuffer.append("0]"); } else { descendentsBuffer.deleteCharAt(descendentsBuffer.length() - 1); descendentsBuffer.append("}"); } buffer.append("classBasedMetadatas.put(\"" + className + "\", new net.sourceforge.floggy.persistence.impl.PersistableMetadata(" + isAbstract + ", \"" + className + "\", " + ((superClassName != null) ? ("\"" + superClassName + "\", ") : ("null, ")) + fieldNamesBuffer.toString() + ", " + fieldTypesBuffer.toString() + ", persistableImplementations, indexMetadatas, " + "\"" + recordStoreName + "\", " + persistableStrategy + ", " + descendentsBuffer.toString() + "));\n"); } buffer.append("load();\n"); buffer.append("}\n"); CtClass ctClass = this.classpathPool .get("net.sourceforge.floggy.persistence.impl.PersistableMetadataManager"); CtMethod[] methods = ctClass.getMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals("init")) { ctClass.removeMethod(methods[i]); } } ctClass.addMethod(CtNewMethod.make(buffer.toString(), ctClass)); embeddedClassesOutputPool.addClass(ctClass); }
From source file:alter.vitro.vgw.service.query.wrappers.ResponseAggrMsg.java
/** * Constructor method.//from w ww .ja v a 2s . c om * Creates a new instance of ResponseAggrMsg with timed-out entries for all sensors defined and all functions * * @param queryDefID The unique ID for the query definition that this response belongs to. This is different from the queryId of the JXTA message that this * message replies to. * @param responderName The Name of the peer that sends this response. * @param responderPeerID The jxta unique Peer ID of the peer that sends this response. * @param motesSensorsAndFunctionsForQueryVec The map that defines the querried sensors, indexed by the motes that have them * @param functionVec the vector of selected functions to be applied * @param qCount the query count of the JXTA message that this response replies to. */ public ResponseAggrMsg(String queryDefID, String responderPeerID, String responderName, Vector<QueriedMoteAndSensors> motesSensorsAndFunctionsForQueryVec, Vector<ReqFunctionOverData> functionVec, int qCount) { try { javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext .newInstance("alter.vitro.vgw.service.query.xmlmessages.response"); // create an object to marshal ObjectFactory theFactory = new ObjectFactory(); response = theFactory.createQueryResponseType(); } catch (javax.xml.bind.JAXBException je) { je.printStackTrace(); response = new QueryResponseType(); } setDeployStatus(DEPLOY_STATUS_SERVICE_UNKNOWN); response.setQueryDefID(queryDefID); response.setResponderPeerID(responderPeerID); response.setResponderName(responderName); response.setQueryCount(Integer.toString(qCount)); response.setMessageType(ResponseAggrMsg.getThisMsgType()); RespFunctionsListType rflType = new RespFunctionsListType(); response.setReqFunctionsList(rflType); // //RespFunctionsListType rflType = response.getReqFunctionsList(); List<RespFunctionType> rfList = rflType.getReqFunction(); // For every function in the Vector create a ReqResultOverData with all data values "timed out" for the sensors defined here! for (int i = 0; i < functionVec.size(); i++) { rfList.add(new ReqResultOverData(functionVec.elementAt(i).getfuncId(), motesSensorsAndFunctionsForQueryVec, ReqResultOverData.modeFillWithTimeouts)); } response.setReqFunctionsList(rflType); // probably redundant ServContinuationListType servContListType = new ServContinuationListType(); response.setServContList(servContListType); List<ServContReplcItemType> pListOfReplcItems = servContListType.getServContReplcItem(); // for (int i = 0; i < allReplceStructVec.size(); i++) { // pListOfReplcItems.add(allReplceStructVec.elementAt(i)); //} }