use of java.lang.String in project jdk8u_jdk by JetBrains.
the class Assembler method GenJCov.
/*
* generate file of coverage data
*/
// for JCovd.readLine() calls
@SuppressWarnings("deprecation")
public void GenJCov(Environment env) {
try {
File outFile = env.getcovFile();
if (outFile.exists()) {
DataInputStream JCovd = new DataInputStream(new BufferedInputStream(new FileInputStream(outFile)));
String CurrLine = null;
boolean first = true;
String Class;
CurrLine = JCovd.readLine();
if ((CurrLine != null) && CurrLine.startsWith(JcovMagicLine)) {
while ((CurrLine = JCovd.readLine()) != null) {
if (CurrLine.startsWith(JcovClassLine)) {
first = true;
for (Enumeration<String> e = SourceClassList.elements(); e.hasMoreElements(); ) {
String clsName = CurrLine.substring(JcovClassLine.length());
int idx = clsName.indexOf(' ');
if (idx != -1) {
clsName = clsName.substring(0, idx);
}
Class = e.nextElement();
if (Class.compareTo(clsName) == 0) {
first = false;
break;
}
}
}
if (// re-write old class
first)
TmpCovTable.addElement(CurrLine);
}
}
JCovd.close();
}
PrintStream CovFile = new PrintStream(new DataOutputStream(new FileOutputStream(outFile)));
CovFile.println(JcovMagicLine);
for (Enumeration<String> e = TmpCovTable.elements(); e.hasMoreElements(); ) {
CovFile.println(e.nextElement());
}
CovFile.close();
} catch (FileNotFoundException e) {
System.out.println("ERROR: " + e);
} catch (IOException e) {
System.out.println("ERROR: " + e);
}
}
use of java.lang.String in project TaEmCasa by Dionen.
the class JsonRequestCharsetTest method specifiedCharsetJsonObject.
@Test
public void specifiedCharsetJsonObject() throws Exception {
byte[] data = jsonObjectString().getBytes(Charset.forName("ISO-8859-1"));
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=iso-8859-1");
NetworkResponse network = new NetworkResponse(data, headers);
JsonObjectRequest objectRequest = new JsonObjectRequest("", null, null, null);
Response<JSONObject> objectResponse = objectRequest.parseNetworkResponse(network);
assertNotNull(objectResponse);
assertTrue(objectResponse.isSuccess());
//don't check the text in Czech, ISO-8859-1 doesn't support some Czech characters
assertEquals(COPY_VALUE, objectResponse.result.getString(COPY_NAME));
}
use of java.lang.String in project TaEmCasa by Dionen.
the class JsonRequestCharsetTest method specifiedCharsetJsonArray.
@Test
public void specifiedCharsetJsonArray() throws Exception {
byte[] data = jsonArrayString().getBytes(Charset.forName("ISO-8859-2"));
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=iso-8859-2");
NetworkResponse network = new NetworkResponse(data, headers);
JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);
assertNotNull(arrayResponse);
assertTrue(arrayResponse.isSuccess());
assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
// don't check the copyright symbol, ISO-8859-2 doesn't have it, but it has Czech characters
}
use of java.lang.String in project tomee by apache.
the class OpenejbJarTest method unmarshalAndMarshal.
private <T> void unmarshalAndMarshal(final Class<T> type, final java.lang.String xmlFileName, final java.lang.String expectedFile) throws Exception {
final InputStream in = getInputStream(xmlFileName);
assertNotNull(in);
final Object object = JaxbOpenejbJar2.unmarshal(type, in);
final String actual = JaxbOpenejbJar2.marshal(type, object);
final String expected;
if (xmlFileName.equals(expectedFile)) {
expected = readContent(getInputStream(xmlFileName));
} else {
expected = readContent(getInputStream(expectedFile));
}
XMLUnit.setIgnoreWhitespace(true);
try {
final Diff myDiff = new DetailedDiff(new Diff(expected, actual));
assertTrue("Files are not similar " + myDiff, myDiff.similar());
} catch (final AssertionFailedError e) {
e.printStackTrace();
assertEquals(expected, actual);
throw e;
}
}
use of java.lang.String in project android_frameworks_base by crdroidandroid.
the class TextGraphReader method readKeyValueAssignments.
private KeyValueMap readKeyValueAssignments(PatternScanner scanner, Pattern endPattern) throws GraphIOException {
// Our parser is a state-machine, and these are our states
final int STATE_IDENTIFIER = 0;
final int STATE_EQUALS = 1;
final int STATE_VALUE = 2;
final int STATE_POST_VALUE = 3;
final Pattern equalsPattern = Pattern.compile("=");
final Pattern semicolonPattern = Pattern.compile(";");
final Pattern wordPattern = Pattern.compile("[a-zA-Z]+[a-zA-Z0-9]*");
final Pattern stringPattern = Pattern.compile("'[^']*'|\\\"[^\\\"]*\\\"");
final Pattern intPattern = Pattern.compile("[0-9]+");
final Pattern floatPattern = Pattern.compile("[0-9]*\\.[0-9]+f?");
final Pattern referencePattern = Pattern.compile("\\$[a-zA-Z]+[a-zA-Z0-9]");
final Pattern booleanPattern = Pattern.compile("true|false");
int state = STATE_IDENTIFIER;
KeyValueMap newVals = new KeyValueMap();
String curKey = null;
String curValue = null;
while (!scanner.atEnd() && !(endPattern != null && scanner.peek(endPattern))) {
switch(state) {
case STATE_IDENTIFIER:
curKey = scanner.eat(wordPattern, "<identifier>");
state = STATE_EQUALS;
break;
case STATE_EQUALS:
scanner.eat(equalsPattern, "=");
state = STATE_VALUE;
break;
case STATE_VALUE:
if ((curValue = scanner.tryEat(stringPattern)) != null) {
newVals.put(curKey, curValue.substring(1, curValue.length() - 1));
} else if ((curValue = scanner.tryEat(referencePattern)) != null) {
String refName = curValue.substring(1, curValue.length());
Object referencedObject = mBoundReferences != null ? mBoundReferences.get(refName) : null;
if (referencedObject == null) {
throw new GraphIOException("Unknown object reference to '" + refName + "'!");
}
newVals.put(curKey, referencedObject);
} else if ((curValue = scanner.tryEat(booleanPattern)) != null) {
newVals.put(curKey, Boolean.parseBoolean(curValue));
} else if ((curValue = scanner.tryEat(floatPattern)) != null) {
newVals.put(curKey, Float.parseFloat(curValue));
} else if ((curValue = scanner.tryEat(intPattern)) != null) {
newVals.put(curKey, Integer.parseInt(curValue));
} else {
throw new GraphIOException(scanner.unexpectedTokenMessage("<value>"));
}
state = STATE_POST_VALUE;
break;
case STATE_POST_VALUE:
scanner.eat(semicolonPattern, ";");
state = STATE_IDENTIFIER;
break;
}
}
// Make sure end is expected
if (state != STATE_IDENTIFIER && state != STATE_POST_VALUE) {
throw new GraphIOException("Unexpected end of assignments on line " + scanner.lineNo() + "!");
}
return newVals;
}
Aggregations