List of usage examples for java.util Vector elements
public Enumeration<E> elements()
From source file:fr.inrialpes.exmo.align.cli.ExtGroupEval.java
public void printHTML(Vector<Vector<Object>> result, PrintStream writer) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far double symVect[]; // symmetric similarity double effVect[]; // effort-based similarity double precOrVect[]; // precision-oriented similarity double recOrVect[]; // recall-oriented similarity fsize = format.length();//from w w w .j a v a2 s .c om try { Formatter formatter = new Formatter(writer); // Print the header writer.println("<html><head></head><body>"); writer.println("<table border='2' frame='sides' rules='groups'>"); writer.println("<colgroup align='center' />"); // for each algo <td spancol='2'>name</td> for (String m : listAlgo) { writer.println("<colgroup align='center' span='" + 2 * fsize + "' />"); } // For each file do a writer.println("<thead valign='top'><tr><th>algo</th>"); // for each algo <td spancol='2'>name</td> for (String m : listAlgo) { writer.println("<th colspan='" + ((2 * fsize)) + "'>" + m + "</th>"); } writer.println("</tr></thead><tbody><tr><td>test</td>"); // for each algo <td>Prec.</td><td>Rec.</td> for (String m : listAlgo) { for (int i = 0; i < fsize; i++) { if (format.charAt(i) == 's') { writer.println("<td colspan='2'><center>Symmetric</center></td>"); } else if (format.charAt(i) == 'e') { writer.println("<td colspan='2'><center>Effort</center></td>"); } else if (format.charAt(i) == 'p') { writer.println("<td colspan='2'><center>Prec. orient.</center></td>"); } else if (format.charAt(i) == 'r') { writer.println("<td colspan='2'><center>Rec. orient.</center></td>"); } } //writer.println("<td>Prec.</td><td>Rec.</td>"); } writer.println("</tr></tbody><tbody>"); foundVect = new int[size]; symVect = new double[size]; effVect = new double[size]; precOrVect = new double[size]; recOrVect = new double[size]; for (int k = size - 1; k >= 0; k--) { foundVect[k] = 0; symVect[k] = 0.; effVect[k] = 0.; precOrVect[k] = 0.; recOrVect[k] = 0.; } // </tr> // For each directory <tr> boolean colored = false; for (Vector<Object> test : result) { int nexpected = -1; if (colored == true && color != null) { colored = false; writer.println("<tr bgcolor=\"" + color + "\">"); } else { colored = true; writer.println("<tr>"); } ; // Print the directory <td>bla</td> writer.println("<td>" + (String) test.get(0) + "</td>"); // For each record print the values <td>bla</td> Enumeration<Object> f = test.elements(); f.nextElement(); for (int k = 0; f.hasMoreElements(); k++) { ExtPREvaluator eval = (ExtPREvaluator) f.nextElement(); if (eval != null) { // iterative H-means computation if (nexpected == -1) { nexpected = eval.getExpected(); expected += nexpected; } // If foundVect is -1 then results are invalid if (foundVect[k] != -1) foundVect[k] += eval.getFound(); for (int i = 0; i < fsize; i++) { writer.print("<td>"); if (format.charAt(i) == 's') { formatter.format("%1.2f", eval.getSymPrecision()); writer.print("</td><td>"); formatter.format("%1.2f", eval.getSymRecall()); symVect[k] += eval.getSymSimilarity(); } else if (format.charAt(i) == 'e') { formatter.format("%1.2f", eval.getEffPrecision()); writer.print("</td><td>"); formatter.format("%1.2f", eval.getEffRecall()); effVect[k] += eval.getEffSimilarity(); } else if (format.charAt(i) == 'p') { formatter.format("%1.2f", eval.getPrecisionOrientedPrecision()); writer.print("</td><td>"); formatter.format("%1.2f", eval.getPrecisionOrientedRecall()); precOrVect[k] += eval.getPrecisionOrientedSimilarity(); } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", eval.getRecallOrientedPrecision()); writer.print("</td><td>"); formatter.format("%1.2f", eval.getRecallOrientedRecall()); recOrVect[k] += eval.getRecallOrientedSimilarity(); } writer.print("</td>"); } } else { for (int i = 0; i < fsize; i++) writer.print("<td>n/a</td>"); } } writer.println("</tr>"); } writer.print("<tr bgcolor=\"yellow\"><td>H-mean</td>"); int k = 0; for (String m : listAlgo) { if (foundVect[k] != -1) { for (int i = 0; i < fsize; i++) { writer.print("<td>"); if (format.charAt(i) == 's') { formatter.format("%1.2f", symVect[k] / foundVect[k]); writer.print("</td><td>"); formatter.format("%1.2f", symVect[k] / expected); } else if (format.charAt(i) == 'e') { formatter.format("%1.2f", effVect[k] / foundVect[k]); writer.print("</td><td>"); formatter.format("%1.2f", effVect[k] / expected); } else if (format.charAt(i) == 'p') { formatter.format("%1.2f", precOrVect[k] / foundVect[k]); writer.print("</td><td>"); formatter.format("%1.2f", precOrVect[k] / expected); } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", recOrVect[k] / foundVect[k]); writer.print("</td><td>"); formatter.format("%1.2f", recOrVect[k] / expected); } writer.println("</td>"); } } else { writer.println("<td colspan='2'><center>Error</center></td>"); } //}; k++; } writer.println("</tr>"); writer.println("</tbody></table>"); writer.println("<p><small>n/a: result alignment not provided or not readable<br />"); writer.println("NaN: division per zero, likely due to empty alignent.</small></p>"); writer.println("</body></html>"); } catch (Exception ex) { logger.debug("IGNORED Exception", ex); } finally { writer.flush(); writer.close(); } }
From source file:net.aepik.alasca.core.ldap.Schema.java
/** * Retourne l'ensemble des objets du schema d'un certain type. * @param type Le type des objets selectionner. * @return SchemaObject[] L'ensemble des objets du schema. *//* w w w. j av a 2s . co m*/ public SchemaObject[] getObjects(String type) { Vector<SchemaObject> v = new Vector<SchemaObject>(); for (Enumeration<SchemaObject> e = objets.elements(); e.hasMoreElements();) { SchemaObject o = e.nextElement(); if (type.equals(o.getType())) { v.add(o); } } SchemaObject[] result = new SchemaObject[v.size()]; int position = 0; for (Enumeration<SchemaObject> e = v.elements(); e.hasMoreElements();) { result[position] = e.nextElement(); position++; } return result; }
From source file:net.aepik.alasca.core.ldap.Schema.java
/** * Retourne l'ensemble des objets du schema d'un certain type, dans l'ordre * dans lequel ils ont t ajout au schma. * @param type Le type des objets selectionner. * @return SchemaObject[] L'ensemble des objets du schema. *///ww w .jav a 2 s .c o m public SchemaObject[] getObjectsInOrder(String type) { Vector<SchemaObject> v = new Vector<SchemaObject>(); for (Enumeration<Object> e = objectsOrder.elements(); e.hasMoreElements();) { SchemaObject o = (SchemaObject) e.nextElement(); if (type.equals(o.getType())) { v.add(o); } } SchemaObject[] result = new SchemaObject[v.size()]; int position = 0; for (Enumeration<SchemaObject> e = v.elements(); e.hasMoreElements();) { result[position] = e.nextElement(); position++; } if (type.equals(this.getSyntax().getObjectIdentifierType())) { Properties oids = getObjectsIdentifiers(result); String[] oidsk = getSortedObjectsIdentifiersKeys(oids); result = new SchemaObject[oidsk.length]; for (int i = 0; i < oidsk.length; i++) { for (Enumeration<SchemaObject> e = v.elements(); e.hasMoreElements();) { SchemaObject o = e.nextElement(); String[] okeys = o.getKeys(); if (okeys[0].compareTo(oidsk[i]) == 0) { result[i] = o; } } } } return result; }
From source file:org.openmrs.module.openhmis.cashier.web.controller.CashierMessageRenderController.java
@RequestMapping(method = RequestMethod.GET) public ModelAndView render(HttpServletRequest request) { // object to store keys from cashier and backboneforms Vector<String> keys = new Vector<String>(); // locate and retrieve cashier messages Locale locale = RequestContextUtils.getLocale(request); ResourceBundle resourceBundle = ResourceBundle.getBundle("messages", locale); // store cashier message keys in the vector object keys.addAll(resourceBundle.keySet()); // retrieve backboneforms messages BackboneMessageRenderController backboneController = new BackboneMessageRenderController(); ModelAndView modelAndView = backboneController.render(request); // store backboneforms message keys in the vector object for (Map.Entry<String, Object> messageKeys : modelAndView.getModel().entrySet()) { Enumeration<String> messageKey = (Enumeration<String>) messageKeys.getValue(); while (messageKey.hasMoreElements()) { String key = messageKey.nextElement(); if (!keys.contains(key)) keys.add(key);/*from ww w . ja v a2s . c o m*/ } } return new ModelAndView(CashierWebConstants.MESSAGE_PAGE, "keys", keys.elements()); }
From source file:com.verisign.epp.serverstub.LaunchDomainHandler.java
/** * Invoked when a Domain Check command is received that includes support for * the Claims Check Command with the {@link EPPLaunchCheck} extension. * /* w w w . j a va2 s . c o m*/ * @param aEvent * The <code>EPPEvent</code> that is being handled * @param aData * Any data that a Server needs to send to this * <code>LaunchDomainHandler</code> * * @return The <code>EPPEventResponse</code> that should be sent back to the * client. */ protected EPPEventResponse doDomainCheck(EPPEvent aEvent, Object aData) { cat.debug("LaunchDomainHandler.doDomainCheck: enter"); EPPEventResponse theEventResponse; EPPDomainCheckCmd theCommand = (EPPDomainCheckCmd) aEvent.getMessage(); // EPPLaunchCheck Extension provided? if (theCommand.hasExtension(EPPLaunchCheck.class)) { EPPLaunchCheck theLaunchCheck = (EPPLaunchCheck) theCommand.getExtension(EPPLaunchCheck.class); // Claims Check Command? if (!theLaunchCheck.hasType() || theLaunchCheck.getType().equals(EPPLaunchCheck.TYPE_CLAIMS)) { cat.debug("LaunchDomainHandler.doDomainCheck: Launch Claims Check Form for Phase = " + theLaunchCheck.getPhase()); // Get phase String phase = theLaunchCheck.getPhase().getPhase(); // Claims Check Command? if (phase.equals(EPPLaunchPhase.PHASE_CLAIMS)) { EPPResponse theResponse = new EPPResponse(new EPPTransId(theCommand.getTransId(), "54321-XYZ")); EPPLaunchChkData theExt = new EPPLaunchChkData(theLaunchCheck.getPhase()); boolean exists = true; boolean validatorId = true; Vector vDomainNames = theCommand.getNames(); Enumeration eDomainNames = vDomainNames.elements(); // Anymore domain names? while (eDomainNames.hasMoreElements()) { String domainName = (String) eDomainNames.nextElement(); // Is there a matching mark for domain name? if (exists) { // Include validatorID attribute? if (validatorId) { theExt.addCheckResult(new EPPLaunchCheckResult(domainName, true, Base64.encodeBase64String(domainName.getBytes()), "tmch")); } else { theExt.addCheckResult(new EPPLaunchCheckResult(domainName, true, Base64.encodeBase64String(domainName.getBytes()))); } validatorId = !validatorId; } // No matching mark for domain name else { theExt.addCheckResult(new EPPLaunchCheckResult(domainName, false)); } exists = !exists; } theResponse.addExtension(theExt); theEventResponse = new EPPEventResponse(theResponse); } // Unsupported phase else { return this.returnError(EPPResult.PARAM_VALUE_POLICY_ERROR, theCommand.getTransId(), "Unsupported check Phase = " + phase); } } // Available Check Form with passed phase else { cat.debug("LaunchDomainHandler.doDomainCheck: Launch Availability Check Form for Phase = " + theLaunchCheck.getPhase()); theEventResponse = super.doDomainCheck(aEvent, aData); } } else { // Domain Check Command theEventResponse = super.doDomainCheck(aEvent, aData); } cat.debug("LaunchDomainHandler.doDomainCheck: exit"); return theEventResponse; }
From source file:fr.inrialpes.exmo.align.cli.GroupEval.java
public void printLATEX(Vector<Vector<Object>> result, PrintStream writer) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far int correctVect[]; // correct so far long timeVect[]; // time so far Formatter formatter = new Formatter(writer); fsize = format.length();// w w w .j a v a2 s .c o m // JE: the h-means computation should be put out as well // Print the header writer.println("\\documentclass[11pt]{book}"); writer.println(); writer.println("\\begin{document}"); writer.println("\\date{today}"); writer.println(""); writer.println("\n%% Plot generated by GroupEval of alignapi"); writer.println("\\setlength{\\tabcolsep}{3pt} % May be changed"); writer.println("\\begin{table}"); writer.print("\\begin{tabular}{|l||"); for (int i = size; i > 0; i--) { for (int j = fsize; j > 0; j--) writer.print("c"); writer.print("|"); } writer.println("}"); writer.println("\\hline"); // For each file do a writer.print("algo"); // for each algo <td spancol='2'>name</td> for (String m : listAlgo) { writer.print(" & \\multicolumn{" + fsize + "}{c|}{" + m + "}"); } writer.println(" \\\\ \\hline"); writer.print("test"); // for each algo <td>Prec.</td><td>Rec.</td> for (String m : listAlgo) { for (int i = 0; i < fsize; i++) { writer.print(" & "); if (format.charAt(i) == 'p') { writer.print("Prec."); } else if (format.charAt(i) == 'f') { writer.print("FMeas."); } else if (format.charAt(i) == 'o') { writer.print("Over."); } else if (format.charAt(i) == 't') { writer.print("Time"); } else if (format.charAt(i) == 'r') { writer.print("Rec."); } } } writer.println(" \\\\ \\hline"); foundVect = new int[size]; correctVect = new int[size]; timeVect = new long[size]; for (int k = size - 1; k >= 0; k--) { foundVect[k] = 0; correctVect[k] = 0; timeVect[k] = 0; } for (Vector<Object> test : result) { int nexpected = -1; // Print the directory writer.print((String) test.get(0)); // For each record print the values Enumeration<Object> f = test.elements(); f.nextElement(); for (int k = 0; f.hasMoreElements(); k++) { PRecEvaluator eval = (PRecEvaluator) f.nextElement(); if (eval != null) { // iterative H-means computation if (nexpected == -1) { expected += eval.getExpected(); nexpected = 0; } foundVect[k] += eval.getFound(); correctVect[k] += eval.getCorrect(); timeVect[k] += eval.getTime(); for (int i = 0; i < fsize; i++) { writer.print(" & "); if (format.charAt(i) == 'p') { formatter.format("%1.2f", eval.getPrecision()); } else if (format.charAt(i) == 'f') { formatter.format("%1.2f", eval.getFmeasure()); } else if (format.charAt(i) == 'o') { formatter.format("%1.2f", eval.getOverall()); } else if (format.charAt(i) == 't') { if (eval.getTime() == 0) { writer.print("-"); } else { formatter.format("%1.2f", eval.getTime()); } } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", eval.getRecall()); } } } else { writer.print(" & \\multicolumn{" + fsize + "}{c|}{n/a}"); } } writer.println(" \\\\"); } writer.print("H-mean"); // Here we are computing a sheer average. // While in the column results we print NaN when the returned // alignment is empty, // here we use the real values, i.e., add 0 to both correctVect and // foundVect, so this is OK for computing the average. int k = 0; // ??? for (String m : listAlgo) { double precision = (double) correctVect[k] / foundVect[k]; double recall = (double) correctVect[k] / expected; for (int i = 0; i < fsize; i++) { writer.print(" & "); if (format.charAt(i) == 'p') { formatter.format("%1.2f", precision); } else if (format.charAt(i) == 'f') { formatter.format("%1.2f", 2 * precision * recall / (precision + recall)); } else if (format.charAt(i) == 'o') { formatter.format("%1.2f", recall * (2 - (1 / precision))); } else if (format.charAt(i) == 't') { if (timeVect[k] == 0) { writer.print("-"); } else { formatter.format("%1.2f", timeVect[k]); } } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", recall); } } ; k++; } writer.println(" \\\\ \\hline"); writer.println("\\end{tabular}"); writer.println( "\\caption{Plot generated by GroupEval of alignapi \\protect\\footnote{n/a: result alignment not provided or not readable -- NaN: division per zero, likely due to empty alignment.}}"); writer.println("\\end{table}"); writer.println("\\end{document}"); }
From source file:com.codename1.corsproxy.CORSProxy.java
@Override protected void copyRequestHeaders(HttpServletRequest servletRequest, HttpRequest proxyRequest) { HttpServletRequestWrapper requestWrapper = new HttpServletRequestWrapper(servletRequest) { @Override//from w ww. j a va 2s .co m public Enumeration<String> getHeaderNames() { Enumeration<String> names = super.getHeaderNames(); Vector<String> filteredNames = new Vector<String>(); boolean foundCookie = false; boolean foundRealCookie = false; while (names.hasMoreElements()) { String name = names.nextElement(); Enumeration<String> vals = this.getHeaders(name); if (!name.equalsIgnoreCase("Referer") && !name.equalsIgnoreCase("Host") && !name.equalsIgnoreCase("origin")) { filteredNames.add(name); } if (name.equalsIgnoreCase("X-CN1-Cookie")) { foundCookie = true; } if (name.equalsIgnoreCase("Cookie")) { foundRealCookie = true; } } if (foundCookie && !foundRealCookie) { filteredNames.add("Cookie"); } return filteredNames.elements(); } @Override public Enumeration<String> getHeaders(String name) { Enumeration<String> headers = super.getHeaders(name); Vector<String> out = new Vector<String>(); while (headers.hasMoreElements()) { out.add(headers.nextElement()); } if ("Cookie".equalsIgnoreCase(name)) { Enumeration<String> xHeaders = getHeaders("X-CN1-Cookie"); while (xHeaders.hasMoreElements()) { out.add(xHeaders.nextElement()); } } return out.elements(); } }; super.copyRequestHeaders(requestWrapper, proxyRequest); }
From source file:fr.inrialpes.exmo.align.cli.WGroupEval.java
public void printHTML(Vector<Vector<Object>> result, PrintStream writer) { // variables for computing iterative harmonic means int expected = 0; // expected so far int foundVect[]; // found so far int correctFoundVect[]; // correct so far int correctExpVect[]; // correct so far long timeVect[]; // time so far fsize = format.length();/*from ww w. j ava 2 s . c o m*/ // JE: the writer should be put out // JE: the h-means computation should be put out as well Formatter formatter = new Formatter(writer); // Print the header if (embedded != true) writer.println("<html><head></head><body>"); writer.println("<table border='2' frame='sides' rules='groups'>"); writer.println("<colgroup align='center' />"); // for each algo <td spancol='2'>name</td> for (String m : listAlgo) { writer.println("<colgroup align='center' span='" + fsize + "' />"); } // For each file do a writer.println("<thead valign='top'><tr><th>algo</th>"); // for each algo <td spancol='2'>name</td> for (String m : listAlgo) { writer.println("<th colspan='" + fsize + "'>" + m + "</th>"); } writer.println("</tr></thead><tbody><tr><td>test</td>"); // for each algo <td>Prec.</td><td>Rec.</td> for (String m : listAlgo) { for (int i = 0; i < fsize; i++) { writer.print("<td>"); if (format.charAt(i) == 'p') { writer.print("Prec."); } else if (format.charAt(i) == 'f') { writer.print("FMeas."); } else if (format.charAt(i) == 'o') { writer.print("Over."); } else if (format.charAt(i) == 't') { writer.print("Time"); } else if (format.charAt(i) == 'r') { writer.print("Rec."); } writer.println("</td>"); } //writer.println("<td>Prec.</td><td>Rec.</td>"); } writer.println("</tr></tbody><tbody>"); foundVect = new int[size]; correctFoundVect = new int[size]; correctExpVect = new int[size]; timeVect = new long[size]; for (int k = size - 1; k >= 0; k--) { foundVect[k] = 0; correctFoundVect[k] = 0; correctExpVect[k] = 0; timeVect[k] = 0; } // </tr> // For each directory <tr> boolean colored = false; for (Vector<Object> test : result) { double newexpected = -1.; if (colored == true && color != null) { colored = false; writer.println("<tr bgcolor=\"" + color + "\">"); } else { colored = true; writer.println("<tr>"); } ; // Print the directory <td>bla</td> writer.println("<td>" + (String) test.get(0) + "</td>"); // For each record print the values <td>bla</td> Enumeration<Object> f = test.elements(); f.nextElement(); for (int k = 0; f.hasMoreElements(); k++) { WeightedPREvaluator eval = (WeightedPREvaluator) f.nextElement(); if (eval != null) { // iterative H-means computation if (newexpected == -1.) { newexpected = eval.getExpected(); expected += newexpected; } foundVect[k] += eval.getFound(); correctFoundVect[k] += eval.getCorrectFound(); correctExpVect[k] += eval.getCorrectExpected(); timeVect[k] += eval.getTime(); for (int i = 0; i < fsize; i++) { writer.print("<td>"); if (format.charAt(i) == 'p') { formatter.format("%1.2f", eval.getPrecision()); } else if (format.charAt(i) == 'f') { formatter.format("%1.2f", eval.getFmeasure()); } else if (format.charAt(i) == 'o') { formatter.format("%1.2f", eval.getOverall()); } else if (format.charAt(i) == 't') { if (eval.getTime() == 0) { writer.print("-"); } else { formatter.format("%1.2f", eval.getTime()); } } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", eval.getRecall()); } writer.println("</td>"); } } else { // JE 2013: will break if the previous tests are all NULL correctExpVect[k] += newexpected; // Nothing needs to be incremented for precision for (int i = 0; i < fsize; i++) writer.print("<td>n/a</td>"); writer.println(); } } writer.println("</tr>"); } writer.print("<tr bgcolor=\"yellow\"><td>H-mean</td>"); // Here we are computing a sheer average. // While in the column results we print NaN when the returned // alignment is empty, // here we use the real values, i.e., add 0 to both correctVect and // foundVect, so this is OK for computing the average. int k = 0; // ??? for (String m : listAlgo) { double precision = 1. - (double) correctFoundVect[k] / foundVect[k]; double recall = 1. - (double) correctExpVect[k] / expected; for (int i = 0; i < fsize; i++) { writer.print("<td>"); if (format.charAt(i) == 'p') { formatter.format("%1.2f", precision); } else if (format.charAt(i) == 'f') { formatter.format("%1.2f", 2 * precision * recall / (precision + recall)); } else if (format.charAt(i) == 'o') { formatter.format("%1.2f", recall * (2 - (1 / precision))); } else if (format.charAt(i) == 't') { if (timeVect[k] == 0) { writer.print("-"); } else { formatter.format("%1.2f", timeVect[k]); } } else if (format.charAt(i) == 'r') { formatter.format("%1.2f", recall); } writer.println("</td>"); } ; k++; } writer.println("</tr>"); writer.println("</tbody></table>"); writer.println("<p><small>n/a: result alignment not provided or not readable<br />"); writer.println("NaN: division per zero, likely due to empty alignment.</small></p>"); if (embedded != true) writer.println("</body></html>"); }
From source file:org.melati.admin.Admin.java
/** * Returns the Add template after placing the table and fields for the new row * in the context using any field values already in the context. * /*from ww w . jav a2s .com*/ * If the table is a table meta data table, or a column meta data table then * the appropriate extras are added to the co0ntext. * * The Form does not normally contain values, but this could be used as a * mechanism for providing defaults. */ @SuppressWarnings("unchecked") protected static String addTemplate(final ServletTemplateContext context, Melati melati) throws PoemException { /* * Enumeration fields = new MappedEnumeration(melati.getTable().columns()) { * public Object mapped(Object column) { String stringValue = * context.getForm("field_" + ((Column)column).getName()); Object value = * null; if (stringValue != null) value = * ((Column)column).getType().rawOfString(stringValue); return new * Field(value, (Column)column); } }; context.put("fields", fields); */ // getDetailDisplayColumns() == columns() but could exclude some in theory Enumeration<Column<?>> columns = melati.getTable().getDetailDisplayColumns(); Vector<Field<?>> fields = new Vector<Field<?>>(); while (columns.hasMoreElements()) { Column<?> column = columns.nextElement(); String stringValue = context.getFormField("field_" + column.getName()); Object value = null; if (stringValue != null) value = column.getType().rawOfString(stringValue); else if (column.getType() instanceof ColumnTypePoemType) value = PoemTypeFactory.STRING.getCode(); fields.add(new Field<Object>(value, (FieldAttributes<Object>) column)); } if (melati.getTable() instanceof TableInfoTable) { Database database = melati.getDatabase(); // Compose field for naming the TROID column: the display name and // description are redundant, since they not used in the template final int troidHeight = 1; final int troidWidth = 20; Field<String> troidNameField = new Field<String>("id", new BaseFieldAttributes<String>("troidName", "Troid column", "Name of TROID column", database.getColumnInfoTable().getNameColumn().getType(), troidWidth, troidHeight, null, false, true, true)); fields.add(troidNameField); } context.put("fields", fields.elements()); return adminTemplate("Add"); }
From source file:com.alfaariss.oa.profile.aselect.processor.handler.AbstractAPIHandler.java
/** * Serialize attributes contained in a hashtable. * // w ww .j ava 2s . c o m * This method serializes attributes contained in a hashtable: * <ul> * <li>They are formatted as attr1=value1&attr2=value2;...</li> * <li>If a "&" or a "=" appears in either the attribute name * or value, they are transformed to %26 or %3d respectively.</li> * <li>The end result is base64 encoded.</li> * </ul> * * @param oAttributes IAttributes object containing all attributes * @return Serialized representation of the attributes * @throws ASelectException If serialization fails. */ protected String serializeAttributes(IAttributes oAttributes) throws ASelectException { String sReturn = null; try { StringBuffer sbCGI = new StringBuffer(); Enumeration enumGatheredAttributes = oAttributes.getNames(); while (enumGatheredAttributes.hasMoreElements()) { StringBuffer sbPart = new StringBuffer(); String sKey = (String) enumGatheredAttributes.nextElement(); Object oValue = oAttributes.get(sKey); if (oValue instanceof Vector) {// it's a multivalue attribute Vector vValue = (Vector) oValue; Enumeration eEnum = vValue.elements(); while (eEnum.hasMoreElements()) { String sValue = (String) eEnum.nextElement(); sbPart.append(URLEncoder.encode(sKey + "[]", ASelectProcessor.CHARSET)); sbPart.append("="); sbPart.append(URLEncoder.encode(sValue, ASelectProcessor.CHARSET)); if (eEnum.hasMoreElements()) sbPart.append("&"); } } else if (oValue instanceof String) {// it's a single value attribute String sValue = (String) oValue; sbPart.append(URLEncoder.encode(sKey, ASelectProcessor.CHARSET)); sbPart.append("="); sbPart.append(URLEncoder.encode(sValue, ASelectProcessor.CHARSET)); } else { StringBuffer sbDebug = new StringBuffer("Attribute '"); sbDebug.append(sKey); sbDebug.append("' has an unsupported value; is not a String: "); sbDebug.append(oValue); _logger.debug(sbDebug.toString()); } if (sbPart.length() > 0 && sbCGI.length() > 0) sbCGI.append("&"); sbCGI.append(sbPart); } if (sbCGI.length() > 0) { byte[] baCGI = Base64.encodeBase64(sbCGI.toString().getBytes(ASelectProcessor.CHARSET)); sReturn = new String(baCGI, ASelectProcessor.CHARSET); } } catch (Exception e) { _logger.fatal("Could not serialize attributes: " + oAttributes.toString(), e); throw new ASelectException(ASelectErrors.ERROR_ASELECT_INTERNAL_ERROR); } return sReturn; }