public Character getChar(int m, int n) { return chars[getIndex(m,n)]; } public Character[] exportChar()
/** * Create the {@link MLChar} from array of {@link String}s. * * @param name the {@link MLArray} name * @param values the array of {@link String}s */ public MLChar(String name, String[] values) { this(name, new int[]{values.length, values.length > 0 ? getMaxLength(values) : 0}, MLArray.mxCHAR_CLASS, 0); for (int i = 0; i < values.length; i++) { set(values[i], i); } }
public MLChar(String name, int[] dims, int type, int attributes) { super(name, dims, type, attributes); chars = createArray(getM(), getN()); }
private MLCell histoDataHeadersAsMLChar(List<String> histoDataHeaders) { int colsSize = histoDataHeaders.size() - 2; MLCell injections = new MLCell("inj_ID", new int[]{1, colsSize}); int i = 0; for (String colkey : histoDataHeaders) { if (colkey.equals("forecastTime") || colkey.equals("datetime")) { continue; } injections.set(new MLChar("", colkey), 0, i); i++; } return injections; }
/** * Gets the m-th character matrix's row as <code>String</code>. * * @param m - row number * @return - <code>String</code> */ public String getString(int m) { StringBuffer charbuff = new StringBuffer(); for (int n = 0; n < getN(); n++) { charbuff.append(getChar(m, n)); } return charbuff.toString().trim(); }
for (final MLArray vocArrItem : vocArr) { final MLChar vocChar = (MLChar) vocArrItem; final String vocString = vocChar.getString(0); if (filter && this.keepIndex.contains(index)) { this.voc.put(vocIndex, vocString);
@Test public void testMLCharStringArray() { String[] expected = new String[]{"a", "quick", "brown", "fox"}; MLChar mlchar = new MLChar("array", expected); assertEquals(expected[0], mlchar.getString(0)); assertEquals(expected[1], mlchar.getString(1)); assertEquals(expected[2], mlchar.getString(2)); assertEquals(expected[3], mlchar.getString(3)); }
/** * Added method to allow initialization of a char array representing * an array of strings. * * @param name * @param values * @param maxlen */ public MLChar(String name, String[] values, int maxlen) { this(name, new int[]{values.length, maxlen}, MLArray.mxCHAR_CLASS, 0); int idx = 0; for (String v : values) { set(v, idx); idx++; } }
Character[] ac = ((MLChar)array).exportChar(); for ( int i = 0; i < ac.length; i++ )
private void putStochasticVariablesIntoMLStructure(StochasticVariable stochasticVariable, MLStructure stochVars, int i) { LOGGER.debug("Preparing mat data for stochastic variable " + stochasticVariable.getId()); // id MLChar id = new MLChar("", stochasticVariable.getId()); stochVars.setField("id", id, 0, i); // type MLChar type = new MLChar("", stochasticVariable.getType()); stochVars.setField("type", type, 0, i); }
/** * Gets the m-th character matrix's row as <code>String</code>. * * @param m - row number * @return - <code>String</code> */ public String getString(int m) { StringBuffer charbuff = new StringBuffer(); for (int n = 0; n < getN(); n++) { charbuff.append(getChar(m, n)); } return charbuff.toString().trim(); }