List of usage examples for org.apache.commons.lang ArrayUtils isEmpty
public static boolean isEmpty(boolean[] array)
Checks if an array of primitive booleans is empty or null
.
From source file:de.codesourcery.gittimelapse.Main.java
public static void main(String[] args) throws IOException, RevisionSyntaxException, GitAPIException { final Stack<String> argStack = new Stack<>(); final String testFile = "/home/tgierke/workspace/voipmanager/voipmngr/voipmngr/build.xml"; if (ArrayUtils.isEmpty(args) && new File(testFile).exists()) { argStack.push(testFile);/* w w w.jav a2s . c om*/ } File file = null; while (!argStack.isEmpty()) { if ("-d".equals(argStack.peek())) { DEBUG_MODE = true; argStack.pop(); } else { file = new File(argStack.pop()); } } if (file == null) { System.err.println("ERROR: Invalid command line."); System.err.println("Usage: [-d] <versioned file>\n"); return; } final GitHelper helper = new GitHelper(file.getParentFile()); MyFrame frame = new MyFrame(file, helper); frame.setPreferredSize(new Dimension(640, 480)); frame.pack(); frame.setVisible(true); }
From source file:de.codesourcery.jasm16.disassembler.Disassembler.java
public static void main(String[] args) throws IOException { if (ArrayUtils.isEmpty(args)) { System.err.println("ERROR: No input file"); System.exit(1);/*from w w w . j ava 2s. c o m*/ } if (args.length != 1) { System.err.println("ERROR: Bad command-line, expected exactly one input file."); System.exit(1); } final byte[] data = Misc.readBytes(new FileResource(new File(args[0]), ResourceType.OBJECT_FILE)); System.out.println("Input file has " + data.length + " (" + Misc.toHexString(data.length) + ") bytes."); for (DisassembledLine line : new Disassembler().disassemble(data, true)) { System.out.println(Misc.toHexString(line.getAddress()) + ": " + line.getContents()); } }
From source file:de.snertlab.xdccBee.ui.Application.java
public static void main(String args[]) { // INFO: Unter MacOsx muss jar wie folgt gestartet werden: java // -XstartOnFirstThread -jar try {/*w w w . j a v a 2 s .co m*/ if (!ArrayUtils.isEmpty(args) && !args[0].equals("-debug")) { BeeLogger.removeConsoleHandler(); } logger.info("xdccBee start"); window = new Application(); window.setBlockOnOpen(true); window.open(); if (Display.getCurrent() != null && !Display.getCurrent().isDisposed()) { Display.getCurrent().dispose(); } } catch (Exception e) { BeeLogger.exception(e); throw new RuntimeException(e); } System.exit(0); }
From source file:at.tuwien.ifs.somtoolbox.apps.VisualisationImageSaver.java
public static void main(String[] args) { JSAPResult res = OptionFactory.parseResults(args, OPTIONS); String uFile = res.getString("unitDescriptionFile"); String wFile = res.getString("weightVectorFile"); String dwmFile = res.getString("dataWinnerMappingFile"); String cFile = res.getString("classInformationFile"); String vFile = res.getString("inputVectorFile"); String tFile = res.getString("templateVectorFile"); String ftype = res.getString("filetype"); boolean unitGrid = res.getBoolean("unitGrid"); String basename = res.getString("basename"); if (basename == null) { basename = FileUtils.extractSOMLibInputPrefix(uFile); }/*from www . j ava 2s . c om*/ basename = new File(basename).getAbsolutePath(); int unitW = res.getInt("width"); int unitH = res.getInt("height", unitW); String[] vizs = res.getStringArray("vis"); GrowingSOM gsom = null; CommonSOMViewerStateData state = CommonSOMViewerStateData.getInstance(); try { SOMLibFormatInputReader inputReader = new SOMLibFormatInputReader(wFile, uFile, null); gsom = new GrowingSOM(inputReader); SharedSOMVisualisationData d = new SharedSOMVisualisationData(cFile, null, null, dwmFile, vFile, tFile, null); d.readAvailableData(); state.inputDataObjects = d; gsom.setSharedInputObjects(d); Visualizations.initVisualizations(d, inputReader, 0, Palettes.getDefaultPalette(), Palettes.getAvailablePalettes()); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); System.exit(1); } catch (SOMLibFileFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); System.exit(1); } if (ArrayUtils.isEmpty(vizs)) { System.out.println("No specific visualisation specified - saving all available visualisations."); vizs = Visualizations.getReadyVisualizationNames(); System.out.println("Found " + vizs.length + ": " + Arrays.toString(vizs)); } for (String viz : vizs) { BackgroundImageVisualizerInstance v = Visualizations.getVisualizationByName(viz); if (v == null) { System.out.println("Visualization '" + viz + "' not found!"); continue; } BackgroundImageVisualizer i = v.getVis(); GrowingLayer layer = gsom.getLayer(); try { int height = unitH * layer.getYSize(); int width = unitW * layer.getXSize(); HashMap<String, BufferedImage> visualizationFlavours = i.getVisualizationFlavours(v.getVariant(), gsom, width, height); ArrayList<String> keys = new ArrayList<String>(visualizationFlavours.keySet()); Collections.sort(keys); // if the visualisation has more than 5 flavours, we create a sub-dir for it String subDirName = ""; String oldBasename = basename; // save original base name for later if (keys.size() > 5) { String parentDir = new File(basename).getParentFile().getPath(); // get the parent path String filePrefix = basename.substring(parentDir.length()); // end the file name prefix subDirName = parentDir + File.separator + filePrefix + "_" + viz + File.separator; // compose a new // subdir name new File(subDirName).mkdir(); // create the dir basename = subDirName + filePrefix; // and extend the base name by the subdir } for (String key : keys) { File out = new File(basename + "_" + viz + key + "." + ftype); System.out.println("Generating visualisation '" + viz + "' as '" + out.getPath() + "'."); BufferedImage image = visualizationFlavours.get(key); if (unitGrid) { VisualisationUtils.drawUnitGrid(image, gsom, width, height); } ImageIO.write(image, ftype, out); } basename = oldBasename; // reset base name } catch (SOMToolboxException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } System.exit(0); }
From source file:com.hs.mail.deliver.Deliver.java
public static void main(String[] args) { CommandLine cli = null;//w w w . ja v a 2s. c o m try { cli = new PosixParser().parse(OPTS, args); } catch (ParseException e) { usage(); System.exit(EX_USAGE); } // Configuration file path String config = cli.getOptionValue("c", DEFAULT_CONFIG_LOCATION); // Message file path File file = new File(cli.getOptionValue("p")); // Envelope sender address String from = cli.getOptionValue("f"); // Destination mailboxes String[] rcpts = cli.getOptionValues("r"); if (!file.exists()) { // Message file must exist logger.error("File not exist: " + file.getAbsolutePath()); System.exit(EX_TEMPFAIL); } if (from == null || rcpts == null) { // If sender or recipients address was not specified, get the // addresses from the message header. InputStream is = null; try { is = new FileInputStream(file); MessageHeader header = new MessageHeader(is); if (from == null && header.getFrom() != null) { from = header.getFrom().getAddress(); } if (rcpts == null) { rcpts = getRecipients(header); } } catch (IOException ex) { logger.error(ex.getMessage(), ex); System.exit(EX_TEMPFAIL); } finally { IOUtils.closeQuietly(is); } } if (from == null || ArrayUtils.isEmpty(rcpts)) { usage(); System.exit(EX_USAGE); } Deliver deliver = new Deliver(); deliver.init(config); // Spool the incoming message deliver.deliver(from, rcpts, file); System.exit(EX_OK); }
From source file:de.hybris.platform.acceleratorservices.dataimport.batch.aop.AspectUtils.java
/** * Retrieves a header from the given arguments. * //from w w w . j a v a 2s.com * @param args * @return header */ public static BatchHeader getHeader(final Object[] args) { BatchHeader header = null; if (!ArrayUtils.isEmpty(args)) { final Object arg = args[0]; if (arg instanceof BatchHeader) { header = (BatchHeader) arg; } } return header; }
From source file:com.sunyue.util.calculator.core.ExpressionConverter.java
/** * Convert an infix expression to a postfix expression. * //from w w w . ja v a 2 s.co m * @param exp * expression parsed by ExpressionParser * @return postfix expression */ public static Object[] convert(Object[] exp) { if (ArrayUtils.isEmpty(exp)) { throw new CalculationException("Expression can not be empty"); } // remember if brackets are coupled int coupled = 0; // out put postfix expression List<Object> out = new ArrayList<Object>(); Stack<Object> opStack = new Stack<Object>(); for (int i = 0; i < exp.length; i++) { if (exp[i] instanceof Operator) { // operator Operator op = (Operator) exp[i]; while (true) { if (opStack.isEmpty()) { opStack.push(op); break; } else { Object obj = opStack.peek(); if (!(obj instanceof Bracket)) { Operator preOp = (Operator) opStack.peek(); if (op.getPriority() <= preOp.getPriority()) { // pop and output operator with not lower // priority out.add(opStack.pop()); } else { // push otherwise opStack.push(op); break; } } else { // push when bracket on top opStack.push(op); break; } } } } else if (Bracket.LEFT_BRACKET.equals(exp[i])) { opStack.push(exp[i]); coupled++; } else if (Bracket.RIGHT_BRACKET.equals(exp[i])) { if (coupled <= 0) { throw new CalculationException("Brackets are not coupled, missing left bracket ("); } while (true) { Object op = opStack.pop(); if (Bracket.LEFT_BRACKET.equals(op)) { // eliminate coupled brackets break; } else { // pop and output until coupled left bracket out.add(op); } } coupled--; } else { // general numbers out.add(exp[i]); } } if (coupled != 0) { throw new CalculationException("Brackets are not coupled, missing right bracket )"); } // output rest elements while (!opStack.isEmpty()) { out.add(opStack.pop()); } return out.toArray(); }
From source file:com.dianping.lion.util.UrlUtils.java
public static String resolveUrl(Map<String, ?> parameters, String... includes) { StringBuilder url = new StringBuilder(); int index = 0; try {// w w w . j a va 2s. c om if (parameters != null) { for (Entry<String, ?> entry : parameters.entrySet()) { Collection<Object> paramValues = new ArrayList<Object>(); Object paramValue = entry.getValue(); if (ArrayUtils.isEmpty(includes) || ArrayUtils.contains(includes, entry.getKey())) { Class<? extends Object> paramClass = paramValue.getClass(); if (Collection.class.isInstance(paramValue)) { paramValues.addAll((Collection<?>) paramValue); } else if (paramClass.isArray()) { Object[] valueArray = (Object[]) paramValue; for (Object value : valueArray) { paramValues.add(value); } } else { paramValues.add(paramValue); } for (Object value : paramValues) { url.append(index++ == 0 ? "" : "&").append(entry.getKey()).append("=") .append(URLEncoder.encode(value.toString(), "utf-8")); } } } } } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } return url.toString(); }
From source file:gov.nih.nci.caarray.services.external.v1_0.grid.client.GridApiUtils.java
static String getMessage(BaseFaultType fault) { if (!ArrayUtils.isEmpty(fault.getDescription())) { return fault.getDescription(0).get_value(); }// w w w . ja va 2 s . com return null; }
From source file:ch.nydi.aop.interceptor.Interceptors.java
/** * Creates an interceptor that chains other interceptors. * /*from w w w .jav a2 s . c o m*/ * @param interceptors * instances of {@link MethodInterceptor}. * @return interceptor that enclose other interceptors or Interceptors.EMPTY instance if interceptors argument is * null or empty */ public static MethodInterceptor create(final MethodInterceptor... interceptors) { if (ArrayUtils.isEmpty(interceptors)) { return Interceptors.EMPTY; } final List<MethodInterceptor> flatlist = new ArrayList<>(); for (final MethodInterceptor interceptor : interceptors) { assert (interceptor != null); if (interceptor instanceof Interceptors) { flatlist.addAll(Arrays.asList(((Interceptors) interceptor).interceptors)); } else if (EMPTY != interceptor) { flatlist.add(interceptor); } } if (flatlist.isEmpty()) { return EMPTY; } else if (flatlist.size() == 1) { return flatlist.get(0); } return new Interceptors(flatlist.toArray(new MethodInterceptor[flatlist.size()])); }