List of usage examples for java.util List clear
void clear();
From source file:de.micromata.genome.db.jpa.tabattr.entities.JpaLongValueBaseDO.java
/** * Set the value of the attribute./*from w w w . jav a2s . c o m*/ * * if value is longer than VALUE_MAXLENGHT the string will be split and stored in additional data children entities. * * @param value the new string data */ public void setStringData(String value) { List<JpaLongValueDataBaseDO<?, PK>> data = getData(); data.clear(); int maxValLength = getValueMaxLength(); if (StringUtils.length(value) > maxValLength) { this.value = value.substring(0, maxValLength); String rest = value.substring(maxValLength); int maxDataLength = getMaxDataLength(); int rowIdx = 0; while (rest.length() > 0) { String ds = StringUtils.substring(rest, 0, maxDataLength); rest = StringUtils.substring(rest, maxDataLength); JpaLongValueDataBaseDO<?, PK> dataDo = createData(ds); dataDo.setDatarow(rowIdx++); data.add(dataDo); } } else { this.value = value; } }
From source file:com.liferay.portal.search.solr.server.LiveServerChecker.java
public void shutdown() { List<SolrServerWrapper> allSolrServerWrappers = new ArrayList<SolrServerWrapper>(); List<SolrServerWrapper> deadSolrServerWrappers = _solrServerFactory.getDeadServers(); allSolrServerWrappers.addAll(deadSolrServerWrappers); deadSolrServerWrappers.clear(); List<SolrServerWrapper> liveSolrServerWrappers = _solrServerFactory.getLiveServers(); allSolrServerWrappers.addAll(liveSolrServerWrappers); liveSolrServerWrappers.clear();//from w w w .ja v a 2 s .c o m for (SolrServerWrapper solrServerWrapper : allSolrServerWrappers) { SolrServer solrServer = solrServerWrapper.getServer(); if (solrServer == null) { continue; } _solrServerFactory.killServer(solrServerWrapper); if (solrServer instanceof StoppableSolrServer) { StoppableSolrServer stoppableSolrServer = (StoppableSolrServer) solrServer; stoppableSolrServer.stop(); } } _scheduledExecutorService.shutdownNow(); MultiThreadedHttpConnectionManager.shutdownAll(); }
From source file:com.ebay.cloud.cms.dal.search.impl.field.AbstractSearchField.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private void traverseFields(List fieldValues, int i, final String[] innerFields, List targetList) { if (i == innerFields.length) { // match all, add to target list targetList.addAll(fieldValues);/*from w w w .j a va 2s.co m*/ return; } String currentField = innerFields[i]; for (Object obj : fieldValues) { if (obj instanceof Map) { Object currentValue = ((Map) obj).get(currentField); List valueContainer = new ArrayList(); valueContainer.clear(); valueContainer.add(currentValue); traverseFields(valueContainer, i + 1, innerFields, targetList); } else if (obj instanceof List) { traverseFields((List) obj, i, innerFields, targetList); } } }
From source file:org.ado.biblio.BarCodeCache.java
public BookMessage[] getBookMessages(@NotNull String id) { final List<BookMessage> bookMessagesList = map.get(id); if (bookMessagesList != null) { BookMessage[] bookMessageArray = bookMessagesList.toArray(new BookMessage[bookMessagesList.size()]); bookMessagesList.clear(); return bookMessageArray; } else {//from w w w. j a v a 2 s .co m return new BookMessage[] {}; } }
From source file:curveavg.MedialAxisTransform.java
public static void trace1(Vector3f[] curveA, Vector3f[] curveB, List<MedialAxisTransform.TracePoint> output) { final boolean dbg = false; if (dbg) {/*from w w w . j a v a 2 s .c o m*/ System.out.println("\n"); } // Clear the output output.clear(); // Pick two points close to the intersection on the first segments and find their tangents Vector3f tA = Curve.quadraticHermiteTangent(curveA[0], curveA[1], curveA[2].subtract(curveA[0]), 0.01f); Vector3f tB = Curve.quadraticHermiteTangent(curveB[0], curveB[1], curveB[2].subtract(curveB[0]), 0.01f); // Compute the medial axis of the tangents and move off the intersection. // NOTE: The jump needs to be large to avoid weird phenomena. MedialAxisTransform.Line line = MedialAxisTransform.medialAxisLine(curveA[0], tA, curveB[0], tB); Vector3f Q1 = curveA[0].addScaled(30.0f, line.v); // Project out from the current point in the direction of the medial axis of its projected tangents // and refine iteratively by moving in the perpendicular direction. final float stepSize = 10.0f; for (int idx = 0; idx < 55; idx++) { // Stop condition if (Q1.distance(curveA[curveA.length - 1]) < 1) { break; } if (dbg) { System.out.println("Iteration " + idx + "---------------------"); } if (dbg) { System.out.println("Line p: " + line.p.toString() + ", line v: " + line.v.toString()); } // Project out the point if (dbg) { System.out.println("Q1 initial: " + Q1.toString()); } Q1 = Q1.addScaled(stepSize, line.v); if (dbg) { System.out.println("Q1 projected: " + Q1.toString()); } // Move the estimate in the negative average direction of the projections // until the difference in their distances vanishes int counter = 0; while (true) { // Find the projections MedialAxisTransform.ClosestInfo infoA = MedialAxisTransform.findClosest(curveA, Q1); MedialAxisTransform.ClosestInfo infoB = MedialAxisTransform.findClosest(curveB, Q1); assert (infoA.found); assert (infoB.found); // Find the distances and their difference float distA = Q1.distance(infoA.Pt); float distB = Q1.distance(infoB.Pt); float err = distA - distB; if (dbg) { System.out.println("distA: " + distA + ", distB: " + distB + ", |diff|: " + Math.abs(err) + ", dirA: " + infoA.dir.toString() + ", dirB: " + infoB.dir.toString()); } // Stop if the difference is small enough and add to the list if (Math.abs(err) < 1e-3) { // Generate the trace point MedialAxisTransform.TracePoint tp = new MedialAxisTransform.TracePoint(); tp.center = Q1; tp.projectionOnA = new float[1]; tp.projectionOnA[0] = (infoA.time + infoA.curveIndex) / (curveA.length - 1); tp.projectionOnB = new float[1]; tp.projectionOnB[0] = (infoB.time + infoB.curveIndex) / (curveB.length - 1); tp.radius = (distA + distB) / 2.0f; output.add(tp); // Stop if (dbg) { System.out.println("Converged..."); } break; } // Move the point in the average direction Vector3f dir = (infoA.dir.subtract(infoB.dir)).normalize(); Q1 = Q1.addScaledLocal(-0.2f * err, dir); if (counter++ > 50) { break; } } // Visualize the medial axis if (dbg) { System.out.println("Q1 later: " + Q1.toString()); } // Find the closest points to the new medial axis MedialAxisTransform.ClosestInfo infoA = MedialAxisTransform.findClosest(curveA, Q1); MedialAxisTransform.ClosestInfo infoB = MedialAxisTransform.findClosest(curveB, Q1); // End condition: if the projected point on one of the curves is // too close to the final intersection if (infoA.curveIndex == (curveA.length - 2)) { if (infoA.time > 0.4) { break; } System.out.println("iter: " + idx + ", curveIndex: " + infoA.curveIndex + ", time: " + infoA.time); } // Find the medial axis of the tangent lines line = MedialAxisTransform.medialAxisLine(infoA.Pt, infoA.tangent, infoB.Pt, infoB.tangent); } }
From source file:com.cognifide.qa.bb.scope.frame.FramePath.java
private FramePath addFrame(String path) { if (StringUtils.isEmpty(path)) { return this; }/* w ww.j a v a 2s . com*/ final String firstPart = StringUtils.substringBefore(path, "/"); final String rest = StringUtils.substringAfter(path, "/"); List<FrameDescriptor> modifiedLocation = new ArrayList<>(frames); if (firstPart.isEmpty()) { modifiedLocation.clear(); } else if (firstPart.matches("\\$[0-9]+")) { final int index = Integer.parseInt(firstPart.substring(1)); modifiedLocation.add(new IndexedFrame(index)); } else if ("$cq".equals(firstPart)) { modifiedLocation.clear(); modifiedLocation.add(AemContentFrame.INSTANCE); } else if ("..".equals(firstPart) && !modifiedLocation.isEmpty()) { modifiedLocation.remove(modifiedLocation.size() - 1); } else { modifiedLocation.add(new NamedFrame(firstPart)); } return new FramePath(modifiedLocation).addFrame(rest); }
From source file:com.gs.obevo.db.sqlparser.tokenparser.SqlTokenParser.java
private void processToken(boolean inToken, List<String> queuedTokens, List<SqlToken> tokens, SqlTokenType tokenType, Token token) { if (inToken) { String queuedTokenStr = StringUtils.join(queuedTokens, ""); queuedTokens.clear(); tokens.add(new SqlToken(SqlTokenType.TOKEN, queuedTokenStr)); }/* ww w . ja v a 2s .c om*/ tokens.add(new SqlToken(tokenType, token.image)); }
From source file:com.neatresults.mgnltweaks.ui.action.ExportMultipleAction.java
@Inject public ExportMultipleAction(Definition definition, List<JcrItemAdapter> items, CommandsManager commandsManager, UiContext uiContext, SimpleTranslator i18n) throws ActionExecutionException { super(definition, items.get(0), commandsManager, uiContext, i18n); // export action doesn't expose init for setting all items so we got to work around // by getting pointer to a list of items in AbstractCommandAction List<JcrItemAdapter> list = getItems(); // first item would be already in the list, clear it out list.clear(); // and adding all items to that list manually. list.addAll(items);/* ww w. j a v a 2 s. c o m*/ // and pray that noone ever changes ACA to return copy of item list instead }
From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.gestor.GestorOrganizacionesControllerImpl.java
public final void editarOrganizacion(ActionMapping mapping, EditarOrganizacionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); String identificador = form.getIdentifier(); List portapapeles = sesEmpaq.getPortapapeles(); if (portapapeles != null) { portapapeles.clear(); } else {/*from w w w. ja v a 2s .c o m*/ List portapapelesN = new ArrayList(); portapapeles = portapapelesN; } sesEmpaq.setPortapapeles(portapapeles); sesEmpaq.setAccion("Normal"); sesEmpaq.setModoPegar(false); List<OrganizacionVO> idCollection = sesEmpaq.getIdCollection(); idCollection.clear(); List<OdeVO> submanifestPath = sesEmpaq.getSubmanifestPath(); OdeVO ultima = submanifestPath.get(submanifestPath.size() - 1); OrganizacionVO[] organizaciones = ultima.getOrganizaciones(); boolean encontrado = false; for (int i = 0; (encontrado == false && i < organizaciones.length); i++) { if (organizaciones[i].getIdentifier().equals(identificador)) { idCollection.add(organizaciones[i]); encontrado = true; } } sesEmpaq.setIdCollection(idCollection); }
From source file:com.docdoku.core.util.Tools.java
private static String getPartLinkAsString(Map<String, List<PartLinkList>> links, String joinWith) { List<String> componentNumbers = new ArrayList<>(); List<String> pathStrings = new ArrayList<>(); List<String> typeStrings = new ArrayList<>(); for (String type : links.keySet()) { List<PartLinkList> paths = links.get(type); for (PartLinkList path : paths) { for (PartLink partLink : path.getPath()) { String linkAsString = partLink.getComponent().getName() + " < " + partLink.getComponent().getNumber() + " > "; if (partLink.getReferenceDescription() != null && !partLink.getReferenceDescription().isEmpty()) { linkAsString += " ( " + partLink.getReferenceDescription() + " )"; }/*w w w . java2 s . c o m*/ componentNumbers.add(linkAsString); } String join = StringUtils.join(componentNumbers, joinWith); pathStrings.add(type + ": " + join); componentNumbers.clear(); } String typeLines = StringUtils.join(pathStrings, "\n"); typeStrings.add(typeLines); pathStrings.clear(); } String fullString = StringUtils.join(typeStrings, "\n"); typeStrings.clear(); return fullString; }