List of usage examples for java.lang Boolean parseBoolean
public static boolean parseBoolean(String s)
From source file:Main.java
public static boolean getCurrentLevelBooleanValue(Element ele, String tagName) { return Boolean.parseBoolean(getCurrentLevelTextValue(ele, tagName)); }
From source file:at.illecker.hama.rootbeer.examples.matrixmultiplication.cpu.MatrixMultiplicationBSPCpu.java
public static void main(String[] args) throws Exception { // Defaults//from ww w . j a v a 2 s. c o m int numRowsA = 1024; int numColsA = 1024; int numRowsB = 1024; int numColsB = 1024; boolean isDebugging = false; Configuration conf = new HamaConfiguration(); BSPJobClient jobClient = new BSPJobClient(conf); ClusterStatus cluster = jobClient.getClusterStatus(true); if (args.length > 0) { if (args.length == 6) { conf.setInt("bsp.peers.num", Integer.parseInt(args[0])); numRowsA = Integer.parseInt(args[1]); numColsA = Integer.parseInt(args[2]); numRowsB = Integer.parseInt(args[3]); numColsB = Integer.parseInt(args[4]); isDebugging = Boolean.parseBoolean(args[5]); } else { System.out.println("Wrong argument size!"); System.out.println(" Argument1=numBspTask"); System.out.println(" Argument2=numRowsA | Number of rows of the first input matrix"); System.out.println(" Argument3=numColsA | Number of columns of the first input matrix"); System.out.println(" Argument4=numRowsB | Number of rows of the second input matrix"); System.out.println(" Argument5=numColsB | Number of columns of the second input matrix"); System.out.println(" Argument6=debug | Enable debugging (true|false)"); return; } } else { conf.setInt("bsp.peers.num", cluster.getMaxTasks()); } conf.setBoolean(CONF_DEBUG, isDebugging); LOG.info("NumBspTask: " + conf.getInt("bsp.peers.num", 0)); LOG.info("numRowsA: " + numRowsA); LOG.info("numColsA: " + numColsA); LOG.info("numRowsB: " + numRowsB); LOG.info("numColsB: " + numColsB); LOG.info("isDebugging: " + isDebugging); LOG.info("outputPath: " + OUTPUT_DIR); if (numColsA != numRowsB) { throw new Exception("Cols of MatrixA != rows of MatrixB! (" + numColsA + "!=" + numRowsB + ")"); } // Create random DistributedRowMatrix // use constant seeds to get reproducible results // Matrix A DistributedRowMatrix.createRandomDistributedRowMatrix(conf, numRowsA, numColsA, new Random(42L), MATRIX_A_PATH, false); // Matrix B is stored transposed DistributedRowMatrix.createRandomDistributedRowMatrix(conf, numRowsB, numColsB, new Random(1337L), MATRIX_B_PATH, true); // Load DistributedRowMatrix a and b DistributedRowMatrix a = new DistributedRowMatrix(MATRIX_A_PATH, OUTPUT_DIR, numRowsA, numColsA); a.setConf(conf); DistributedRowMatrix b = new DistributedRowMatrix(MATRIX_B_PATH, OUTPUT_DIR, numRowsB, numColsB); b.setConf(conf); // MatrixMultiply all within a new BSP job long startTime = System.currentTimeMillis(); DistributedRowMatrix c = a.multiplyBSP(b, MATRIX_C_PATH, false); System.out.println("MatrixMultiplicationCpu using Hama finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds"); // Verification // Overwrite matrix B, NOT transposed for verification check DistributedRowMatrix.createRandomDistributedRowMatrix(conf, numRowsB, numColsB, new Random(1337L), MATRIX_B_PATH, false); b = new DistributedRowMatrix(MATRIX_B_PATH, OUTPUT_DIR, numRowsB, numColsB); b.setConf(conf); DistributedRowMatrix d = a.multiplyJava(b, MATRIX_D_PATH); if (c.verify(d)) { System.out.println("Verify PASSED!"); } else { System.out.println("Verify FAILED!"); } if (isDebugging) { System.out.println("Matrix A:"); a.printDistributedRowMatrix(); System.out.println("Matrix B:"); b.printDistributedRowMatrix(); System.out.println("Matrix C:"); c.printDistributedRowMatrix(); System.out.println("Matrix D:"); d.printDistributedRowMatrix(); printOutput(conf); } }
From source file:Main.java
public static boolean readBoolAttr(Element element, String attributeName) { String attributeValue = element.getAttribute(attributeName); return Boolean.parseBoolean(attributeValue); }
From source file:Main.java
/** * Parses string value retrieved from sourceElement.getAttribure(..) method * to its boolean value./*from www . ja va 2s . c om*/ * <p> * <code>true</code> is returned only if it specified explicitly, otherwise * <code>false</code> is returned. * * @param str * the string to parse * @return boolean value from string */ public static boolean string2boolean(String str) { return Boolean.parseBoolean(str); }
From source file:Main.java
public static boolean getBooleanAttribute(Element element, String name) { return Boolean.parseBoolean(getAttribute(element, name)); }
From source file:Main.java
/** * Calls getTextValue and returns a boolean value *//*from w w w . j av a2s .c o m*/ public static boolean getBooleanValue(Element ele, String tagName) { return Boolean.parseBoolean(getTextValue(ele, tagName)); }
From source file:Main.java
public static boolean getPrefBool(Context context, int keyId, int defaultValueId) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); String key = context.getString(keyId); boolean defaultValue = false; try {/*from ww w .j a v a 2s.co m*/ defaultValue = Boolean.parseBoolean(context.getString(defaultValueId)); } catch (Exception e) { /* don't care */ } return sharedPreferences.getBoolean(key, defaultValue); }
From source file:com.github.rnewson.couchdb.lucene.util.ServletUtils.java
public static boolean getBooleanParameter(final HttpServletRequest req, final String parameterName) { return Boolean.parseBoolean(req.getParameter(parameterName)); }
From source file:Main.java
public static boolean getAttributeBoolean(Node node, String attributeName, boolean defaultValue) { String value = getAttribute(node, attributeName, null); return (value == null ? defaultValue : Boolean.parseBoolean(value)); }
From source file:Main.java
public static boolean readBooleanAttribute(XmlPullParser in, String name, boolean defaultValue) { final String value = in.getAttributeValue(null, name); if (value == null) { return defaultValue; } else {/* w w w .j a v a2 s .c o m*/ return Boolean.parseBoolean(value); } }