protected void prepare() throws Exception { try { List execCommand = buildExecCommand(); if (execCommand == null) { mLogger.severe("No command property was specified; disabling server"); synchronized (this) { changeState(STATE_DISABLED); } return; } else { mExecArgs = (String[]) execCommand.toArray(new String[0]); StringBuffer printableCmd = new StringBuffer(4096); int index = 0; for (; index < mExecArgs.length - 1; index++) { printableCmd.append(mExecArgs[index]).append(" "); } printableCmd.append(mExecArgs[index]); mPrintableCommand = printableCmd.toString(); if (useOptimizeIt()) { System.err.println(mPrintableCommand); } } } catch (Exception ex) { mLogger.severe("Failed In preparing execargs"); throw ex; } }
/** * Find all the year records in a Calendar, it need not be a standard period (used in MRP) * * @param C_Calendar_ID calendar * @param ctx context * @param trx trx * @return MYear[] */ public static MYear[] getAllYearsInCalendar(int C_Calendar_ID, Ctx ctx, Trx trx) { List<MYear> years = new ArrayList<MYear>(); String sql = "SELECT * FROM C_Year WHERE " + "IsActive='Y' AND C_Calendar_ID = ? "; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, trx); pstmt.setInt(1, C_Calendar_ID); rs = pstmt.executeQuery(); while (rs.next()) years.add(new MYear(ctx, rs, trx)); } catch (Exception e) { s_log.log(Level.SEVERE, sql, e); } finally { DB.closeResultSet(rs); DB.closeStatement(pstmt); } MYear[] retValue = new MYear[years.size()]; years.toArray(retValue); return retValue; }
/** * Find the periods in a calendar year it need not be a standard period (used in MRP) * * @param C_Year_ID Year * @param periodType Period Type * @param ctx context * @param trx trx * @return MPeriod[] */ public static MPeriod[] getAllPeriodsInYear(int C_Year_ID, String periodType, Ctx ctx, Trx trx) { List<MPeriod> periods = new ArrayList<MPeriod>(); String sql = "SELECT * FROM C_Period WHERE IsActive='Y'"; sql = sql + " AND C_Year_ID = ?"; if (periodType != null) sql = sql + " AND PeriodType = ? "; sql = sql + " order by StartDate "; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, trx); pstmt.setInt(1, C_Year_ID); if (periodType != null) pstmt.setString(2, periodType); rs = pstmt.executeQuery(); while (rs.next()) periods.add(new MPeriod(ctx, rs, trx)); } catch (Exception e) { s_log.log(Level.SEVERE, sql, e); } finally { DB.closeResultSet(rs); DB.closeStatement(pstmt); } MPeriod[] retValue = new MPeriod[periods.size()]; periods.toArray(retValue); return retValue; }
private static String[] splitLibDirPaths(String libDirPathsString) { List<String> libDirPathList = new ArrayList<String>(8); StringTokenizer stringTokenizer = new StringTokenizer(libDirPathsString, File.pathSeparator); while (stringTokenizer.hasMoreElements()) { String libDirPath = (String) stringTokenizer.nextElement(); libDirPathList.add(libDirPath); } return libDirPathList.toArray(new String[libDirPathList.size()]); }
/** * Returns all supported capture sizes. * * @return an array of capture sizes, in bytes, never <code>null</code>. */ public Integer[] getCaptureSizes() { final String rawValue = this.properties.get(DEVICE_CAPTURESIZES); final String[] values = rawValue.split(",\\s*"); final List<Integer> result = new ArrayList<Integer>(); for (String value : values) { result.add(Integer.valueOf(value.trim())); } Collections.sort( result, NumberUtils.<Integer>createNumberComparator(false /* aSortAscending */)); return result.toArray(new Integer[result.size()]); }
/** * Returns the String array of the specified property, or null in case the returned property * string array had zero length. * * @param propertyName the name of the property that is being queried. * @param regex the delimiting regular expression * @return the array of strings computed by splitting the specified property value around matches * of the given regular expression */ public static String[] getStringArray(String propertyName, String regex) { String str = getString(propertyName); if (str == null) return null; String[] parts = str.split(regex); // Remove mal-formatted entries. List<String> res = new ArrayList<String>(); for (String s : parts) if (s != null && s.trim().length() != 0) res.add(s); if (res.size() == 0) return null; return res.toArray(new String[res.size()]); }
/** * Gets the <tt>Candidate</tt>s harvested for {@link #hostCandidate} during this harvest. * * @return an array containing the <tt>Candidate</tt>s harvested for {@link #hostCandidate} during * this harvest */ LocalCandidate[] getCandidates() { return candidates.toArray(NO_CANDIDATES); }
/** * List version * * @param * @return */ public static String joinNelementsPerLine( List<String> vnl, int divisor, String sp, boolean quote, String qm, String lnsp) { String[] vn = (String[]) vnl.toArray(new String[vnl.size()]); return joinNelementsPerLine(vn, divisor, sp, quote, qm, lnsp); }