List of usage examples for java.util List clear
void clear();
From source file:edu.unlv.kilo.web.ChartingController.java
@RequestMapping(method = RequestMethod.POST) public String post(@Valid ChartingForm form, BindingResult result, Model model, HttpServletRequest request) { // Returns the form with errors found from the @ checks if (result.hasErrors()) { return createForm(model, form); }/*www .j a v a 2 s . c om*/ Calendar startDate = form.getStartDate(); // Gets the start date from the user Calendar endDate = form.getEndDate(); // Gets the end date from the user // Have to make sure the begin date is actually before the end date // If not, throw an error if (startDate.after(endDate)) { result.rejectValue("startDate", "start_date_after_end"); return createForm(model, form); //result.rejectValue("startDate", "start_after_end", "The start date must be before the end date."); } int interval = form.getDay_Interval(); // Gets the interval in days from the user // Send the data to projecting and receive the points to plot //List<MoneyValue> data_Points = Projection.getGraphData(startDate, endDate, interval); /*------------TEST CASE------------------------------------------*/ List<MoneyValue> data_Points = new ArrayList<MoneyValue>(); data_Points.clear(); for (long j = 0; j < 10; j++) { MoneyValue abc = new MoneyValue(); abc.setAmount(j); data_Points.add(abc); } /*------------TEST CASE------------------------------------------*/ // This sets up the start date and end date to be able // to be printed in a nice default format. SimpleDateFormat nice_String = new SimpleDateFormat("MM/dd/yyyy"); String begin_Print = null; String end_Print = null; begin_Print = nice_String.format(startDate.getTime()); end_Print = nice_String.format(endDate.getTime()); /*-------------GRAPHING STARTS HERE-------------*/ int number_of_points = data_Points.size(); // Holds the points for graphing. // Library dictates it must be a double double[] points = new double[number_of_points]; // These values are set so they're sure to be changed double min_Value = 1000000; // The minimum Money amount in the list double max_Value = 0; // The maximum Money amount in the list // Put the Money amounts into the array and check for updated // minimum and maximum values. for (int i = 0; i < number_of_points; i++) { points[i] = (double) data_Points.get(i).getAmount(); if (min_Value > points[i]) { min_Value = points[i]; } if (max_Value < points[i]) { max_Value = points[i]; } } //Line charting_Line = Plots.newLine(Data.newData(points), RED, "Item"); Line charting_Line = Plots.newLine(DataUtil.scaleWithinRange(min_Value, max_Value, points), RED, "Item"); charting_Line.setLineStyle(LineStyle.newLineStyle(3, 1, 0)); charting_Line.addShapeMarkers(Shape.CIRCLE, Color.AQUAMARINE, 8); // Defining the chart LineChart chart = GCharts.newLineChart(charting_Line); chart.setSize(550, 450); chart.setTitle("Budgeting Line Chart", MAROON, 14); chart.setGrid(number_of_points, number_of_points, 3, 2); // Defining the axis information and styles AxisStyle axisStyle = AxisStyle.newAxisStyle(BLACK, 12, AxisTextAlignment.CENTER); AxisLabels xAxis = AxisLabelsFactory.newAxisLabels(begin_Print, "Dates", end_Print); xAxis.setAxisStyle(axisStyle); AxisLabels yAxis = AxisLabelsFactory.newNumericAxisLabels(min_Value, max_Value); yAxis.setAxisStyle(axisStyle); // Adding axis information to the chart chart.addXAxisLabels(xAxis); chart.addYAxisLabels(yAxis); // Defining the background color chart.setBackgroundFill(Fills.newSolidFill(LIGHTBLUE)); // The image url to be sent to the jspx String url = chart.toURLString(); // Setting the "url" variable for the jspx model.addAttribute("url", chart.toURLString()); return "charting/graph"; }
From source file:com.espertech.esper.regression.rowrecog.TestRowPatternMaxStatesEngineWide.java
private static void assertContextEnginePool(EPServiceProvider epService, EPStatement stmt, List<ConditionHandlerContext> contexts, int max, Map<String, Long> counts) { assertEquals(1, contexts.size());//from w w w . ja va 2 s.c o m ConditionHandlerContext context = contexts.get(0); assertEquals(epService.getURI(), context.getEngineURI()); assertEquals(stmt.getText(), context.getEpl()); assertEquals(stmt.getName(), context.getStatementName()); ConditionMatchRecognizeStatesMax condition = (ConditionMatchRecognizeStatesMax) context .getEngineCondition(); assertEquals(max, condition.getMax()); assertEquals(counts.size(), condition.getCounts().size()); for (Map.Entry<String, Long> expected : counts.entrySet()) { assertEquals("failed for key " + expected.getKey(), expected.getValue(), condition.getCounts().get(expected.getKey())); } contexts.clear(); }
From source file:com.googlecode.osde.internal.editors.contents.SupportedViewsPart.java
public void setValuesToModule() { Module module = getModule();/*from w w w.j a v a 2s. c o m*/ List<ContentModel> models = getContentModels(); List<Content> contents = module.getContent(); contents.clear(); for (ContentModel model : models) { Content content = new Content(); content.setHref(model.getHref()); content.setType(model.getType().name()); content.setValue(model.getBody()); content.setView(model.getView()); contents.add(content); } }
From source file:com.fluidops.iwb.server.SparqlServlet.java
/** * Retrieves from the data repository the lists of classes and properties which will be used as suggestions in the SPARQL interface. * Called only once on startup (in IWBStart). * /*ww w. ja va 2 s .c om*/ * @return Future<?> object whose get() method returns null if the sub-thread has executed successfully, null otherwise (for test purposes only) */ public static Future<?> initOntologyTermsSuggestions() { // Loading of classes and properties is performed in two stages: // First, only the classes and properties explicitly declared as such in the ontology are retrieved. // Then, all terms serving as entity types (classes) and statement predicates (properties) are retrieved in a parallel thread. // This is done to prevent queries to very big datasets (e.g. DBpedia) from blocking the startup while the results are being retrieved. classesList = Lists.newArrayListWithCapacity(1000); propertiesList = Lists.newArrayListWithCapacity(1000); ReadDataManager dm = ReadDataManagerImpl.getDataManager(Global.repository); fillUris(dm, "SELECT DISTINCT ?type WHERE { { ?type a rdfs:Class } UNION { ?type a owl:Class } } LIMIT 1000", classesList); Collections.sort(classesList); fillUris(dm, "SELECT DISTINCT ?property WHERE { { ?property a rdf:Property } UNION { ?property a owl:ObjectProperty } UNION { ?property a owl:DatatypeProperty } } LIMIT 1000", propertiesList); Collections.sort(propertiesList); log.info("Loaded classes and properties declared in the ontology"); final List<String> fullClassesList = new ArrayList<String>(classesList); final List<String> fullPropertiesList = new ArrayList<String>(propertiesList); Runnable classInfoReader = new Runnable() { @Override public void run() { Set<String> classesSet = new HashSet<String>(); Set<String> propertiesSet = new HashSet<String>(); ReadDataManager dm = ReadDataManagerImpl.getDataManager(Global.repository); fillUris(dm, "SELECT DISTINCT ?type WHERE { ?x rdf:type ?type . } LIMIT 1000", classesSet); combineWithAndSort(fullClassesList, classesSet); classesList = fullClassesList; fillUris(dm, "SELECT DISTINCT ?property WHERE { ?x ?property ?y . } LIMIT 1000", propertiesSet); combineWithAndSort(fullPropertiesList, propertiesSet); propertiesList = fullPropertiesList; log.info("Loaded classes and properties based on usage"); } private void combineWithAndSort(List<String> resultList, Set<String> tmpSet) { tmpSet.addAll(resultList); resultList.clear(); resultList.addAll(tmpSet); Collections.sort(resultList); } }; try { return TaskExecutor.instance().submit(classInfoReader); } catch (Exception e) { log.warn(e.getMessage()); log.debug("Details: ", e); } return null; }
From source file:br.com.uol.runas.classloader.ClassLoaderGC.java
private void releaseFromLoggers(WeakReference<ClassLoader> classLoader) { try {/*from w w w . j a v a2 s .c om*/ final Class<?> logFactoryClass = classLoader.get().loadClass("org.apache.commons.logging.LogFactory"); final Method releaseMethod = logFactoryClass.getDeclaredMethod("release", ClassLoader.class); releaseMethod.invoke(null, classLoader.get()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } try { final Class<?> logginHandlerClass = classLoader.get() .loadClass("org.openqa.selenium.logging.LoggingHandler"); final Object instance = Reflections.getStaticFieldValue(logginHandlerClass, "instance"); final Method closeMethod = logginHandlerClass.getDeclaredMethod("close"); closeMethod.invoke(instance, (Object[]) null); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } try { final Class<?> remoteWebDriverClass = classLoader.get() .loadClass("org.openqa.selenium.remote.RemoteWebDriver"); final Object logger = Reflections.getStaticFieldValue(remoteWebDriverClass, "logger"); // final Class<?> loggingClass = classLoader.get().loadClass("java.util.logging.Logger"); final List<?> handlers = Reflections.getFieldValue(logger, "handlers"); handlers.clear(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:hydrograph.ui.menus.handlers.PasteHandler.java
private List<IFile> getPastedFileList(List<IFile> jobFiles) { List<IFile> newJobFilesList = ListUtils.subtract(jobFiles, JobCopyParticipant.getPreviousJobFiles()); jobFiles.clear(); jobFiles.addAll(newJobFilesList);/*w w w .j a v a2 s .co m*/ return jobFiles; }
From source file:com.helpinput.spring.refresher.mvc.MvcContextRefresher.java
@Override public void refresh(ApplicationContext context, Map<Class<?>, ScanedType> scanedClasses) { boolean needUpdateHandlerMapping = false; boolean needUpdateInterceptor = false; for (Entry<Class<?>, ScanedType> entry : scanedClasses.entrySet()) { if ((entry.getValue().getValue() > ScanedType.SAME.getValue()) && entry.getKey().getAnnotation(Controller.class) != null) { needUpdateHandlerMapping = true; break; }//w w w . ja v a 2s.c o m } for (Entry<Class<?>, ScanedType> entry : scanedClasses.entrySet()) { if ((entry.getValue().getValue() > ScanedType.SAME.getValue()) && HandlerInterceptor.class.isAssignableFrom(entry.getKey())) { needUpdateInterceptor = true; break; } } if (needUpdateInterceptor) { DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) ((AbstractApplicationContext) context) .getBeanFactory(); Map<String, AbstractHandlerMapping> mappings = dlbf.getBeansOfType(AbstractHandlerMapping.class); if (Utils.hasLength(mappings)) { Field interceptorsField = Utils.findField(AbstractHandlerMapping.class, "interceptors"); Field mappedInterceptorsFeild = Utils.findField(AbstractHandlerMapping.class, "mappedInterceptors"); Method initApplicationContext = Utils.findMethod(AbstractHandlerMapping.class, "initApplicationContext"); if (interceptorsField != null && mappedInterceptorsFeild != null && initApplicationContext != null) { for (AbstractHandlerMapping mapping : mappings.values()) { synchronized (mapping) { final List<Object> interceptors = Utils.getFieldValue(mapping, interceptorsField); if (Utils.hasLength(interceptors)) interceptors.clear(); final List<MappedInterceptor> mappedInterceptors = Utils.getFieldValue(mapping, mappedInterceptorsFeild); if (Utils.hasLength(mappedInterceptors)) mappedInterceptors.clear(); Utils.InvokedMethod(mapping, initApplicationContext); } } } } } if (needUpdateHandlerMapping) { final String mapName = "org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0"; Object mappingHandler = context.getBean(mapName); if (mappingHandler != null) { Method method = Utils.findMethod(mappingHandler, "initHandlerMethods"); Map<?, ?> handlerMethods = Utils.getFieldValue(mappingHandler, "handlerMethods"); Map<?, ?> urlMap = Utils.getFieldValue(mappingHandler, "urlMap"); if (method != null && handlerMethods != null && urlMap != null) { synchronized (mappingHandler) { handlerMethods.clear(); urlMap.clear(); Utils.InvokedMethod(mappingHandler, method); } } } } }
From source file:de.ks.idnadrev.information.view.InformationOverviewDS.java
@Override public List<InformationPreviewItem> loadModel(Consumer<List<InformationPreviewItem>> furtherProcessing) { List<Class<? extends Information<?>>> classes = new ArrayList<>( Arrays.asList(TextInfo.class, ChartInfo.class, UmlDiagramInfo.class)); if (loadingHint.getType() != null) { classes.clear(); classes.add(loadingHint.getType()); }//w ww . j ava2 s .c o m String name = "%" + StringUtils.replace(loadingHint.getName(), "*", "%") + "%"; List<String> tags = loadingHint.getTags(); Category category = loadingHint.getCategory(); List<InformationPreviewItem> retval = PersistentWork.read(em -> { CriteriaBuilder builder = em.getCriteriaBuilder(); List<InformationPreviewItem> items = new ArrayList<>(); for (Class<? extends Information<?>> clazz : classes) { List<InformationPreviewItem> results = getResults(name, tags, category, em, builder, clazz); results.forEach(r -> r.setType(clazz)); items.addAll(results); } furtherProcessing.accept(items); return items; }); return retval; }
From source file:es.csic.iiia.planes.behaviors.AbstractBehaviorAgent.java
/** * {@inheritDoc}// w w w . java 2 s .com * <p/> * In this case, the step initialization is to turn the "future" messages * of the previous iteration into the "current" ones for this iteration. * <p/> * Additionally, it gives the opportunity for behaviors to initialize * themselves. */ @Override public void preStep() { List<Message> tmp = currentMessages; tmp.clear(); currentMessages = futureMessages; futureMessages = tmp; for (Behavior b : behaviors) { b.preStep(); } }
From source file:hydrograph.ui.propertywindow.widgets.dialog.hiveInput.HiveFieldDialogHelper.java
/** * Disposes all columns in table//from w w w . j a v a 2 s . co m * @param tableViewer */ public void disposeAllColumns(TableViewer tableViewer, List<HivePartitionFields> fieldsDialogList) { fieldsDialogList.clear(); tableViewer.refresh(); TableColumn[] columns = tableViewer.getTable().getColumns(); for (TableColumn tc : columns) { tc.dispose(); } tableViewer.getTable().redraw(); }