@Test public void testCreateAndDelete() throws Exception { LOG.info("EntityDaoTest.testCreateAndDelete"); UUID applicationId = setup.createApplication("testOrganization", "testCreateAndDelete"); EntityManager em = setup.getEmf().getEntityManager(applicationId); String name = "test.thing" + UUIDUtils.newTimeUUID(); Map<String, Object> properties = new LinkedHashMap<String, Object>(); properties.put("name", name); properties.put("foo", "bar"); LOG.info("Starting entity create"); Entity thing = em.create("thing", properties); LOG.info("Entity created"); LOG.info("Starting entity delete"); em.delete(thing); LOG.info("Entity deleted"); // now search by username, no results should be returned Results r = em.searchCollection( em.getApplicationRef(), "thing", new Query().addEqualityFilter("name", name)); assertEquals(0, r.size()); }
static void runBenchmark( Client client, int maxIter, Results results, List<Entry<String, RequestInfo>> nativeSearchRequests, int minTerms, int warmerIter) throws IOException { int counter = 0; for (Entry<String, RequestInfo> entry : nativeSearchRequests) { SearchResponse searchResponse = null; // warm up for (int i = 0; i < warmerIter; i++) { searchResponse = client.search(entry.getValue().request).actionGet(); } System.gc(); // run benchmark StopWatch stopWatch = new StopWatch(); stopWatch.start(); for (int i = 0; i < maxIter; i++) { searchResponse = client.search(entry.getValue().request).actionGet(); } stopWatch.stop(); results.set( searchResponse, stopWatch, entry.getKey(), maxIter, counter, entry.getValue().numTerms); counter++; } results.printResults(null); }
@Override public void onComplete(final Context context, final Results results) { if (results.hasFailedTasks()) { final ServiceError error = results.getFailedTasks().get(0).getError(); ErrorBroadcaster.broadcast(context, getUri(), error.getCode(), error.getMessage()); } }
@Override protected void printDocumentStart() { System.out.print(" | Page |"); Results.printLevelHeader(); System.out.print(" | |"); Results.printColumnHeader(); printSeparator(); }
@Test public void testEntityManager() throws Exception { LOG.info("EntityManagerIT.testEntityManagerTest"); UUID applicationId = setup.createApplication("testOrganization", "testEntityManagerTest"); assertNotNull(applicationId); EntityManager em = setup.getEmf().getEntityManager(applicationId); assertNotNull(em); Map<String, Object> properties = new LinkedHashMap<String, Object>(); properties.put("username", "edanuff"); properties.put("email", "*****@*****.**"); Entity user = em.create("user", properties); assertNotNull(user); user = em.get(user); assertNotNull(user); assertEquals("user.username not expected value", "edanuff", user.getProperty("username")); assertEquals("user.email not expected value", "*****@*****.**", user.getProperty("email")); EntityRef userRef = em.getAlias(applicationId, "user", "edanuff"); assertNotNull(userRef); assertEquals("userRef.id not expected value", user.getUuid(), userRef.getUuid()); assertEquals("userRef.type not expected value", "user", userRef.getType()); LOG.info("user.username: "******"username")); LOG.info("user.email: " + user.getProperty("email")); Results results = em.searchCollection( em.getApplicationRef(), "users", new Query().addEqualityFilter("username", "edanuff")); assertNotNull(results); assertEquals(1, results.size()); user = results.getEntity(); assertNotNull(user); assertEquals("user.username not expected value", "edanuff", user.getProperty("username")); assertEquals("user.email not expected value", "*****@*****.**", user.getProperty("email")); LOG.info("user.username: "******"username")); LOG.info("user.email: " + user.getProperty("email")); results = em.searchCollection( em.getApplicationRef(), "users", new Query().addEqualityFilter("email", "*****@*****.**")); assertNotNull(results); assertEquals(1, results.size()); user = results.getEntity(); assertNotNull(user); assertEquals("user.username not expected value", "edanuff", user.getProperty("username")); assertEquals("user.email not expected value", "*****@*****.**", user.getProperty("email")); LOG.info("user.username: "******"username")); LOG.info("user.email: " + user.getProperty("email")); }
@Override protected void onObjectReceived(Object obj) { if (obj instanceof Results) { Results<T> r = (Results<T>) obj; if (r.getRequestIndex() == requestId) { onResultsReceived(r.getRes()); } } }
public boolean collide( ConvexShape shape0, Transform wtrs0, ConvexShape shape1, Transform wtrs1, float radialmargin /*, btStackAlloc* stackAlloc*/, Results results) { // Initialize results.witnesses[0].set(0f, 0f, 0f); results.witnesses[1].set(0f, 0f, 0f); results.normal.set(0f, 0f, 0f); results.depth = 0; results.status = ResultsStatus.Separated; results.epa_iterations = 0; results.gjk_iterations = 0; /* Use GJK to locate origin */ gjk.init( /*stackAlloc,*/ wtrs0.basis, wtrs0.origin, shape0, wtrs1.basis, wtrs1.origin, shape1, radialmargin + EPA_accuracy); try { boolean collide = gjk.SearchOrigin(); results.gjk_iterations = gjk.iterations + 1; if (collide) { /* Then EPA for penetration depth */ EPA epa = new EPA(gjk); float pd = epa.EvaluatePD(); results.epa_iterations = epa.iterations + 1; if (pd > 0) { results.status = ResultsStatus.Penetrating; results.normal.set(epa.normal); results.depth = pd; results.witnesses[0].set(epa.nearest[0]); results.witnesses[1].set(epa.nearest[1]); return (true); } else { if (epa.failed) { results.status = ResultsStatus.EPA_Failed; } } } else { if (gjk.failed) { results.status = ResultsStatus.GJK_Failed; } } return (false); } finally { gjk.destroy(); } }
public void addExpected(ExpectedInvocation expected, Result result, Range count) { for (ExpectedInvocationAndResults entry : results) { if (entry.getExpectedInvocation().equals(expected)) { entry.getResults().add(result, count); return; } } Results list = new Results(); list.add(result, count); results.add(new ExpectedInvocationAndResults(expected, list)); }
/** * Tests the specified runnable, using the specified number of warmup and test runs. * * @param runnable Runnable to test. * @param numWarmupRuns Number of warmup runs before testing. * @param numTestRuns Number of test runs. * @return Results object. */ public static Results test(Runnable runnable, int numWarmupRuns, int numTestRuns) { for (int i = 0; i < numWarmupRuns; ++i) { runnable.run(); } Results results = new Results(numWarmupRuns, numTestRuns); for (int i = 0; i < numTestRuns; ++i) { results.start(); runnable.run(); results.end(); } return results; }
public static void printOctaveScript(List<Results> allResults, String[] args) throws IOException { if (args.length == 0) { return; } try (BufferedWriter out = Files.newBufferedWriter(Paths.get(args[0]), StandardCharsets.UTF_8)) { out.write("#! /usr/local/bin/octave -qf"); out.write("\n\n\n\n"); out.write("######################################\n"); out.write("# Octave script for plotting results\n"); String filename = "scriptScoreBenchmark" + new DateTime().toString(); out.write( "#Call '" + args[0] + "' from the command line. The plot is then in " + filename + "\n\n"); out.write("handleArray = [];\n tagArray = [];\n plot([]);\n hold on;\n"); for (Results result : allResults) { out.write("\n"); out.write("# " + result.description); result.printResults(out); out.write( "handleArray = [handleArray, addToPlot(" + Results.NUM_TERMS + ", " + Results.TIME_PER_DOCIN_MILLIS + ", '" + result.color + "','" + result.lineStyle + "',5)];\n"); out.write("tagArray = [tagArray; '" + result.label + "'];\n"); out.write("\n"); } out.write("xlabel(\'number of query terms');"); out.write("ylabel(\'query time per document');"); out.write("legend(handleArray,tagArray);\n"); out.write("saveas(gcf,'" + filename + ".png','png')\n"); out.write("hold off;\n\n"); } catch (IOException e) { System.err.println("Error: " + e.getMessage()); } writeHelperFunction(); }
void writeResults(String loc) throws IOException { Results results = new Results(); results.ctCodingNucleotide = ctCodingNucleotide; results.ctExons = ctExons; results.ctStates = ctStates; results.ctTransitions = ctTransitions; results.correct = correct; results.incorrect = incorrect; results.perfect = perfect; results.imperfect = imperfect; FileUtil.writeObject(loc, results); }
@Override protected void printDocumentResults(Results results) { printSeparator(); Formatter formatter = new Formatter(System.out, Locale.US); formatter.format(" | Total: |"); results.printResults(formatter); }
@Override public void run() { int counter; System.out.printf( "%s: Processing lines from %d to %d\n", Thread.currentThread().getName(), firstRow, lastRow); for (int i = firstRow; i < lastRow; i++) { int row[] = mock.getRow(i); counter = 0; for (int j = 0; j < row.length; j++) { if (row[j] == number) { counter++; } } results.setData(i, counter); try { Thread.sleep(10); } catch (InterruptedException e) { // TODO: handle exception } } System.out.printf("%s: Lines processed \n", Thread.currentThread().getName()); try { barrier.await(); } catch (InterruptedException e) { e.printStackTrace(); } catch (BrokenBarrierException e) { e.printStackTrace(); } }
@Test public void testDeletes() throws Exception { EntityManager entityManager = this.app.getEntityManager(); Map<String, Object> map = new HashMap<>(); for (int i = 0; i < 10; i++) { map.put("somekey", UUID.randomUUID()); Entity entity = entityManager.create("tests", map); } this.app.refreshIndex(); Thread.sleep(500); ApplicationScope appScope = CpNamingUtils.getApplicationScope(entityManager.getApplicationId()); Observable<Id> ids = this.app.getApplicationService().deleteAllEntities(appScope, 5); int count = ids.count().toBlocking().last(); Assert.assertEquals(count, 5); ids = this.app.getApplicationService().deleteAllEntities(appScope, 5); count = ids.count().toBlocking().last(); Assert.assertEquals(count, 5); this.app.refreshIndex(); Thread.sleep(5000); Injector injector = SpringResource.getInstance().getBean(Injector.class); GraphManagerFactory factory = injector.getInstance(GraphManagerFactory.class); GraphManager graphManager = factory.createEdgeManager(appScope); SimpleSearchByEdgeType simpleSearchByEdgeType = new SimpleSearchByEdgeType( appScope.getApplication(), CpNamingUtils.getEdgeTypeFromCollectionName("tests"), Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, Optional.<Edge>absent()); Iterator<Edge> results = graphManager.loadEdgesFromSource(simpleSearchByEdgeType).toBlocking().getIterator(); if (results.hasNext()) { Assert.fail("should be empty"); } else { Results searchCollection = entityManager.searchCollection(entityManager.getApplication(), "tests", Query.all()); Assert.assertEquals(searchCollection.size(), 0); AggregationServiceFactory aggregationServiceFactory = injector.getInstance(AggregationServiceFactory.class); long size = aggregationServiceFactory.getAggregationService().getCollectionSize(appScope, "tests"); Assert.assertEquals(size, 0); // success } }
/** Main method of the Grouper. Sum the values stored in the Results object */ @Override public void run() { int finalResult = 0; System.out.printf("Grouper: Processing results...\n"); int data[] = results.getData(); for (int number : data) { finalResult += number; } System.out.printf("Grouper: Total result: %d.\n", finalResult); }
public static void main(String[] args) throws AnalysisException, IOException, TransformationException { SegmentationEvaluator evaluator = new SegmentationEvaluator(); evaluator.ignoredLabels.add(BxZoneLabel.BODY_TABLE); evaluator.ignoredLabels.add(BxZoneLabel.BODY_FIGURE); evaluator.ignoredLabels.add(BxZoneLabel.BODY_EQUATION); File file = new File(args[0]); Collection<File> files = FileUtils.listFiles(file, new String[] {"xml"}, true); Results results = evaluator.newResults(); int i = 0; double zoneScores = 0; double lineScores = 0; double wordScores = 0; BxDocument origDoc; BxDocument testDoc; FileReader reader; for (File filee : files) { System.out.println(new Date(System.currentTimeMillis())); System.out.println(filee.getName()); reader = new FileReader(filee); origDoc = evaluator.prepareExpectedDocument(evaluator.readDocument(reader)); testDoc = evaluator.prepareActualDocument(origDoc); Results docRes = evaluator.compareDocuments(origDoc, testDoc); results.add(docRes); zoneScores += results.zoneLevel.getScore(); lineScores += results.lineLevel.getScore(); wordScores += results.wordLevel.getScore(); System.out.println(++i); } zoneScores /= i; lineScores /= i; wordScores /= i; System.out.println("Documents: " + i); System.out.println("Average zone score: " + zoneScores); System.out.println("Average line score: " + lineScores); System.out.println("Average word score: " + wordScores); results.printSummary(); }
/** * Defines and carries out the process modeled by this class. Generates several competitors * parttaking in the Biathlon competition. */ public void lifeCycle() { Biathlon model = (Biathlon) getModel(); for (int i = 0; i < Biathlon.NUM_COMPETITORS; i++) { Competitor competitor = new Competitor(model, "Competitor", true, i); Results.getInstance().registerCompetitor(i, competitor.toString()); competitor.activateAfter(this); } }
/** * Invokes a test as a command, with specified number of warmup runs, test runs, class name, and * string arguments. The command-line syntax is: * * <blockquote> * * <code> * java com.aliasi.test.time.Stopwatch * <br> * <i>numWarmups</i> <i>numTests</i> <i>className</i> * <i>arg1</i> ... <i>argN</i> [<i>N</i> >= 0] * </code> * * </blockquote> * * The arguments are strings, and there must be an <i>N</i>-argument constructor with string * argument types for the class with the name <i>className</i>. In particular, if there are no * arguments, there must be a no-argument constructor. * * @param args Command-line arguments. */ public static void main(String[] args) throws Exception { if (args.length < 3) { String msg = "Must specify name of class as argument."; throw new IllegalArgumentException(msg); } int numWarmups = Integer.parseInt(args[0]); int numTests = Integer.parseInt(args[1]); String className = args[2]; String[] consArgs = new String[args.length - 3]; System.arraycopy(args, 3, consArgs, 0, consArgs.length); Runnable runnable = (Runnable) Reflection.newInstance(className, consArgs); if (runnable == null) { String msg = "Could not construct runnable."; throw new IllegalArgumentException(msg); } Results results = test(runnable, numWarmups, numTests); System.out.println(); System.out.println("RESULTS"); System.out.println(results.toString()); }
@Test public void testCreateAndList() throws Exception { LOG.info("EntityDaoTest.testCreateAndDelete"); UUID applicationId = setup.createApplication("testOrganization", "testCreateAndList"); EntityManager em = setup.getEmf().getEntityManager(applicationId); String name = "test.thing" + UUIDUtils.newTimeUUID() + 1; Map<String, Object> properties = new LinkedHashMap<String, Object>(); properties.put("name", name); properties.put("foo", "bar"); LOG.info("Starting entity create"); Entity thing1 = em.create("thing", properties); LOG.info("Entity created"); String name2 = "test.thing" + UUIDUtils.newTimeUUID() + 2; properties = new LinkedHashMap<String, Object>(); properties.put("name", name2); properties.put("foo", "bar"); LOG.info("Starting entity create"); Entity thing2 = em.create("thing", properties); LOG.info("Entity created"); // now search by username, no results should be returned EntityRef appRef = em.getRef(applicationId); Results r = em.getCollection(appRef, "things", null, 10, Level.ALL_PROPERTIES, false); assertEquals(2, r.size()); assertEquals(thing1.getUuid(), r.getEntities().get(0).getUuid()); assertEquals(thing2.getUuid(), r.getEntities().get(1).getUuid()); }
// Search in index for a query private CursorPage<DProduct, String> searchInIndexWithQuery( com.google.appengine.api.search.Query query, Index index) { CursorPage<DProduct, String> cursorPage = null; try { // Query the index. Results<ScoredDocument> results = index.search(query); // Collect all the primary keys Collection<String> ids = new ArrayList<String>(); for (ScoredDocument document : results) { ids.add(document.getId()); } if (ids.size() != 0) { // We got results, get the places from datastore Iterator<DProduct> dProductIterator = queryByPrimaryKeys(null, ids).iterator(); Collection<DProduct> dProducts = new ArrayList<DProduct>(ids.size()); while (dProductIterator.hasNext()) { dProducts.add(dProductIterator.next()); } // Build a cursor page cursorPage = new CursorPage<DProduct, String>(); cursorPage.setCursorKey(results.getCursor().toWebSafeString()); cursorPage.setItems(dProducts); } } catch (SearchException e) { if (StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult().getCode())) { LOG.error("Search index failed"); // TODO: Error handling missing } throw new SearchException("Searching index failed"); } return cursorPage; }
@PostConstruct @Override public void postConstruct() { super.postConstruct(); getResultsTable().setMultiSelect(true); HorizontalLayout crudButtons = new HorizontalLayout(); setDebugId(crudButtons, "crudButtons"); crudButtons.setMargin(false); crudButtons.setSpacing(true); newButton = new Button(uiMessageSource.getMessage("crudResults.new"), this, "create"); newButton.setDescription(uiMessageSource.getToolTip("crudResults.new.toolTip")); newButton.setIcon(new ThemeResource("../expressui/icons/16/add.png")); newButton.addStyleName("small default"); crudButtons.addComponent(newButton); viewButton = new Button(uiMessageSource.getMessage("crudResults.view"), this, "view"); viewButton.setDescription(uiMessageSource.getToolTip("crudResults.view.toolTip")); viewButton.setIcon(new ThemeResource("../expressui/icons/16/view.png")); viewButton.addStyleName("small default"); crudButtons.addComponent(viewButton); editButton = new Button(uiMessageSource.getMessage("crudResults.edit"), this, "edit"); editButton.setDescription(uiMessageSource.getToolTip("crudResults.edit.toolTip")); editButton.setIcon(new ThemeResource("../expressui/icons/16/edit.png")); editButton.addStyleName("small default"); crudButtons.addComponent(editButton); deleteButton = new Button(uiMessageSource.getMessage("crudResults.delete"), this, "delete"); deleteButton.setDescription(uiMessageSource.getToolTip("crudResults.delete.toolTip")); deleteButton.setIcon(new ThemeResource("../expressui/icons/16/delete.png")); deleteButton.addStyleName("small default"); crudButtons.addComponent(deleteButton); actionContextMenu.addAction("crudResults.view", this, "view"); actionContextMenu.addAction("crudResults.edit", this, "edit"); actionContextMenu.addAction("crudResults.delete", this, "delete"); addSelectionChangedListener(this, "selectionChanged"); getCrudButtons().addComponent(crudButtons, 0); getCrudButtons().setComponentAlignment(crudButtons, Alignment.MIDDLE_LEFT); getResultsTable().addListener(new DoubleClickListener()); addCodePopupButtonIfEnabledForCrudResults(); }
/** * Evaluates a tree * * @param inst itemsets * @param smooth =true, evaluates the smoothed models; =false, evaluats the unsmoothed models * @return the evaluation results * @exception Exception if something goes wrong */ public final Results errors(MyDataset inst, boolean smooth) throws Exception { int i; double tmp; Results e = new Results(0, inst.numItemsets() - 1); for (i = 0; i <= inst.numItemsets() - 1; i++) { tmp = this.predict(inst.itemset(i), smooth) - inst.itemset(i).getClassValue(); e.sumErr += tmp; e.sumAbsErr += Math.abs(tmp); e.sumSqrErr += tmp * tmp; } e.meanAbsErr = e.sumAbsErr / e.numItemsets; e.meanSqrErr = (e.sumSqrErr - e.sumErr * e.sumErr / e.numItemsets) / e.numItemsets; e.meanSqrErr = Math.abs(e.meanSqrErr); e.rootMeanSqrErr = Math.sqrt(e.meanSqrErr); return e; }
/** * Makes a copy of the tree under this node * * @param up the parant node of the new node * @return a copy of the tree under this node * @exception Exception if something goes wrong */ public final M5TreeNode copy(M5TreeNode up) throws Exception { M5TreeNode node = new M5TreeNode(itemsets, upNode); node.type = type; node.splitAttr = splitAttr; node.splitValue = splitValue; node.unsmoothed = unsmoothed.copy(); node.smoothed = smoothed.copy(); node.valueNode = valueNode; node.upNode = up; if (errors == null) { node.errors = null; } else { node.errors = errors.copy(); } node.numParameters = node.numParameters; if (sf == null) { node.sf = null; } else { node.sf = sf.copy(); } node.itemsets = new MyDataset(itemsets, 0, itemsets.numItemsets()); node.lm = lm; node.model = model; node.pruningFactor = pruningFactor; node.deviation = deviation; if (leftNode != null) { node.leftNode = leftNode.copy(node); } else { node.leftNode = null; } if (rightNode != null) { node.rightNode = rightNode.copy(node); } else { node.rightNode = null; } return node; }
/** * Converts the information stored at this node to a string * * @return the converted string * @exception Exception if something goes wrong */ public final String singleNodeToString() throws Exception { StringBuffer text = new StringBuffer(); text.append("Print single node (" + itemsets.numItemsets() + "):\n"); if (type == true) { text.append(" Type:\t\t\tNODE\n"); } else { text.append(" Type:\t\t\tLEAF\n"); } text.append(" Unsmoothed function:\t\t"); unsmoothed.toString(itemsets, 0); System.out.print(" Smoothed function:\t\t"); smoothed.toString(itemsets, 0); text.append(" Value node:\t\t\t" + valueNode + "\n"); if (errors != null) { text.append(errors.toString()); } if (upNode != null) { text.append(" upNode:\t\t\tyes\n"); } else { text.append(" upNode:\t\t\tnull\n"); } if (leftNode != null) { text.append(" leftNode:\t\t\tyes\n"); } else { text.append(" leftNode:\t\t\tnull\n"); } if (rightNode != null) { text.append(" rightNode:\t\t\tyes\n"); } else { text.append(" rightNode:\t\t\tnull\n"); } text.append(" number of parameters:\t" + numParameters + "\n"); text.append(" LEAF number(lm):\t\t" + lm + "\n"); text.append(" Number of itemsets\t\t" + itemsets.numItemsets() + "\n"); return text.toString(); }
public static Results evaluate(String act_file, String pred_file) throws Exception { CONLLReader09 goldReader = new CONLLReader09(act_file, -1); CONLLReader09 predictedReader = new CONLLReader09(pred_file, -1); int total = 0, corr = 0, corrL = 0; int numsent = 0, corrsent = 0, corrsentL = 0; SentenceData09 goldInstance = goldReader.getNext(); SentenceData09 predInstance = predictedReader.getNext(); while (goldInstance != null) { int instanceLength = goldInstance.length(); if (instanceLength != predInstance.length()) { Parser.out.println("Lengths do not match on sentence " + numsent); } int[] goldHeads = goldInstance.heads; String[] goldLabels = goldInstance.labels; int[] predHeads = predInstance.pheads; String[] predLabels = predInstance.plabels; boolean whole = true; boolean wholeL = true; // NOTE: the first item is the root info added during nextInstance(), so we skip it. int punc = 0; for (int i = 1; i < instanceLength; i++) { if (predHeads[i] == goldHeads[i]) { corr++; if (goldLabels[i].equals(predLabels[i])) { corrL++; } else { // Parser.out.println(numsent+" error gold "+goldLabels[i]+" "+predLabels[i]+" head // "+goldHeads[i]+" child "+i); wholeL = false; } } else { // Parser.out.println(numsent+"error gold "+goldLabels[i]+" "+predLabels[i]+" head // "+goldHeads[i]+" child "+i); whole = false; wholeL = false; } } total += ((instanceLength - 1) - punc); // Subtract one to not score fake root token if (whole) { corrsent++; } if (wholeL) { corrsentL++; } numsent++; goldInstance = goldReader.getNext(); predInstance = predictedReader.getNext(); } Results r = new Results(); r.total = total; r.corr = corr; r.las = (float) Math.round(((double) corrL / total) * 100000) / 1000; r.ula = (float) Math.round(((double) corr / total) * 100000) / 1000; Parser.out.print("Total: " + total + " \tCorrect: " + corr + " "); Parser.out.println( "LAS: " + (double) Math.round(((double) corrL / total) * 100000) / 1000 + " \tTotal: " + (double) Math.round(((double) corrsentL / numsent) * 100000) / 1000 + " \tULA: " + (double) Math.round(((double) corr / total) * 100000) / 1000 + " \tTotal: " + (double) Math.round(((double) corrsent / numsent) * 100000) / 1000); return r; }
private void printSeparator() { System.out.print(" +----------+"); Results.printSeparator(); }
@Override public void postWire() { super.postWire(); }
@Override protected String executePlayer(Player p_player, String p_cmd, String[] p_args) { switch (p_args.length) { case 0: if (this.checkPerm(p_player, false)) { Results result = this.action(p_player); switch (result) { case ERROR: p_player.sendMessage( ChatColor.RED + "[" + this.getPlugin().getName() + "] " + ZeltCmds.getLanguage().getString("playertoggle_error")); break; case OFF: if (msg != null && msg[1] != null) { p_player.sendMessage(ChatColor.GREEN + msg[1]); } break; case ON: if (msg != null && msg[0] != null) { p_player.sendMessage(ChatColor.GREEN + msg[0]); } break; } return ZeltCmds.getLanguage() .getString( "log_playertoggle_self", new Object[] {type.name(), result.name(), p_player.getName()}); } break; case 1: if (this.checkPerm(p_player, true)) { final OfflinePlayer off_player = p_player.getServer().getOfflinePlayer(p_args[0]); if (off_player.isOnline()) { final Player player = off_player.getPlayer(); Results result = this.action(player); switch (result) { case ERROR: p_player.sendMessage( ChatColor.RED + "[" + this.getPlugin().getName() + "] " + ZeltCmds.getLanguage().getString("playertoggle_error")); break; case OFF: if (msg != null) { player.sendMessage(ChatColor.GREEN + msg[1]); } break; case ON: if (msg != null) { player.sendMessage(ChatColor.GREEN + msg[0]); } break; } return ZeltCmds.getLanguage() .getString( "log_playertoggle_player", new Object[] { type.name(), result.name(), p_player.getName(), player.getName() }); } else { p_player.sendMessage( ChatColor.RED + "[" + this.getPlugin().getName() + "] " + ZeltCmds.getLanguage() .getString( (off_player.getFirstPlayed() != 0 ? "player_offline" : "player_not_found"), new Object[] {p_args[0]})); } } break; default: p_player.sendMessage( ChatColor.RED + "[" + this.getPlugin().getName() + "] " + ZeltCmds.getLanguage().getString("arguments_too_many")); p_player.sendMessage( ChatColor.RED + "[" + this.getPlugin().getName() + "] " + ZeltCmds.getLanguage().getString("usage_player", new Object[] {"/" + p_cmd})); break; } return null; }
public Results execute() throws SqlException { return Results.build(this, mapper); }
@Override protected void printFinalResults(Results results) { results.printSummary(); }