List of usage examples for java.lang Comparable Comparable
Comparable
From source file:net.commerce.zocalo.freechart.ChartTest.java
private static OHLCDataset createOHLCDataSet(Minute now) { OHLCDataItem item1 = new OHLCDataItem(new Date(now.getFirstMillisecond()), .34, .40, .22, .22, 5); OHLCDataItem item2 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 5)), .22, .35, .21, .31, 54);/* ww w . j av a2 s.c o m*/ OHLCDataItem item3 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 12)), .31, .35, .30, .34, 4); OHLCDataItem item4 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 18)), .34, .43, .32, .41, 8); OHLCDataItem item5 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 35)), .41, .41, .20, .21, 14); OHLCDataItem item6 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 42)), .21, .40, .21, .40, 14); OHLCDataItem item7 = new OHLCDataItem(new Date(now.getFirstMillisecond() + (1000 * 54)), .40, .53, .40, .52, 14); OHLCDataItem[] items = { item1, item2, item3, item4, item5, item6, item7 }; return new DefaultOHLCDataset(new Comparable() { public int compareTo(Object object) { return 1; } }, items); }
From source file:de.xirp.plugin.PluginManager.java
/** * Extract the OS independent and appropriate depending jars to a * plugins own directory for the jars./*from w w w .j a v a 2 s . com*/ * * @param info * the information about the plugin * @param path * the path to which the plugins jars are extracted */ protected static void extractPluginLib(PluginInfo info, String path) { String notContains = LIB_LINUX_PLUGIN_DIR; if (!osWindows()) { notContains = LIB_WINDOWS_PLUGIN_DIR; } final String notCont = notContains; extractFromJar(info, path, new Comparable<String>() { public int compareTo(String elementName) { if (elementName.startsWith(LIB_PLUGIN_DIR) && !elementName.startsWith(LIB_PLUGIN_DIR + JAR_SEPARATOR + LIB_DLL_PLUGIN_DIR) && !elementName.startsWith(LIB_PLUGIN_DIR + JAR_SEPARATOR + LIB_SO_PLUGIN_DIR) && !elementName.startsWith(LIB_PLUGIN_DIR + JAR_SEPARATOR + notCont)) { return 0; } return -1; } }, LIB_PLUGIN_DIR, false); }
From source file:de.xirp.plugin.PluginManager.java
/** * Extracts all dll's or so's (if OS is not windows) for the given * plugin. The files are deleted on shutdown. * /* w ww. ja v a 2s . co m*/ * @param info * the information about the plugin * @return <code>false</code> if extraction failed */ protected static boolean extractDLLs(PluginInfo info) { String path = getLibraryPath(); String compareName = LIB_DLL_PLUGIN_DIR; if (!osWindows()) { compareName = LIB_SO_PLUGIN_DIR; } final String compName = compareName; return extractFromJar(info, path, new Comparable<String>() { public int compareTo(String elementName) { if (elementName.startsWith(LIB_PLUGIN_DIR + JAR_SEPARATOR + compName)) { return 0; } return -1; } }, LIB_PLUGIN_DIR + JAR_SEPARATOR + compareName, true); }
From source file:de.xirp.plugin.PluginManager.java
/** * Extracts the plugins help directory from within the jar to the * given path<br>/*from w w w. jav a2 s . c o m*/ * Plugins can have html help files inside a directory named help * in the upmost jar layer.<br> * The files are deleted on shutdown. * * @param info * Information about the plugin for which help should * be extracted * @param path * Path to the directory to which help should be * extracted * @return <code>true</code> if extraction was successful */ public static boolean extractHelp(PluginInfo info, String path) { return extractFromJar(info, path, new Comparable<String>() { public int compareTo(String elementName) { if (elementName.startsWith(HELP_PLUGIN_DIR)) { return 0; } return -1; } }, HELP_PLUGIN_DIR, true); }
From source file:de.xirp.plugin.PluginManager.java
/** * Extracts the images of the given plugin. The images are deleted * on shutdown.//from w w w.j a va 2s . co m * * @param info * information about the plugin * @return <code>true</code> if extraction was successful */ protected static boolean extractImages(PluginInfo info) { final String path = ImageManager.PLUGIN_BASE_PATH + File.separator + info.getMainClass(); DeleteManager.deleteOnShutdown(path); new File(path).mkdirs(); return extractFromJar(info, path, new Comparable<String>() { public int compareTo(String elementName) { if (elementName.startsWith(IMAGE_PLUGIN_DIR)) { return 0; } return -1; } }, IMAGE_PLUGIN_DIR, false); }
From source file:org.mule.test.config.ExceptionHelperTestCase.java
@Test public void filteredStackIncludingMixedNonMuleCode() { int calls = 5; try {/*from w w w . jav a 2s . c o m*/ generateStackEntries(calls, new Closure() { @Override public void execute(Object input) { Comparable exceptionComparable = new Comparable() { @Override public int compareTo(Object o) { throw new RuntimeException( new DefaultMuleException(MessageFactory.createStaticMessage("foo"))); } }; Collections.sort(Arrays.asList(exceptionComparable, exceptionComparable), ComparableComparator.getInstance()); } }); fail("Expected exception"); } catch (Exception e) { assertThat(ExceptionHelper.getExceptionStack(e), StringByLineMatcher.matchesLineByLine("foo (org.mule.api.DefaultMuleException)", " org.mule.test.config.ExceptionHelperTestCase$2$1.compareTo:", " org.apache.commons.collections.comparators.ComparableComparator.compare:", " java.util", // Collections.sort " java.util", // Collections.sort " java.util", // Collections.sort " java.util", // Collections.sort " java.util", // Collections.sort " org.mule.test.config.ExceptionHelperTestCase$2.execute:", " org.mule.test.config.ExceptionHelperTestCase.generateStackEntries:", " (" + (calls + 13) + " more...)")); // recursive } }
From source file:org.pentaho.metadata.query.model.util.BooleanComparator.java
public static Comparable<Object> getComparable(Object object) { final Boolean b = toBoolean(object); return new Comparable<Object>() { public int compareTo(Object o) { return _instance.compare(b, o); }/* ww w . j av a2 s . com*/ @Override public String toString() { return "BooleanComparable[boolean=" + b + "]"; //$NON-NLS-1$ //$NON-NLS-2$ } }; }