id
int64 22
34.9k
| comment_id
int64 0
328
| comment
stringlengths 2
2.55k
| code
stringlengths 31
107k
| classification
stringclasses 6
values | isFinished
bool 1
class | code_context_2
stringlengths 21
27.3k
| code_context_10
stringlengths 29
27.3k
| code_context_20
stringlengths 29
27.3k
|
---|---|---|---|---|---|---|---|---|
14,069 | 0 | /** SETTER
* TODO: Write general description for this method
*/ | @JsonSetter("tokeType")
public void setTokeType (String value) {
this.tokeType = value;
notifyObservers(this.tokeType);
} | DOCUMENTATION | true | @JsonSetter("tokeType")
public void setTokeType (String value) {
this.tokeType = value;
notifyObservers(this.tokeType);
} | @JsonSetter("tokeType")
public void setTokeType (String value) {
this.tokeType = value;
notifyObservers(this.tokeType);
} | @JsonSetter("tokeType")
public void setTokeType (String value) {
this.tokeType = value;
notifyObservers(this.tokeType);
} |
14,070 | 0 | /** GETTER
* TODO: Write general description for this method
*/ | @JsonGetter("expiresIn")
public Long getExpiresIn ( ) {
return this.expiresIn;
} | DOCUMENTATION | true | @JsonGetter("expiresIn")
public Long getExpiresIn ( ) {
return this.expiresIn;
} | @JsonGetter("expiresIn")
public Long getExpiresIn ( ) {
return this.expiresIn;
} | @JsonGetter("expiresIn")
public Long getExpiresIn ( ) {
return this.expiresIn;
} |
14,071 | 0 | /** SETTER
* TODO: Write general description for this method
*/ | @JsonSetter("expiresIn")
public void setExpiresIn (Long value) {
this.expiresIn = value;
notifyObservers(this.expiresIn);
} | DOCUMENTATION | true | @JsonSetter("expiresIn")
public void setExpiresIn (Long value) {
this.expiresIn = value;
notifyObservers(this.expiresIn);
} | @JsonSetter("expiresIn")
public void setExpiresIn (Long value) {
this.expiresIn = value;
notifyObservers(this.expiresIn);
} | @JsonSetter("expiresIn")
public void setExpiresIn (Long value) {
this.expiresIn = value;
notifyObservers(this.expiresIn);
} |
22,278 | 0 | // FIXME: issue A:外面如果ObservableOn 其他线程,将会是异步操作,如果在实际的onNext调用之前,发生了onComplete或者onError,将会unsubscribe,导致onNext没有被调用 | @Override
public void onNext(T o) {
if (debug) Log.i(TAG, "net onNext o:" + o);
observableWrapper.setData(o);
logThread("");
if (debug) Log.e(TAG, " check subscriber :" + subscriber + " isUnsubscribed:" + subscriber.isUnsubscribed());
if (subscriber != null && !subscriber.isUnsubscribed()) {
subscriber.onNext(o);// FIXME: issue A:外面如果ObservableOn 其他线程,将会是异步操作,如果在实际的onNext调用之前,发生了onComplete或者onError,将会unsubscribe,导致onNext没有被调用
}
} | DEFECT | true | if (debug) Log.e(TAG, " check subscriber :" + subscriber + " isUnsubscribed:" + subscriber.isUnsubscribed());
if (subscriber != null && !subscriber.isUnsubscribed()) {
subscriber.onNext(o);// FIXME: issue A:外面如果ObservableOn 其他线程,将会是异步操作,如果在实际的onNext调用之前,发生了onComplete或者onError,将会unsubscribe,导致onNext没有被调用
}
} | @Override
public void onNext(T o) {
if (debug) Log.i(TAG, "net onNext o:" + o);
observableWrapper.setData(o);
logThread("");
if (debug) Log.e(TAG, " check subscriber :" + subscriber + " isUnsubscribed:" + subscriber.isUnsubscribed());
if (subscriber != null && !subscriber.isUnsubscribed()) {
subscriber.onNext(o);// FIXME: issue A:外面如果ObservableOn 其他线程,将会是异步操作,如果在实际的onNext调用之前,发生了onComplete或者onError,将会unsubscribe,导致onNext没有被调用
}
} | @Override
public void onNext(T o) {
if (debug) Log.i(TAG, "net onNext o:" + o);
observableWrapper.setData(o);
logThread("");
if (debug) Log.e(TAG, " check subscriber :" + subscriber + " isUnsubscribed:" + subscriber.isUnsubscribed());
if (subscriber != null && !subscriber.isUnsubscribed()) {
subscriber.onNext(o);// FIXME: issue A:外面如果ObservableOn 其他线程,将会是异步操作,如果在实际的onNext调用之前,发生了onComplete或者onError,将会unsubscribe,导致onNext没有被调用
}
} |
22,279 | 0 | // FIXME: issue A:外面如果ObservableOn 其他线程,将会是异步操作,如果在实际的onNext调用之前,发生了onComplete或者onError,将会unsubscribe,导致onNext没有被调用 | @Override
public void onNext(T o) {
if (debug) Log.i(TAG, "cache onNext o:" + o);
observableWrapper.setData(o);
logThread("");
if (netLatch.getCount() > 0) {
if (debug) Log.e(TAG, " check subscriber :" + subscriber + " isUnsubscribed:" + subscriber.isUnsubscribed());
if (subscriber != null && !subscriber.isUnsubscribed()) {
subscriber.onNext(o);// FIXME: issue A:外面如果ObservableOn 其他线程,将会是异步操作,如果在实际的onNext调用之前,发生了onComplete或者onError,将会unsubscribe,导致onNext没有被调用
}
} else {
if (debug) Log.e(TAG, "net result had been load,so cache is not need to load");
}
} | DEFECT | true | if (debug) Log.e(TAG, " check subscriber :" + subscriber + " isUnsubscribed:" + subscriber.isUnsubscribed());
if (subscriber != null && !subscriber.isUnsubscribed()) {
subscriber.onNext(o);// FIXME: issue A:外面如果ObservableOn 其他线程,将会是异步操作,如果在实际的onNext调用之前,发生了onComplete或者onError,将会unsubscribe,导致onNext没有被调用
}
} else { | @Override
public void onNext(T o) {
if (debug) Log.i(TAG, "cache onNext o:" + o);
observableWrapper.setData(o);
logThread("");
if (netLatch.getCount() > 0) {
if (debug) Log.e(TAG, " check subscriber :" + subscriber + " isUnsubscribed:" + subscriber.isUnsubscribed());
if (subscriber != null && !subscriber.isUnsubscribed()) {
subscriber.onNext(o);// FIXME: issue A:外面如果ObservableOn 其他线程,将会是异步操作,如果在实际的onNext调用之前,发生了onComplete或者onError,将会unsubscribe,导致onNext没有被调用
}
} else {
if (debug) Log.e(TAG, "net result had been load,so cache is not need to load");
}
} | @Override
public void onNext(T o) {
if (debug) Log.i(TAG, "cache onNext o:" + o);
observableWrapper.setData(o);
logThread("");
if (netLatch.getCount() > 0) {
if (debug) Log.e(TAG, " check subscriber :" + subscriber + " isUnsubscribed:" + subscriber.isUnsubscribed());
if (subscriber != null && !subscriber.isUnsubscribed()) {
subscriber.onNext(o);// FIXME: issue A:外面如果ObservableOn 其他线程,将会是异步操作,如果在实际的onNext调用之前,发生了onComplete或者onError,将会unsubscribe,导致onNext没有被调用
}
} else {
if (debug) Log.e(TAG, "net result had been load,so cache is not need to load");
}
} |
14,123 | 0 | /**
* do work here
*
* @param v1
* @return
*/ | public abstract Iterable<Tuple2<K, V>> doCall(final T t) throws Exception; | IMPLEMENTATION | true | public abstract Iterable<Tuple2<K, V>> doCall(final T t) throws Exception; | public abstract Iterable<Tuple2<K, V>> doCall(final T t) throws Exception; | public abstract Iterable<Tuple2<K, V>> doCall(final T t) throws Exception; |
30,517 | 0 | /**
* @param singlePointSegments
* @param string
* private static void writeSegmentsToFile(List<Segment>
* segments, String fileName) { GeometryJSON geometryJson = new
* GeometryJSON(DIGITS_OF_PRECISION); File outFile = new
* File(fileName); OutputStream oStream = null; try { oStream =
* new FileOutputStream(outFile); for (Segment segment :
* segments) { geometryJson.write(((SegmentImpl)
* segment).getLineString(), oStream); } } catch
* (FileNotFoundException e) { e.printStackTrace(); } catch
* (IOException e) { // TODO Auto-generated catch block
* e.printStackTrace(); } finally { try { if (oStream != null) {
* oStream.close(); } } catch (IOException e) { // Don't care } }
*
* }
*/
/**
* @param segment
* @deprecated - Move toward LineFeature private static boolean
* validateSegment(Segment segment) { if
* (segment.getStart().matchesLocation((segment.getEnd()))) {
* System.out.println("Single Point Line?"); return true; } else
* { return false; } }
*/
/**
* @param linesByName
*/ | private static void findIntersection(Map<String, LineString> linesByName) {
for (Entry<String, LineString> entryA : linesByName.entrySet()) {
for (Entry<String, LineString> entryB : linesByName.entrySet()) {
System.out.println("Checking " + entryA.getKey() + " against "
+ entryB.getKey());
if (entryA.equals(entryB))
continue;
// TODO: Introduce PreparedGeometry
if (entryA.getValue().intersects(entryB.getValue())) {
System.out.println(entryA.getKey() + " intersects "
+ entryB.getKey());
lineStringToJSON(entryA);
lineStringToJSON(entryB);
System.out
.println("Intersection is "
+ entryA.getValue().intersection(
entryB.getValue()));
System.exit(0);
}
}
}
} | NONSATD | true | private static void findIntersection(Map<String, LineString> linesByName) {
for (Entry<String, LineString> entryA : linesByName.entrySet()) {
for (Entry<String, LineString> entryB : linesByName.entrySet()) {
System.out.println("Checking " + entryA.getKey() + " against "
+ entryB.getKey());
if (entryA.equals(entryB))
continue;
// TODO: Introduce PreparedGeometry
if (entryA.getValue().intersects(entryB.getValue())) {
System.out.println(entryA.getKey() + " intersects "
+ entryB.getKey());
lineStringToJSON(entryA);
lineStringToJSON(entryB);
System.out
.println("Intersection is "
+ entryA.getValue().intersection(
entryB.getValue()));
System.exit(0);
}
}
}
} | private static void findIntersection(Map<String, LineString> linesByName) {
for (Entry<String, LineString> entryA : linesByName.entrySet()) {
for (Entry<String, LineString> entryB : linesByName.entrySet()) {
System.out.println("Checking " + entryA.getKey() + " against "
+ entryB.getKey());
if (entryA.equals(entryB))
continue;
// TODO: Introduce PreparedGeometry
if (entryA.getValue().intersects(entryB.getValue())) {
System.out.println(entryA.getKey() + " intersects "
+ entryB.getKey());
lineStringToJSON(entryA);
lineStringToJSON(entryB);
System.out
.println("Intersection is "
+ entryA.getValue().intersection(
entryB.getValue()));
System.exit(0);
}
}
}
} | private static void findIntersection(Map<String, LineString> linesByName) {
for (Entry<String, LineString> entryA : linesByName.entrySet()) {
for (Entry<String, LineString> entryB : linesByName.entrySet()) {
System.out.println("Checking " + entryA.getKey() + " against "
+ entryB.getKey());
if (entryA.equals(entryB))
continue;
// TODO: Introduce PreparedGeometry
if (entryA.getValue().intersects(entryB.getValue())) {
System.out.println(entryA.getKey() + " intersects "
+ entryB.getKey());
lineStringToJSON(entryA);
lineStringToJSON(entryB);
System.out
.println("Intersection is "
+ entryA.getValue().intersection(
entryB.getValue()));
System.exit(0);
}
}
}
} |
30,517 | 1 | // TODO: Introduce PreparedGeometry | private static void findIntersection(Map<String, LineString> linesByName) {
for (Entry<String, LineString> entryA : linesByName.entrySet()) {
for (Entry<String, LineString> entryB : linesByName.entrySet()) {
System.out.println("Checking " + entryA.getKey() + " against "
+ entryB.getKey());
if (entryA.equals(entryB))
continue;
// TODO: Introduce PreparedGeometry
if (entryA.getValue().intersects(entryB.getValue())) {
System.out.println(entryA.getKey() + " intersects "
+ entryB.getKey());
lineStringToJSON(entryA);
lineStringToJSON(entryB);
System.out
.println("Intersection is "
+ entryA.getValue().intersection(
entryB.getValue()));
System.exit(0);
}
}
}
} | DESIGN | true | if (entryA.equals(entryB))
continue;
// TODO: Introduce PreparedGeometry
if (entryA.getValue().intersects(entryB.getValue())) {
System.out.println(entryA.getKey() + " intersects " | private static void findIntersection(Map<String, LineString> linesByName) {
for (Entry<String, LineString> entryA : linesByName.entrySet()) {
for (Entry<String, LineString> entryB : linesByName.entrySet()) {
System.out.println("Checking " + entryA.getKey() + " against "
+ entryB.getKey());
if (entryA.equals(entryB))
continue;
// TODO: Introduce PreparedGeometry
if (entryA.getValue().intersects(entryB.getValue())) {
System.out.println(entryA.getKey() + " intersects "
+ entryB.getKey());
lineStringToJSON(entryA);
lineStringToJSON(entryB);
System.out
.println("Intersection is "
+ entryA.getValue().intersection(
entryB.getValue()));
System.exit(0); | private static void findIntersection(Map<String, LineString> linesByName) {
for (Entry<String, LineString> entryA : linesByName.entrySet()) {
for (Entry<String, LineString> entryB : linesByName.entrySet()) {
System.out.println("Checking " + entryA.getKey() + " against "
+ entryB.getKey());
if (entryA.equals(entryB))
continue;
// TODO: Introduce PreparedGeometry
if (entryA.getValue().intersects(entryB.getValue())) {
System.out.println(entryA.getKey() + " intersects "
+ entryB.getKey());
lineStringToJSON(entryA);
lineStringToJSON(entryB);
System.out
.println("Intersection is "
+ entryA.getValue().intersection(
entryB.getValue()));
System.exit(0);
}
}
}
} |
14,145 | 0 | // TODO what do? | private Optional<DecodedJWT> authenticateRequest(HttpServletRequest req, HttpServletResponse resp) {
String authHeader = StringUtil.trimToEmpty(req.getHeader("Authorization"));
String authBearerToken = authHeader.replaceFirst("^Bearer ", "");
if (authHeader.isEmpty()) {
LOG.warn("No Authorization header in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
if (authBearerToken.isEmpty()) {
LOG.warn("No Authorization Bearer token in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
DecodedJWT decodedJWT = JWT.decode(authBearerToken);
RSAKeyProvider keyProvider = new RSAKeyProvider() {
@Override
public RSAPublicKey getPublicKeyById(String keyId) {
Optional<JSONWebKey> key = jwtKeyProvider.getKey(keyId);
if (!key.isPresent()) {
// TODO what do?
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get();
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.n));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent));
// String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public RSAPrivateKey getPrivateKey() {
return null;
}
@Override
public String getPrivateKeyId() {
return null;
}
};
Algorithm algorithm;
switch (decodedJWT.getAlgorithm()) {
case "RS256":
algorithm = Algorithm.RSA256(keyProvider);
break;
default:
resp.setStatus(HTTP_BAD_REQUEST);
LOG.error("Unknown algorithm {}", decodedJWT.getAlgorithm());
return Optional.empty();
}
JWTVerifier jwtVerifier = JWT.require(algorithm)
.acceptLeeway(Duration.ofMinutes(5).getSeconds())
.withIssuer("https://api.botframework.com")
// .withAudience(ap) TODO verify audience if the app id
.build();
jwtVerifier.verify(authBearerToken);
return Optional.of(decodedJWT);
} | DESIGN | true | Optional<JSONWebKey> key = jwtKeyProvider.getKey(keyId);
if (!key.isPresent()) {
// TODO what do?
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null; | LOG.warn("No Authorization Bearer token in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
DecodedJWT decodedJWT = JWT.decode(authBearerToken);
RSAKeyProvider keyProvider = new RSAKeyProvider() {
@Override
public RSAPublicKey getPublicKeyById(String keyId) {
Optional<JSONWebKey> key = jwtKeyProvider.getKey(keyId);
if (!key.isPresent()) {
// TODO what do?
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get();
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.n));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent)); | private Optional<DecodedJWT> authenticateRequest(HttpServletRequest req, HttpServletResponse resp) {
String authHeader = StringUtil.trimToEmpty(req.getHeader("Authorization"));
String authBearerToken = authHeader.replaceFirst("^Bearer ", "");
if (authHeader.isEmpty()) {
LOG.warn("No Authorization header in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
if (authBearerToken.isEmpty()) {
LOG.warn("No Authorization Bearer token in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
DecodedJWT decodedJWT = JWT.decode(authBearerToken);
RSAKeyProvider keyProvider = new RSAKeyProvider() {
@Override
public RSAPublicKey getPublicKeyById(String keyId) {
Optional<JSONWebKey> key = jwtKeyProvider.getKey(keyId);
if (!key.isPresent()) {
// TODO what do?
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get();
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.n));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent));
// String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public RSAPrivateKey getPrivateKey() {
return null; |
14,145 | 1 | // https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171 | private Optional<DecodedJWT> authenticateRequest(HttpServletRequest req, HttpServletResponse resp) {
String authHeader = StringUtil.trimToEmpty(req.getHeader("Authorization"));
String authBearerToken = authHeader.replaceFirst("^Bearer ", "");
if (authHeader.isEmpty()) {
LOG.warn("No Authorization header in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
if (authBearerToken.isEmpty()) {
LOG.warn("No Authorization Bearer token in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
DecodedJWT decodedJWT = JWT.decode(authBearerToken);
RSAKeyProvider keyProvider = new RSAKeyProvider() {
@Override
public RSAPublicKey getPublicKeyById(String keyId) {
Optional<JSONWebKey> key = jwtKeyProvider.getKey(keyId);
if (!key.isPresent()) {
// TODO what do?
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get();
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.n));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent));
// String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public RSAPrivateKey getPrivateKey() {
return null;
}
@Override
public String getPrivateKeyId() {
return null;
}
};
Algorithm algorithm;
switch (decodedJWT.getAlgorithm()) {
case "RS256":
algorithm = Algorithm.RSA256(keyProvider);
break;
default:
resp.setStatus(HTTP_BAD_REQUEST);
LOG.error("Unknown algorithm {}", decodedJWT.getAlgorithm());
return Optional.empty();
}
JWTVerifier jwtVerifier = JWT.require(algorithm)
.acceptLeeway(Duration.ofMinutes(5).getSeconds())
.withIssuer("https://api.botframework.com")
// .withAudience(ap) TODO verify audience if the app id
.build();
jwtVerifier.verify(authBearerToken);
return Optional.of(decodedJWT);
} | NONSATD | true | }
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get(); | RSAKeyProvider keyProvider = new RSAKeyProvider() {
@Override
public RSAPublicKey getPublicKeyById(String keyId) {
Optional<JSONWebKey> key = jwtKeyProvider.getKey(keyId);
if (!key.isPresent()) {
// TODO what do?
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get();
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.n));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent));
// String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e); | LOG.warn("No Authorization header in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
if (authBearerToken.isEmpty()) {
LOG.warn("No Authorization Bearer token in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
DecodedJWT decodedJWT = JWT.decode(authBearerToken);
RSAKeyProvider keyProvider = new RSAKeyProvider() {
@Override
public RSAPublicKey getPublicKeyById(String keyId) {
Optional<JSONWebKey> key = jwtKeyProvider.getKey(keyId);
if (!key.isPresent()) {
// TODO what do?
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get();
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.n));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent));
// String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public RSAPrivateKey getPrivateKey() {
return null;
}
@Override
public String getPrivateKeyId() {
return null;
} |
14,145 | 2 | // String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData)); | private Optional<DecodedJWT> authenticateRequest(HttpServletRequest req, HttpServletResponse resp) {
String authHeader = StringUtil.trimToEmpty(req.getHeader("Authorization"));
String authBearerToken = authHeader.replaceFirst("^Bearer ", "");
if (authHeader.isEmpty()) {
LOG.warn("No Authorization header in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
if (authBearerToken.isEmpty()) {
LOG.warn("No Authorization Bearer token in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
DecodedJWT decodedJWT = JWT.decode(authBearerToken);
RSAKeyProvider keyProvider = new RSAKeyProvider() {
@Override
public RSAPublicKey getPublicKeyById(String keyId) {
Optional<JSONWebKey> key = jwtKeyProvider.getKey(keyId);
if (!key.isPresent()) {
// TODO what do?
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get();
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.n));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent));
// String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public RSAPrivateKey getPrivateKey() {
return null;
}
@Override
public String getPrivateKeyId() {
return null;
}
};
Algorithm algorithm;
switch (decodedJWT.getAlgorithm()) {
case "RS256":
algorithm = Algorithm.RSA256(keyProvider);
break;
default:
resp.setStatus(HTTP_BAD_REQUEST);
LOG.error("Unknown algorithm {}", decodedJWT.getAlgorithm());
return Optional.empty();
}
JWTVerifier jwtVerifier = JWT.require(algorithm)
.acceptLeeway(Duration.ofMinutes(5).getSeconds())
.withIssuer("https://api.botframework.com")
// .withAudience(ap) TODO verify audience if the app id
.build();
jwtVerifier.verify(authBearerToken);
return Optional.of(decodedJWT);
} | NONSATD | true | BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent));
// String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e); | resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get();
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.n));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent));
// String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public RSAPrivateKey getPrivateKey() {
return null;
}
@Override
public String getPrivateKeyId() { | resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
DecodedJWT decodedJWT = JWT.decode(authBearerToken);
RSAKeyProvider keyProvider = new RSAKeyProvider() {
@Override
public RSAPublicKey getPublicKeyById(String keyId) {
Optional<JSONWebKey> key = jwtKeyProvider.getKey(keyId);
if (!key.isPresent()) {
// TODO what do?
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get();
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.n));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent));
// String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public RSAPrivateKey getPrivateKey() {
return null;
}
@Override
public String getPrivateKeyId() {
return null;
}
};
Algorithm algorithm;
switch (decodedJWT.getAlgorithm()) {
case "RS256":
algorithm = Algorithm.RSA256(keyProvider);
break;
default:
resp.setStatus(HTTP_BAD_REQUEST); |
14,145 | 3 | // .withAudience(ap) TODO verify audience if the app id | private Optional<DecodedJWT> authenticateRequest(HttpServletRequest req, HttpServletResponse resp) {
String authHeader = StringUtil.trimToEmpty(req.getHeader("Authorization"));
String authBearerToken = authHeader.replaceFirst("^Bearer ", "");
if (authHeader.isEmpty()) {
LOG.warn("No Authorization header in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
if (authBearerToken.isEmpty()) {
LOG.warn("No Authorization Bearer token in request");
resp.setStatus(HTTP_FORBIDDEN);
return Optional.empty();
}
DecodedJWT decodedJWT = JWT.decode(authBearerToken);
RSAKeyProvider keyProvider = new RSAKeyProvider() {
@Override
public RSAPublicKey getPublicKeyById(String keyId) {
Optional<JSONWebKey> key = jwtKeyProvider.getKey(keyId);
if (!key.isPresent()) {
// TODO what do?
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
try {
// https://github.com/auth0/jwks-rsa-java/blob/master/src/main/java/com/auth0/jwk/Jwk.java#L171
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
JSONWebKey jwk = key.get();
BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.n));
BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.e));
return (RSAPublicKey) keyFactory.generatePublic(new RSAPublicKeySpec(modulus, exponent));
// String keyDataString = key.get().x509CertificateChain.get(0);
// byte[] keyData = Base64.getDecoder().decode(keyDataString.getBytes(StandardCharsets.UTF_8));
// return (RSAPublicKey) keyFactory.generatePublic(new X509EncodedKeySpec(keyData));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public RSAPrivateKey getPrivateKey() {
return null;
}
@Override
public String getPrivateKeyId() {
return null;
}
};
Algorithm algorithm;
switch (decodedJWT.getAlgorithm()) {
case "RS256":
algorithm = Algorithm.RSA256(keyProvider);
break;
default:
resp.setStatus(HTTP_BAD_REQUEST);
LOG.error("Unknown algorithm {}", decodedJWT.getAlgorithm());
return Optional.empty();
}
JWTVerifier jwtVerifier = JWT.require(algorithm)
.acceptLeeway(Duration.ofMinutes(5).getSeconds())
.withIssuer("https://api.botframework.com")
// .withAudience(ap) TODO verify audience if the app id
.build();
jwtVerifier.verify(authBearerToken);
return Optional.of(decodedJWT);
} | IMPLEMENTATION | true | .acceptLeeway(Duration.ofMinutes(5).getSeconds())
.withIssuer("https://api.botframework.com")
// .withAudience(ap) TODO verify audience if the app id
.build();
jwtVerifier.verify(authBearerToken); | algorithm = Algorithm.RSA256(keyProvider);
break;
default:
resp.setStatus(HTTP_BAD_REQUEST);
LOG.error("Unknown algorithm {}", decodedJWT.getAlgorithm());
return Optional.empty();
}
JWTVerifier jwtVerifier = JWT.require(algorithm)
.acceptLeeway(Duration.ofMinutes(5).getSeconds())
.withIssuer("https://api.botframework.com")
// .withAudience(ap) TODO verify audience if the app id
.build();
jwtVerifier.verify(authBearerToken);
return Optional.of(decodedJWT);
} | return null;
}
@Override
public String getPrivateKeyId() {
return null;
}
};
Algorithm algorithm;
switch (decodedJWT.getAlgorithm()) {
case "RS256":
algorithm = Algorithm.RSA256(keyProvider);
break;
default:
resp.setStatus(HTTP_BAD_REQUEST);
LOG.error("Unknown algorithm {}", decodedJWT.getAlgorithm());
return Optional.empty();
}
JWTVerifier jwtVerifier = JWT.require(algorithm)
.acceptLeeway(Duration.ofMinutes(5).getSeconds())
.withIssuer("https://api.botframework.com")
// .withAudience(ap) TODO verify audience if the app id
.build();
jwtVerifier.verify(authBearerToken);
return Optional.of(decodedJWT);
} |
22,340 | 0 | /**
* get the searchbeans for each ObjectEntity
* fill the beans with all information, regardless of permission.
*
* @return
*/ | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | NONSATD | true | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} |
22,340 | 1 | // just an empty list | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | NONSATD | true | List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList(); | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{ |
22,340 | 2 | // get all the ObjectEntity's in the tree | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | NONSATD | true | if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities) | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean); |
22,340 | 3 | // only objects, exclude derived series | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | NONSATD | true | for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{ | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean); | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info |
22,340 | 4 | // create a bean | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | NONSATD | true | if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it | List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList(); | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
} |
22,340 | 5 | // fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | DESIGN | true | // create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info | return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
} | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} |
22,340 | 6 | // then the object info | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | NONSATD | true | // because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well | {
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!! | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} |
22,340 | 7 | // all the ObjectEntities subentities must fill this bean as well
// but not Objects? | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | DESIGN | true | // then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities) | if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean); | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} |
22,340 | 8 | // Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!! | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | NONSATD | true | searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list | searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} |
22,340 | 9 | // should be the repository id for this peace of info | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | NONSATD | true | // Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean); | searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | // only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} |
22,340 | 10 | // add to the list | public List<DccdSB> getSearchBeans()
{
List<DccdSB> searchBeans = new ArrayList<DccdSB>();
if (!hasTridas())
return searchBeans; // just an empty list
// get all the ObjectEntity's in the tree
List<Entity> entities = getSubTreeAsList();
for (Entity entity : entities)
{
// only objects, exclude derived series
if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | NONSATD | true | // just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
} | // all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} | if (entity instanceof ObjectEntity)
{
// create a bean
DccdSB searchBean = new DccdObjectSB();
// fill it
// first with the project info, maybe this can be done more efficiently
// because same conversions are done for every Object again
searchBean = fillSearchBean(searchBean);
// then the object info
searchBean = entity.fillSearchBean(searchBean);
// all the ObjectEntities subentities must fill this bean as well
// but not Objects?
List<Entity> subentities = entity.getSubTreeAsList();
for (Entity subentity : subentities)
{
searchBean = subentity.fillSearchBean(searchBean);
}
// Note id should be the (system) identifier in the repository (sid)
// just hoping that is is set correctly when read from the repository!!!
searchBean.setDatastreamId(entity.getId());// should be the repository id for this peace of info
// add to the list
searchBeans.add(searchBean);
}
}
return searchBeans;
} |
14,150 | 0 | /**
* This method receives two parameters. The first parameter is the page
* in which we have discovered this new url and the second parameter is
* the new url. You should implement this function to specify whether
* the given url should be crawled or not (based on your crawling logic).
* In this example, we are instructing the crawler to ignore urls that
* have css, js, git, ... extensions and to only accept urls that start
* with "http://www.ics.uci.edu/". In this case, we didn't need the
* referringPage parameter to make the decision.
*/ | @Override
public boolean shouldVisit(Page referringPage, WebURL url) {
String href = url.getURL().toLowerCase();
return !FILTERS.matcher(href).matches()
&& href.startsWith("http://www.ics.uci.edu/");
} | IMPLEMENTATION | true | @Override
public boolean shouldVisit(Page referringPage, WebURL url) {
String href = url.getURL().toLowerCase();
return !FILTERS.matcher(href).matches()
&& href.startsWith("http://www.ics.uci.edu/");
} | @Override
public boolean shouldVisit(Page referringPage, WebURL url) {
String href = url.getURL().toLowerCase();
return !FILTERS.matcher(href).matches()
&& href.startsWith("http://www.ics.uci.edu/");
} | @Override
public boolean shouldVisit(Page referringPage, WebURL url) {
String href = url.getURL().toLowerCase();
return !FILTERS.matcher(href).matches()
&& href.startsWith("http://www.ics.uci.edu/");
} |
14,154 | 0 | // TODO: The timings here will be inaccurate on slow systems. | @Test
void buildTask() throws Exception {
VelocityScheduler scheduler = new VelocityScheduler(new FakePluginManager());
CountDownLatch latch = new CountDownLatch(1);
ScheduledTask task = scheduler.buildTask(FakePluginManager.PLUGIN_A, latch::countDown)
.schedule();
latch.await();
assertEquals(TaskStatus.FINISHED, task.status());
} | DEFECT | true | @Test
void buildTask() throws Exception {
VelocityScheduler scheduler = new VelocityScheduler(new FakePluginManager());
CountDownLatch latch = new CountDownLatch(1);
ScheduledTask task = scheduler.buildTask(FakePluginManager.PLUGIN_A, latch::countDown)
.schedule();
latch.await();
assertEquals(TaskStatus.FINISHED, task.status());
} | @Test
void buildTask() throws Exception {
VelocityScheduler scheduler = new VelocityScheduler(new FakePluginManager());
CountDownLatch latch = new CountDownLatch(1);
ScheduledTask task = scheduler.buildTask(FakePluginManager.PLUGIN_A, latch::countDown)
.schedule();
latch.await();
assertEquals(TaskStatus.FINISHED, task.status());
} | @Test
void buildTask() throws Exception {
VelocityScheduler scheduler = new VelocityScheduler(new FakePluginManager());
CountDownLatch latch = new CountDownLatch(1);
ScheduledTask task = scheduler.buildTask(FakePluginManager.PLUGIN_A, latch::countDown)
.schedule();
latch.await();
assertEquals(TaskStatus.FINISHED, task.status());
} |
30,548 | 0 | //TODO: Add functionality for edit button | @Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
ParseUser currentUser = ParseUser.getCurrentUser();
String role = currentUser.getString("role");
if(convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.product_list_item, null);
holder = new ViewHolder();
holder.companyNameLabel = (TextView) convertView.findViewById(R.id.companyName);
holder.productNameLabel = (TextView) convertView.findViewById(R.id.productNameLabel);
holder.priceNameLabel = (TextView) convertView.findViewById(R.id.productPriceLabel);
holder.addItemButton = (Button) convertView.findViewById(R.id.btnAddToCart);
holder.editItemButton = (Button) convertView.findViewById(R.id.btnEditButton);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (role.equals("Company Account")) {
holder.editItemButton.setVisibility(View.VISIBLE);
}
else if (role.equals("Personal Account")) {
holder.addItemButton.setVisibility(View.VISIBLE);
}
final Product product = mProducts.get(position);
holder.companyNameLabel.setText(product.getCompany());
holder.productNameLabel.setText(product.getProductName());
holder.priceNameLabel.setText(product.getPrice() + "");
holder.addItemButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, CheckoutActivity.class);
intent.putExtra("product", product.getProductName());
mContext.startActivity(intent);
//TODO: Add functionality for edit button
}
});
return convertView;
} | IMPLEMENTATION | true | intent.putExtra("product", product.getProductName());
mContext.startActivity(intent);
//TODO: Add functionality for edit button
}
}); | final Product product = mProducts.get(position);
holder.companyNameLabel.setText(product.getCompany());
holder.productNameLabel.setText(product.getProductName());
holder.priceNameLabel.setText(product.getPrice() + "");
holder.addItemButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, CheckoutActivity.class);
intent.putExtra("product", product.getProductName());
mContext.startActivity(intent);
//TODO: Add functionality for edit button
}
});
return convertView;
} | convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (role.equals("Company Account")) {
holder.editItemButton.setVisibility(View.VISIBLE);
}
else if (role.equals("Personal Account")) {
holder.addItemButton.setVisibility(View.VISIBLE);
}
final Product product = mProducts.get(position);
holder.companyNameLabel.setText(product.getCompany());
holder.productNameLabel.setText(product.getProductName());
holder.priceNameLabel.setText(product.getPrice() + "");
holder.addItemButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, CheckoutActivity.class);
intent.putExtra("product", product.getProductName());
mContext.startActivity(intent);
//TODO: Add functionality for edit button
}
});
return convertView;
} |
22,367 | 0 | // TODO Implement me, pls :( | public static void main(String[] args) {
// TODO Implement me, pls :(
} | IMPLEMENTATION | true | public static void main(String[] args) {
// TODO Implement me, pls :(
} | public static void main(String[] args) {
// TODO Implement me, pls :(
} | public static void main(String[] args) {
// TODO Implement me, pls :(
} |
30,563 | 0 | /**
* Returns true of the queued redis message has timed out (ie, created > 25 minutes ago)
*/ | private boolean hasTimedOut(SentMessage sentMessage) {
// NPE fix. For some reason under heavy load redis can return null records.
if (sentMessage == null) {
return false;
}
long now = new Date().getTime();
Date createdTs = sentMessage.getCreatedTs();
return createdTs.getTime() + faxTimeout < now;
} | NONSATD | true | private boolean hasTimedOut(SentMessage sentMessage) {
// NPE fix. For some reason under heavy load redis can return null records.
if (sentMessage == null) {
return false;
}
long now = new Date().getTime();
Date createdTs = sentMessage.getCreatedTs();
return createdTs.getTime() + faxTimeout < now;
} | private boolean hasTimedOut(SentMessage sentMessage) {
// NPE fix. For some reason under heavy load redis can return null records.
if (sentMessage == null) {
return false;
}
long now = new Date().getTime();
Date createdTs = sentMessage.getCreatedTs();
return createdTs.getTime() + faxTimeout < now;
} | private boolean hasTimedOut(SentMessage sentMessage) {
// NPE fix. For some reason under heavy load redis can return null records.
if (sentMessage == null) {
return false;
}
long now = new Date().getTime();
Date createdTs = sentMessage.getCreatedTs();
return createdTs.getTime() + faxTimeout < now;
} |
30,563 | 1 | // NPE fix. For some reason under heavy load redis can return null records. | private boolean hasTimedOut(SentMessage sentMessage) {
// NPE fix. For some reason under heavy load redis can return null records.
if (sentMessage == null) {
return false;
}
long now = new Date().getTime();
Date createdTs = sentMessage.getCreatedTs();
return createdTs.getTime() + faxTimeout < now;
} | DEFECT | true | private boolean hasTimedOut(SentMessage sentMessage) {
// NPE fix. For some reason under heavy load redis can return null records.
if (sentMessage == null) {
return false; | private boolean hasTimedOut(SentMessage sentMessage) {
// NPE fix. For some reason under heavy load redis can return null records.
if (sentMessage == null) {
return false;
}
long now = new Date().getTime();
Date createdTs = sentMessage.getCreatedTs();
return createdTs.getTime() + faxTimeout < now;
} | private boolean hasTimedOut(SentMessage sentMessage) {
// NPE fix. For some reason under heavy load redis can return null records.
if (sentMessage == null) {
return false;
}
long now = new Date().getTime();
Date createdTs = sentMessage.getCreatedTs();
return createdTs.getTime() + faxTimeout < now;
} |
22,391 | 0 | // TODO: fix how this is rendering in XML | public Integer getLastmodifiedby() {
return this.lastmodifiedby;
} | DEFECT | true | public Integer getLastmodifiedby() {
return this.lastmodifiedby;
} | public Integer getLastmodifiedby() {
return this.lastmodifiedby;
} | public Integer getLastmodifiedby() {
return this.lastmodifiedby;
} |
22,404 | 0 | //TODO Need a fix to make sure the value is not null | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
return cursorLoader;
} | DEFECT | true | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS, | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
return cursorLoader;
} |
22,404 | 1 | //Sort order: Ascending by date | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
return cursorLoader;
} | NONSATD | true | //TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null, | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
return cursorLoader;
} |
22,404 | 2 | //Build the Uri needed for the query | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
return cursorLoader;
} | NONSATD | true | //Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis()); | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
return cursorLoader; | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
return cursorLoader;
} |
22,404 | 3 | //Create a cursor loader | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
return cursorLoader;
} | NONSATD | true | Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri, | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
return cursorLoader;
} | @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
//TODO Need a fix to make sure the value is not null
String locationSetting = Utility.getPreferredLocation(getActivity());
//Sort order: Ascending by date
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
//Build the Uri needed for the query
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting,
System.currentTimeMillis());
//Create a cursor loader
CursorLoader cursorLoader = new CursorLoader(getActivity(),
weatherForLocationUri,
FORECAST_COLUMNS,
null,
null,
sortOrder);
return cursorLoader;
} |
14,220 | 0 | //log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> ----------------------------------------------------------- | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | NONSATD | true | public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version"); | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else { | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl); |
14,220 | 1 | // Add this document to the list of processed documents. | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | NONSATD | true | ((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) { | String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id"); | public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic(); |
14,220 | 2 | // FIXME: what to do about language? | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | DEFECT | true | }
}
// FIXME: what to do about language?
}
// ----- <facet> ---------------------------------------------------------- | TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ---------------------------------------------------------- | if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid); |
14,220 | 3 | // ----- <facet> ---------------------------------------------------------- | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | NONSATD | true | // FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id"); | ((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id"); | if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
} |
14,220 | 4 | // FIXME: complain if no id | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | DEFECT | true | else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id); | processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id); | if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url"); |
14,220 | 5 | // ----- <topic> ---------------------------------------------------------- | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | NONSATD | true | keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id"); | // FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid); | TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------ |
14,220 | 6 | // FIXME: complain if no id | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | DEFECT | true | else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id); | processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id); | if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url"); |
14,220 | 7 | // FIXME: complain if no refs | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | DEFECT | true | if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic); | }
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
} | }
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ---------------------------------------------------- |
14,220 | 8 | // ----- <page> ----------------------------------------------------------- | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | NONSATD | true | parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url"); | // FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none | else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName)) |
14,220 | 9 | // FIXME: complain if no url | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | DEFECT | true | else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url)); | String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
} | current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace(); |
14,220 | 10 | // ----- <occurrence>------------------------------------------------------ | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | NONSATD | true | current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid"); | TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ---------------------------------------------------------- | // ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} |
14,220 | 11 | // FIXME: complain if none | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | DESIGN | true | else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic); | // ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName)) | // FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} |
14,220 | 12 | // ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> -------------------------------------------------------- | @Override
public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
try {
//log.debug("S: '" + uri + "' " + qName);
// ----- <xfml> -----------------------------------------------------------
if (EL_XFML.equals(qName)) {
String version = atts.getValue("version");
if (version == null)
log.warn("No version attribute on 'xfml' element");
if (!"1.0".equals(version))
log.warn("Unsupported XFML version: " + version);
String mapurl = atts.getValue("url");
if (mapurl == null)
log.warn("No url attribute on 'xfml' element");
else {
try {
map_uri = new URILocator(mapurl);
TopicMapStoreIF store = topicmap.getStore();
if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
((AbstractTopicMapStore) store).setBaseAddress(map_uri);
doc_address = map_uri;
// Add this document to the list of processed documents.
processed_documents_accumulated.add(getBaseAddress());
} catch (MalformedURLException e) {
log.warn("Invalid xfml base URL: " + mapurl);
}
}
// FIXME: what to do about language?
}
// ----- <facet> ----------------------------------------------------------
else if (EL_FACET.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
keep_content = true;
}
// ----- <topic> ----------------------------------------------------------
else if (EL_TOPIC.equals(qName)) {
String id = atts.getValue("id");
// FIXME: complain if no id
current_topic = builder.makeTopic();
registerSourceLocator(current_topic, id);
String parentid = atts.getValue("parentTopicid");
if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | NONSATD | true | occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName)) | current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} | if (parentid == null)
parentid = atts.getValue("facetid");
// FIXME: complain if no refs
TopicIF parent = resolveTopicRef("#" + parentid);
parentBuilder.makeAssociation(parent, current_topic);
}
// ----- <page> -----------------------------------------------------------
else if (EL_PAGE.equals(qName)) {
String url = atts.getValue("url");
// FIXME: complain if no url
current_topic = builder.makeTopic();
current_topic.addSubjectLocator(createLocator(url));
}
// ----- <occurrence>------------------------------------------------------
else if (EL_OCCURRENCE.equals(qName)) {
String topicid = atts.getValue("topicid");
// FIXME: complain if none
TopicIF subject = resolveTopicRef("#" + topicid);
occursBuilder.makeAssociation(subject, current_topic);
}
// ----- <name> -----------------------------------------------------------
// ----- <psi> ------------------------------------------------------------
// ----- <description> ----------------------------------------------------
// ----- <title> ----------------------------------------------------------
// ----- <connect> --------------------------------------------------------
else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
EL_TITLE.equals(qName) || EL_CONNECT.equals(qName))
keep_content = true;
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
} |
22,436 | 0 | // TODO Auto-generated method stub
// first populate, then call super | @Override
public void prepareForSave(KualiDocumentEvent event) {
// TODO Auto-generated method stub
// first populate, then call super
if (event instanceof AttributedContinuePurapEvent) {
SpringContext.getBean(OleInvoiceService.class).populateInvoice(this);
}
if(this.getVendorPaymentTermsCode() != null && this.getVendorPaymentTermsCode().isEmpty()) {
this.setVendorPaymentTermsCode(null);
}
super.prepareForSave(event);
try {
if (this.proformaIndicator && !this.immediatePaymentIndicator) {
this.setImmediatePaymentIndicator(true);
}
LOG.debug("###########Inside OleInvoiceDocument " + "repareForSave###########");
List<OleInvoiceItem> items = new ArrayList<OleInvoiceItem>();
items = this.getItems();
Iterator iterator = items.iterator();
HashMap dataMap = new HashMap();
String titleId;
while (iterator.hasNext()) {
LOG.debug("###########inside prepareForSave item loop###########");
Object object = iterator.next();
if (object instanceof OleInvoiceItem) {
LOG.debug("###########inside prepareForSave ole payment request item###########");
OleInvoiceItem singleItem = (OleInvoiceItem) object;
if (StringUtils.isNotBlank(this.invoiceCurrencyType)) {
this.setInvoiceCurrencyTypeId(new Long(this.getInvoiceCurrencyType()));
String currencyType = SpringContext.getBean(OleInvoiceService.class).getCurrencyType(this.getInvoiceCurrencyType());
if (StringUtils.isNotBlank(currencyType)) {
if(!currencyType.equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)) {
if (StringUtils.isNotBlank(this.getInvoiceCurrencyExchangeRate())) {
try {
Double.parseDouble(this.getInvoiceCurrencyExchangeRate());
singleItem.setItemExchangeRate(new KualiDecimal(this.getInvoiceCurrencyExchangeRate()));
singleItem.setExchangeRate(this.getInvoiceCurrencyExchangeRate());
}
catch (NumberFormatException nfe) {
throw new RuntimeException("Invalid Exchange Rate", nfe);
}
} else {
BigDecimal exchangeRate = SpringContext.getBean(OleInvoiceService.class).getExchangeRate(this.getInvoiceCurrencyType()).getExchangeRate();
this.setInvoiceCurrencyExchangeRate(exchangeRate.toString());
singleItem.setItemExchangeRate(new KualiDecimal(exchangeRate));
singleItem.setExchangeRate(exchangeRate.toString());
}
this.setVendorInvoiceAmount(this.getForeignVendorInvoiceAmount() != null ?
new KualiDecimal(this.getForeignVendorInvoiceAmount().divide(new BigDecimal(singleItem.getExchangeRate()), 4, RoundingMode.HALF_UP)) : null);
}
}
}
setItemDescription(singleItem);
Map<String, String> copyCriteria = new HashMap<String, String>();
if (singleItem.getPaidCopies().size() <= 0 && singleItem.getPoItemIdentifier() != null && (this.getPurapDocumentIdentifier() != null && singleItem.getItemIdentifier() != null)) {
copyCriteria.put("poItemId", singleItem.getPoItemIdentifier().toString());
List<OleCopy> copies = (List<OleCopy>) getBusinessObjectService().findMatching(OleCopy.class, copyCriteria);
if (copies.size() > 0) {
List<OLEPaidCopy> paidCopies = new ArrayList<OLEPaidCopy>();
for (OleCopy copy : copies) {
OLEPaidCopy paidCopy = new OLEPaidCopy();
paidCopy.setCopyId(copy.getCopyId());
paidCopy.setInvoiceItemId(this.getPurapDocumentIdentifier());
paidCopy.setInvoiceIdentifier(singleItem.getItemIdentifier());
//copy.getOlePaidCopies().add(paidCopy);
paidCopies.add(paidCopy);
}
getBusinessObjectService().save(paidCopies);
singleItem.setPaidCopies(paidCopies);
}
}
}
}
} catch (Exception e) {
LOG.error("Exception during prepareForSave() in OleInvoiceDocument", e);
throw new RuntimeException(e);
}
} | IMPLEMENTATION | true | @Override
public void prepareForSave(KualiDocumentEvent event) {
// TODO Auto-generated method stub
// first populate, then call super
if (event instanceof AttributedContinuePurapEvent) {
SpringContext.getBean(OleInvoiceService.class).populateInvoice(this); | @Override
public void prepareForSave(KualiDocumentEvent event) {
// TODO Auto-generated method stub
// first populate, then call super
if (event instanceof AttributedContinuePurapEvent) {
SpringContext.getBean(OleInvoiceService.class).populateInvoice(this);
}
if(this.getVendorPaymentTermsCode() != null && this.getVendorPaymentTermsCode().isEmpty()) {
this.setVendorPaymentTermsCode(null);
}
super.prepareForSave(event);
try {
if (this.proformaIndicator && !this.immediatePaymentIndicator) {
this.setImmediatePaymentIndicator(true); | @Override
public void prepareForSave(KualiDocumentEvent event) {
// TODO Auto-generated method stub
// first populate, then call super
if (event instanceof AttributedContinuePurapEvent) {
SpringContext.getBean(OleInvoiceService.class).populateInvoice(this);
}
if(this.getVendorPaymentTermsCode() != null && this.getVendorPaymentTermsCode().isEmpty()) {
this.setVendorPaymentTermsCode(null);
}
super.prepareForSave(event);
try {
if (this.proformaIndicator && !this.immediatePaymentIndicator) {
this.setImmediatePaymentIndicator(true);
}
LOG.debug("###########Inside OleInvoiceDocument " + "repareForSave###########");
List<OleInvoiceItem> items = new ArrayList<OleInvoiceItem>();
items = this.getItems();
Iterator iterator = items.iterator();
HashMap dataMap = new HashMap();
String titleId;
while (iterator.hasNext()) {
LOG.debug("###########inside prepareForSave item loop###########");
Object object = iterator.next(); |
22,436 | 1 | //copy.getOlePaidCopies().add(paidCopy); | @Override
public void prepareForSave(KualiDocumentEvent event) {
// TODO Auto-generated method stub
// first populate, then call super
if (event instanceof AttributedContinuePurapEvent) {
SpringContext.getBean(OleInvoiceService.class).populateInvoice(this);
}
if(this.getVendorPaymentTermsCode() != null && this.getVendorPaymentTermsCode().isEmpty()) {
this.setVendorPaymentTermsCode(null);
}
super.prepareForSave(event);
try {
if (this.proformaIndicator && !this.immediatePaymentIndicator) {
this.setImmediatePaymentIndicator(true);
}
LOG.debug("###########Inside OleInvoiceDocument " + "repareForSave###########");
List<OleInvoiceItem> items = new ArrayList<OleInvoiceItem>();
items = this.getItems();
Iterator iterator = items.iterator();
HashMap dataMap = new HashMap();
String titleId;
while (iterator.hasNext()) {
LOG.debug("###########inside prepareForSave item loop###########");
Object object = iterator.next();
if (object instanceof OleInvoiceItem) {
LOG.debug("###########inside prepareForSave ole payment request item###########");
OleInvoiceItem singleItem = (OleInvoiceItem) object;
if (StringUtils.isNotBlank(this.invoiceCurrencyType)) {
this.setInvoiceCurrencyTypeId(new Long(this.getInvoiceCurrencyType()));
String currencyType = SpringContext.getBean(OleInvoiceService.class).getCurrencyType(this.getInvoiceCurrencyType());
if (StringUtils.isNotBlank(currencyType)) {
if(!currencyType.equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)) {
if (StringUtils.isNotBlank(this.getInvoiceCurrencyExchangeRate())) {
try {
Double.parseDouble(this.getInvoiceCurrencyExchangeRate());
singleItem.setItemExchangeRate(new KualiDecimal(this.getInvoiceCurrencyExchangeRate()));
singleItem.setExchangeRate(this.getInvoiceCurrencyExchangeRate());
}
catch (NumberFormatException nfe) {
throw new RuntimeException("Invalid Exchange Rate", nfe);
}
} else {
BigDecimal exchangeRate = SpringContext.getBean(OleInvoiceService.class).getExchangeRate(this.getInvoiceCurrencyType()).getExchangeRate();
this.setInvoiceCurrencyExchangeRate(exchangeRate.toString());
singleItem.setItemExchangeRate(new KualiDecimal(exchangeRate));
singleItem.setExchangeRate(exchangeRate.toString());
}
this.setVendorInvoiceAmount(this.getForeignVendorInvoiceAmount() != null ?
new KualiDecimal(this.getForeignVendorInvoiceAmount().divide(new BigDecimal(singleItem.getExchangeRate()), 4, RoundingMode.HALF_UP)) : null);
}
}
}
setItemDescription(singleItem);
Map<String, String> copyCriteria = new HashMap<String, String>();
if (singleItem.getPaidCopies().size() <= 0 && singleItem.getPoItemIdentifier() != null && (this.getPurapDocumentIdentifier() != null && singleItem.getItemIdentifier() != null)) {
copyCriteria.put("poItemId", singleItem.getPoItemIdentifier().toString());
List<OleCopy> copies = (List<OleCopy>) getBusinessObjectService().findMatching(OleCopy.class, copyCriteria);
if (copies.size() > 0) {
List<OLEPaidCopy> paidCopies = new ArrayList<OLEPaidCopy>();
for (OleCopy copy : copies) {
OLEPaidCopy paidCopy = new OLEPaidCopy();
paidCopy.setCopyId(copy.getCopyId());
paidCopy.setInvoiceItemId(this.getPurapDocumentIdentifier());
paidCopy.setInvoiceIdentifier(singleItem.getItemIdentifier());
//copy.getOlePaidCopies().add(paidCopy);
paidCopies.add(paidCopy);
}
getBusinessObjectService().save(paidCopies);
singleItem.setPaidCopies(paidCopies);
}
}
}
}
} catch (Exception e) {
LOG.error("Exception during prepareForSave() in OleInvoiceDocument", e);
throw new RuntimeException(e);
}
} | NONSATD | true | paidCopy.setInvoiceItemId(this.getPurapDocumentIdentifier());
paidCopy.setInvoiceIdentifier(singleItem.getItemIdentifier());
//copy.getOlePaidCopies().add(paidCopy);
paidCopies.add(paidCopy);
} | if (singleItem.getPaidCopies().size() <= 0 && singleItem.getPoItemIdentifier() != null && (this.getPurapDocumentIdentifier() != null && singleItem.getItemIdentifier() != null)) {
copyCriteria.put("poItemId", singleItem.getPoItemIdentifier().toString());
List<OleCopy> copies = (List<OleCopy>) getBusinessObjectService().findMatching(OleCopy.class, copyCriteria);
if (copies.size() > 0) {
List<OLEPaidCopy> paidCopies = new ArrayList<OLEPaidCopy>();
for (OleCopy copy : copies) {
OLEPaidCopy paidCopy = new OLEPaidCopy();
paidCopy.setCopyId(copy.getCopyId());
paidCopy.setInvoiceItemId(this.getPurapDocumentIdentifier());
paidCopy.setInvoiceIdentifier(singleItem.getItemIdentifier());
//copy.getOlePaidCopies().add(paidCopy);
paidCopies.add(paidCopy);
}
getBusinessObjectService().save(paidCopies);
singleItem.setPaidCopies(paidCopies);
}
}
}
}
} catch (Exception e) {
LOG.error("Exception during prepareForSave() in OleInvoiceDocument", e); | singleItem.setItemExchangeRate(new KualiDecimal(exchangeRate));
singleItem.setExchangeRate(exchangeRate.toString());
}
this.setVendorInvoiceAmount(this.getForeignVendorInvoiceAmount() != null ?
new KualiDecimal(this.getForeignVendorInvoiceAmount().divide(new BigDecimal(singleItem.getExchangeRate()), 4, RoundingMode.HALF_UP)) : null);
}
}
}
setItemDescription(singleItem);
Map<String, String> copyCriteria = new HashMap<String, String>();
if (singleItem.getPaidCopies().size() <= 0 && singleItem.getPoItemIdentifier() != null && (this.getPurapDocumentIdentifier() != null && singleItem.getItemIdentifier() != null)) {
copyCriteria.put("poItemId", singleItem.getPoItemIdentifier().toString());
List<OleCopy> copies = (List<OleCopy>) getBusinessObjectService().findMatching(OleCopy.class, copyCriteria);
if (copies.size() > 0) {
List<OLEPaidCopy> paidCopies = new ArrayList<OLEPaidCopy>();
for (OleCopy copy : copies) {
OLEPaidCopy paidCopy = new OLEPaidCopy();
paidCopy.setCopyId(copy.getCopyId());
paidCopy.setInvoiceItemId(this.getPurapDocumentIdentifier());
paidCopy.setInvoiceIdentifier(singleItem.getItemIdentifier());
//copy.getOlePaidCopies().add(paidCopy);
paidCopies.add(paidCopy);
}
getBusinessObjectService().save(paidCopies);
singleItem.setPaidCopies(paidCopies);
}
}
}
}
} catch (Exception e) {
LOG.error("Exception during prepareForSave() in OleInvoiceDocument", e);
throw new RuntimeException(e);
}
} |
30,631 | 0 | /**
* Calculates the number of dstinct elements that can be stored in a filter of size
* <code>bytes</code> without exceeding the given false positive probability.
*
* @param bytes the size of the filter
* @param fpp the desired false positive probability
* @return the maximum number of distinct values that can be added
*/ | public static double TotalHashCapacity(double bytes, double fpp) {
double word_bits = 32;
double bucket_words = 8;
double hash_bits = 32;
double result = 1;
// TODO: unify this exponential + binary search with the bytes needed function above
while (Fpp(result, bytes) < fpp) {
result *= 2;
}
if (result == 1) return 0;
double lo = 0;
while (lo + 1 < result) {
double mid = lo + (result - lo) / 2;
double test = Fpp(mid, bytes);
if (test < fpp)
lo = mid;
else if (test == fpp)
return mid;
else
result = mid;
}
return lo;
} | NONSATD | true | public static double TotalHashCapacity(double bytes, double fpp) {
double word_bits = 32;
double bucket_words = 8;
double hash_bits = 32;
double result = 1;
// TODO: unify this exponential + binary search with the bytes needed function above
while (Fpp(result, bytes) < fpp) {
result *= 2;
}
if (result == 1) return 0;
double lo = 0;
while (lo + 1 < result) {
double mid = lo + (result - lo) / 2;
double test = Fpp(mid, bytes);
if (test < fpp)
lo = mid;
else if (test == fpp)
return mid;
else
result = mid;
}
return lo;
} | public static double TotalHashCapacity(double bytes, double fpp) {
double word_bits = 32;
double bucket_words = 8;
double hash_bits = 32;
double result = 1;
// TODO: unify this exponential + binary search with the bytes needed function above
while (Fpp(result, bytes) < fpp) {
result *= 2;
}
if (result == 1) return 0;
double lo = 0;
while (lo + 1 < result) {
double mid = lo + (result - lo) / 2;
double test = Fpp(mid, bytes);
if (test < fpp)
lo = mid;
else if (test == fpp)
return mid;
else
result = mid;
}
return lo;
} | public static double TotalHashCapacity(double bytes, double fpp) {
double word_bits = 32;
double bucket_words = 8;
double hash_bits = 32;
double result = 1;
// TODO: unify this exponential + binary search with the bytes needed function above
while (Fpp(result, bytes) < fpp) {
result *= 2;
}
if (result == 1) return 0;
double lo = 0;
while (lo + 1 < result) {
double mid = lo + (result - lo) / 2;
double test = Fpp(mid, bytes);
if (test < fpp)
lo = mid;
else if (test == fpp)
return mid;
else
result = mid;
}
return lo;
} |
30,631 | 1 | // TODO: unify this exponential + binary search with the bytes needed function above | public static double TotalHashCapacity(double bytes, double fpp) {
double word_bits = 32;
double bucket_words = 8;
double hash_bits = 32;
double result = 1;
// TODO: unify this exponential + binary search with the bytes needed function above
while (Fpp(result, bytes) < fpp) {
result *= 2;
}
if (result == 1) return 0;
double lo = 0;
while (lo + 1 < result) {
double mid = lo + (result - lo) / 2;
double test = Fpp(mid, bytes);
if (test < fpp)
lo = mid;
else if (test == fpp)
return mid;
else
result = mid;
}
return lo;
} | DESIGN | true | double hash_bits = 32;
double result = 1;
// TODO: unify this exponential + binary search with the bytes needed function above
while (Fpp(result, bytes) < fpp) {
result *= 2; | public static double TotalHashCapacity(double bytes, double fpp) {
double word_bits = 32;
double bucket_words = 8;
double hash_bits = 32;
double result = 1;
// TODO: unify this exponential + binary search with the bytes needed function above
while (Fpp(result, bytes) < fpp) {
result *= 2;
}
if (result == 1) return 0;
double lo = 0;
while (lo + 1 < result) {
double mid = lo + (result - lo) / 2;
double test = Fpp(mid, bytes);
if (test < fpp)
lo = mid; | public static double TotalHashCapacity(double bytes, double fpp) {
double word_bits = 32;
double bucket_words = 8;
double hash_bits = 32;
double result = 1;
// TODO: unify this exponential + binary search with the bytes needed function above
while (Fpp(result, bytes) < fpp) {
result *= 2;
}
if (result == 1) return 0;
double lo = 0;
while (lo + 1 < result) {
double mid = lo + (result - lo) / 2;
double test = Fpp(mid, bytes);
if (test < fpp)
lo = mid;
else if (test == fpp)
return mid;
else
result = mid;
}
return lo;
} |
30,633 | 0 | /**
* Implements the Nodejs require.resolve algorithm, see
* https://nodejs.org/api/modules.html#modules_all_together
*
* <p>require(X) from module at path Y 1. If X is a core module, a. return the core module b. STOP
* 2. If X begins with './' or '/' or '../' a. LOAD_AS_FILE(Y + X) b. LOAD_AS_DIRECTORY(Y + X) 3.
* LOAD_NODE_MODULES(X, dirname(Y)) 4. THROW "not found"
*
* @param dir Y in the pseudo algorithm
* @param target X in the pseudo algorithm
*/ | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target));
if (module != null) return module;
module = loadAsDirectory(rootDir, new File(dir, target));
if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} | NONSATD | true | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target));
if (module != null) return module;
module = loadAsDirectory(rootDir, new File(dir, target));
if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target));
if (module != null) return module;
module = loadAsDirectory(rootDir, new File(dir, target));
if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target));
if (module != null) return module;
module = loadAsDirectory(rootDir, new File(dir, target));
if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} |
30,633 | 1 | // NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target); | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target));
if (module != null) return module;
module = loadAsDirectory(rootDir, new File(dir, target));
if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} | DESIGN | true | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target)); | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target));
if (module != null) return module;
module = loadAsDirectory(rootDir, new File(dir, target));
if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target));
if (module != null) return module;
module = loadAsDirectory(rootDir, new File(dir, target));
if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} |
30,633 | 2 | // NOTE(Zhen): it is not very useful to throw exception... | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target));
if (module != null) return module;
module = loadAsDirectory(rootDir, new File(dir, target));
if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} | DESIGN | true | if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target));
if (module != null) return module;
module = loadAsDirectory(rootDir, new File(dir, target));
if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} | public static SourceFileModule resolve(File rootDir, File dir, String target) throws IOException, JSONException {
// NOTE(Zhen): Ignore CoreModule for now to enable a more flexible semantic modeling
// if (NodejsRequiredCoreModule.isCoreModule(target)) return NodejsRequiredCoreModule.make(target);
if (target.startsWith("./") || target.startsWith("/") || target.startsWith("../")) {
SourceFileModule module = loadAsFile(rootDir, new File(dir, target));
if (module != null) return module;
module = loadAsDirectory(rootDir, new File(dir, target));
if (module != null) return module;
}
// NOTE(Zhen): it is not very useful to throw exception...
return loadNodeModules(rootDir, dir, target);
} |
22,463 | 0 | //if (is.available() > 0) { | private String prepareHeadersAndBodyForService(HttpServletRequest request, String method, String url,
List<String> clientRequestHeaders, Interactor.Interaction interaction,
String clientRequestContentType,
InteractionManipulations interactionManipulations) throws IOException {
Enumeration<String> hdrs = request.getHeaderNames();
ServletInputStream is = request.getInputStream();
Object clientRequestBody = null;
//if (is.available() > 0) {
if (isText(clientRequestContentType)) {
clientRequestBody = null;
String characterEncoding = request.getCharacterEncoding();
if (characterEncoding == null) {
characterEncoding = "utf-8";
}
try (Scanner scanner = new Scanner(is, characterEncoding)) {
if(scanner.hasNext()) {
clientRequestBody = scanner.useDelimiter("\\A").next();
}
}
if (shouldHavePrettyPrintedTextBodies() && clientRequestBody != null) {
clientRequestBody = prettifyDocOrNot((String) clientRequestBody);
}
} else if(is.available() > 0){
byte[] targetArray = new byte[is.available()];
is.read(targetArray);
clientRequestBody = targetArray;
}
//}
while (hdrs.hasMoreElements()) {
// TODO - make this cater for multiple lines with the same name
String hdrName = hdrs.nextElement();
String hdrVal = request.getHeader(hdrName);
hdrVal = interactionManipulations.headerReplacement(hdrName, hdrVal);
final String fullHeader = (getLowerCaseHeaders() ? hdrName.toLowerCase() : hdrName) + ": " + hdrVal;
clientRequestHeaders.add(fullHeader);
interactionManipulations.changeSingleHeaderForRequestToService(method, fullHeader, clientRequestHeaders);
}
interactionManipulations.changeAnyHeadersForRequestToService(clientRequestHeaders);
if (clientRequestBody instanceof String) {
clientRequestBody = interactionManipulations.changeBodyForRequestToService((String) clientRequestBody);
}
if (clientRequestBody == null) {
clientRequestBody = "";
}
interaction.noteClientRequestHeadersAndBody(clientRequestHeaders, clientRequestBody, clientRequestContentType);
return interactionManipulations.changeUrlForRequestToService(url);
} | NONSATD | true | ServletInputStream is = request.getInputStream();
Object clientRequestBody = null;
//if (is.available() > 0) {
if (isText(clientRequestContentType)) {
clientRequestBody = null; | private String prepareHeadersAndBodyForService(HttpServletRequest request, String method, String url,
List<String> clientRequestHeaders, Interactor.Interaction interaction,
String clientRequestContentType,
InteractionManipulations interactionManipulations) throws IOException {
Enumeration<String> hdrs = request.getHeaderNames();
ServletInputStream is = request.getInputStream();
Object clientRequestBody = null;
//if (is.available() > 0) {
if (isText(clientRequestContentType)) {
clientRequestBody = null;
String characterEncoding = request.getCharacterEncoding();
if (characterEncoding == null) {
characterEncoding = "utf-8";
}
try (Scanner scanner = new Scanner(is, characterEncoding)) {
if(scanner.hasNext()) {
clientRequestBody = scanner.useDelimiter("\\A").next();
} | private String prepareHeadersAndBodyForService(HttpServletRequest request, String method, String url,
List<String> clientRequestHeaders, Interactor.Interaction interaction,
String clientRequestContentType,
InteractionManipulations interactionManipulations) throws IOException {
Enumeration<String> hdrs = request.getHeaderNames();
ServletInputStream is = request.getInputStream();
Object clientRequestBody = null;
//if (is.available() > 0) {
if (isText(clientRequestContentType)) {
clientRequestBody = null;
String characterEncoding = request.getCharacterEncoding();
if (characterEncoding == null) {
characterEncoding = "utf-8";
}
try (Scanner scanner = new Scanner(is, characterEncoding)) {
if(scanner.hasNext()) {
clientRequestBody = scanner.useDelimiter("\\A").next();
}
}
if (shouldHavePrettyPrintedTextBodies() && clientRequestBody != null) {
clientRequestBody = prettifyDocOrNot((String) clientRequestBody);
}
} else if(is.available() > 0){
byte[] targetArray = new byte[is.available()];
is.read(targetArray);
clientRequestBody = targetArray;
}
//} |
22,463 | 1 | //} | private String prepareHeadersAndBodyForService(HttpServletRequest request, String method, String url,
List<String> clientRequestHeaders, Interactor.Interaction interaction,
String clientRequestContentType,
InteractionManipulations interactionManipulations) throws IOException {
Enumeration<String> hdrs = request.getHeaderNames();
ServletInputStream is = request.getInputStream();
Object clientRequestBody = null;
//if (is.available() > 0) {
if (isText(clientRequestContentType)) {
clientRequestBody = null;
String characterEncoding = request.getCharacterEncoding();
if (characterEncoding == null) {
characterEncoding = "utf-8";
}
try (Scanner scanner = new Scanner(is, characterEncoding)) {
if(scanner.hasNext()) {
clientRequestBody = scanner.useDelimiter("\\A").next();
}
}
if (shouldHavePrettyPrintedTextBodies() && clientRequestBody != null) {
clientRequestBody = prettifyDocOrNot((String) clientRequestBody);
}
} else if(is.available() > 0){
byte[] targetArray = new byte[is.available()];
is.read(targetArray);
clientRequestBody = targetArray;
}
//}
while (hdrs.hasMoreElements()) {
// TODO - make this cater for multiple lines with the same name
String hdrName = hdrs.nextElement();
String hdrVal = request.getHeader(hdrName);
hdrVal = interactionManipulations.headerReplacement(hdrName, hdrVal);
final String fullHeader = (getLowerCaseHeaders() ? hdrName.toLowerCase() : hdrName) + ": " + hdrVal;
clientRequestHeaders.add(fullHeader);
interactionManipulations.changeSingleHeaderForRequestToService(method, fullHeader, clientRequestHeaders);
}
interactionManipulations.changeAnyHeadersForRequestToService(clientRequestHeaders);
if (clientRequestBody instanceof String) {
clientRequestBody = interactionManipulations.changeBodyForRequestToService((String) clientRequestBody);
}
if (clientRequestBody == null) {
clientRequestBody = "";
}
interaction.noteClientRequestHeadersAndBody(clientRequestHeaders, clientRequestBody, clientRequestContentType);
return interactionManipulations.changeUrlForRequestToService(url);
} | NONSATD | true | clientRequestBody = targetArray;
}
//}
while (hdrs.hasMoreElements()) {
// TODO - make this cater for multiple lines with the same name | }
}
if (shouldHavePrettyPrintedTextBodies() && clientRequestBody != null) {
clientRequestBody = prettifyDocOrNot((String) clientRequestBody);
}
} else if(is.available() > 0){
byte[] targetArray = new byte[is.available()];
is.read(targetArray);
clientRequestBody = targetArray;
}
//}
while (hdrs.hasMoreElements()) {
// TODO - make this cater for multiple lines with the same name
String hdrName = hdrs.nextElement();
String hdrVal = request.getHeader(hdrName);
hdrVal = interactionManipulations.headerReplacement(hdrName, hdrVal);
final String fullHeader = (getLowerCaseHeaders() ? hdrName.toLowerCase() : hdrName) + ": " + hdrVal;
clientRequestHeaders.add(fullHeader);
interactionManipulations.changeSingleHeaderForRequestToService(method, fullHeader, clientRequestHeaders);
}
interactionManipulations.changeAnyHeadersForRequestToService(clientRequestHeaders); | //if (is.available() > 0) {
if (isText(clientRequestContentType)) {
clientRequestBody = null;
String characterEncoding = request.getCharacterEncoding();
if (characterEncoding == null) {
characterEncoding = "utf-8";
}
try (Scanner scanner = new Scanner(is, characterEncoding)) {
if(scanner.hasNext()) {
clientRequestBody = scanner.useDelimiter("\\A").next();
}
}
if (shouldHavePrettyPrintedTextBodies() && clientRequestBody != null) {
clientRequestBody = prettifyDocOrNot((String) clientRequestBody);
}
} else if(is.available() > 0){
byte[] targetArray = new byte[is.available()];
is.read(targetArray);
clientRequestBody = targetArray;
}
//}
while (hdrs.hasMoreElements()) {
// TODO - make this cater for multiple lines with the same name
String hdrName = hdrs.nextElement();
String hdrVal = request.getHeader(hdrName);
hdrVal = interactionManipulations.headerReplacement(hdrName, hdrVal);
final String fullHeader = (getLowerCaseHeaders() ? hdrName.toLowerCase() : hdrName) + ": " + hdrVal;
clientRequestHeaders.add(fullHeader);
interactionManipulations.changeSingleHeaderForRequestToService(method, fullHeader, clientRequestHeaders);
}
interactionManipulations.changeAnyHeadersForRequestToService(clientRequestHeaders);
if (clientRequestBody instanceof String) {
clientRequestBody = interactionManipulations.changeBodyForRequestToService((String) clientRequestBody);
}
if (clientRequestBody == null) {
clientRequestBody = "";
}
interaction.noteClientRequestHeadersAndBody(clientRequestHeaders, clientRequestBody, clientRequestContentType);
return interactionManipulations.changeUrlForRequestToService(url);
} |
22,463 | 2 | // TODO - make this cater for multiple lines with the same name | private String prepareHeadersAndBodyForService(HttpServletRequest request, String method, String url,
List<String> clientRequestHeaders, Interactor.Interaction interaction,
String clientRequestContentType,
InteractionManipulations interactionManipulations) throws IOException {
Enumeration<String> hdrs = request.getHeaderNames();
ServletInputStream is = request.getInputStream();
Object clientRequestBody = null;
//if (is.available() > 0) {
if (isText(clientRequestContentType)) {
clientRequestBody = null;
String characterEncoding = request.getCharacterEncoding();
if (characterEncoding == null) {
characterEncoding = "utf-8";
}
try (Scanner scanner = new Scanner(is, characterEncoding)) {
if(scanner.hasNext()) {
clientRequestBody = scanner.useDelimiter("\\A").next();
}
}
if (shouldHavePrettyPrintedTextBodies() && clientRequestBody != null) {
clientRequestBody = prettifyDocOrNot((String) clientRequestBody);
}
} else if(is.available() > 0){
byte[] targetArray = new byte[is.available()];
is.read(targetArray);
clientRequestBody = targetArray;
}
//}
while (hdrs.hasMoreElements()) {
// TODO - make this cater for multiple lines with the same name
String hdrName = hdrs.nextElement();
String hdrVal = request.getHeader(hdrName);
hdrVal = interactionManipulations.headerReplacement(hdrName, hdrVal);
final String fullHeader = (getLowerCaseHeaders() ? hdrName.toLowerCase() : hdrName) + ": " + hdrVal;
clientRequestHeaders.add(fullHeader);
interactionManipulations.changeSingleHeaderForRequestToService(method, fullHeader, clientRequestHeaders);
}
interactionManipulations.changeAnyHeadersForRequestToService(clientRequestHeaders);
if (clientRequestBody instanceof String) {
clientRequestBody = interactionManipulations.changeBodyForRequestToService((String) clientRequestBody);
}
if (clientRequestBody == null) {
clientRequestBody = "";
}
interaction.noteClientRequestHeadersAndBody(clientRequestHeaders, clientRequestBody, clientRequestContentType);
return interactionManipulations.changeUrlForRequestToService(url);
} | DESIGN | true | //}
while (hdrs.hasMoreElements()) {
// TODO - make this cater for multiple lines with the same name
String hdrName = hdrs.nextElement();
String hdrVal = request.getHeader(hdrName); | if (shouldHavePrettyPrintedTextBodies() && clientRequestBody != null) {
clientRequestBody = prettifyDocOrNot((String) clientRequestBody);
}
} else if(is.available() > 0){
byte[] targetArray = new byte[is.available()];
is.read(targetArray);
clientRequestBody = targetArray;
}
//}
while (hdrs.hasMoreElements()) {
// TODO - make this cater for multiple lines with the same name
String hdrName = hdrs.nextElement();
String hdrVal = request.getHeader(hdrName);
hdrVal = interactionManipulations.headerReplacement(hdrName, hdrVal);
final String fullHeader = (getLowerCaseHeaders() ? hdrName.toLowerCase() : hdrName) + ": " + hdrVal;
clientRequestHeaders.add(fullHeader);
interactionManipulations.changeSingleHeaderForRequestToService(method, fullHeader, clientRequestHeaders);
}
interactionManipulations.changeAnyHeadersForRequestToService(clientRequestHeaders);
if (clientRequestBody instanceof String) {
clientRequestBody = interactionManipulations.changeBodyForRequestToService((String) clientRequestBody); | clientRequestBody = null;
String characterEncoding = request.getCharacterEncoding();
if (characterEncoding == null) {
characterEncoding = "utf-8";
}
try (Scanner scanner = new Scanner(is, characterEncoding)) {
if(scanner.hasNext()) {
clientRequestBody = scanner.useDelimiter("\\A").next();
}
}
if (shouldHavePrettyPrintedTextBodies() && clientRequestBody != null) {
clientRequestBody = prettifyDocOrNot((String) clientRequestBody);
}
} else if(is.available() > 0){
byte[] targetArray = new byte[is.available()];
is.read(targetArray);
clientRequestBody = targetArray;
}
//}
while (hdrs.hasMoreElements()) {
// TODO - make this cater for multiple lines with the same name
String hdrName = hdrs.nextElement();
String hdrVal = request.getHeader(hdrName);
hdrVal = interactionManipulations.headerReplacement(hdrName, hdrVal);
final String fullHeader = (getLowerCaseHeaders() ? hdrName.toLowerCase() : hdrName) + ": " + hdrVal;
clientRequestHeaders.add(fullHeader);
interactionManipulations.changeSingleHeaderForRequestToService(method, fullHeader, clientRequestHeaders);
}
interactionManipulations.changeAnyHeadersForRequestToService(clientRequestHeaders);
if (clientRequestBody instanceof String) {
clientRequestBody = interactionManipulations.changeBodyForRequestToService((String) clientRequestBody);
}
if (clientRequestBody == null) {
clientRequestBody = "";
}
interaction.noteClientRequestHeadersAndBody(clientRequestHeaders, clientRequestBody, clientRequestContentType);
return interactionManipulations.changeUrlForRequestToService(url);
} |
14,274 | 0 | /*
* // NOTE: this is wrong ? Even though the ibis has left, the
* IbisIdentifier may still be floating around in the system... We should
* just have some timeout on the cache entries instead...
*
* public void left(ibis.ipl.IbisIdentifier id) { super.left(id);
* synchronized(addresses) { addresses.remove(id); } }
*
* public void died(ibis.ipl.IbisIdentifier id) { super.died(id);
* synchronized(addresses) { addresses.remove(id); } }
*/ | IbisSocket connect(TcpSendPort sp, ibis.ipl.impl.ReceivePortIdentifier rip,
int timeout, boolean fillTimeout) throws IOException {
IbisIdentifier id = (IbisIdentifier) rip.ibisIdentifier();
String name = rip.name();
IbisSocketAddress idAddr;
synchronized (addresses) {
idAddr = addresses.get(id);
if (idAddr == null) {
idAddr = new IbisSocketAddress(id.getImplementationData());
addresses.put(id, idAddr);
}
}
long startTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("--> Creating socket for connection to " + name
+ " at " + idAddr);
}
PortType sendPortType = sp.getPortType();
do {
DataOutputStream out = null;
IbisSocket s = null;
int result = -1;
sp.printManagementProperties(System.out);
try {
s = factory.createClientSocket(idAddr, timeout, fillTimeout,
sp.managementProperties());
s.setTcpNoDelay(true);
out = new DataOutputStream(new BufferedArrayOutputStream(
s.getOutputStream()));
out.writeUTF(name);
sp.getIdent().writeTo(out);
sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} | DEFECT | true | IbisSocket connect(TcpSendPort sp, ibis.ipl.impl.ReceivePortIdentifier rip,
int timeout, boolean fillTimeout) throws IOException {
IbisIdentifier id = (IbisIdentifier) rip.ibisIdentifier();
String name = rip.name();
IbisSocketAddress idAddr;
synchronized (addresses) {
idAddr = addresses.get(id);
if (idAddr == null) {
idAddr = new IbisSocketAddress(id.getImplementationData());
addresses.put(id, idAddr);
}
}
long startTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("--> Creating socket for connection to " + name
+ " at " + idAddr);
}
PortType sendPortType = sp.getPortType();
do {
DataOutputStream out = null;
IbisSocket s = null;
int result = -1;
sp.printManagementProperties(System.out);
try {
s = factory.createClientSocket(idAddr, timeout, fillTimeout,
sp.managementProperties());
s.setTcpNoDelay(true);
out = new DataOutputStream(new BufferedArrayOutputStream(
s.getOutputStream()));
out.writeUTF(name);
sp.getIdent().writeTo(out);
sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} | IbisSocket connect(TcpSendPort sp, ibis.ipl.impl.ReceivePortIdentifier rip,
int timeout, boolean fillTimeout) throws IOException {
IbisIdentifier id = (IbisIdentifier) rip.ibisIdentifier();
String name = rip.name();
IbisSocketAddress idAddr;
synchronized (addresses) {
idAddr = addresses.get(id);
if (idAddr == null) {
idAddr = new IbisSocketAddress(id.getImplementationData());
addresses.put(id, idAddr);
}
}
long startTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("--> Creating socket for connection to " + name
+ " at " + idAddr);
}
PortType sendPortType = sp.getPortType();
do {
DataOutputStream out = null;
IbisSocket s = null;
int result = -1;
sp.printManagementProperties(System.out);
try {
s = factory.createClientSocket(idAddr, timeout, fillTimeout,
sp.managementProperties());
s.setTcpNoDelay(true);
out = new DataOutputStream(new BufferedArrayOutputStream(
s.getOutputStream()));
out.writeUTF(name);
sp.getIdent().writeTo(out);
sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} | IbisSocket connect(TcpSendPort sp, ibis.ipl.impl.ReceivePortIdentifier rip,
int timeout, boolean fillTimeout) throws IOException {
IbisIdentifier id = (IbisIdentifier) rip.ibisIdentifier();
String name = rip.name();
IbisSocketAddress idAddr;
synchronized (addresses) {
idAddr = addresses.get(id);
if (idAddr == null) {
idAddr = new IbisSocketAddress(id.getImplementationData());
addresses.put(id, idAddr);
}
}
long startTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("--> Creating socket for connection to " + name
+ " at " + idAddr);
}
PortType sendPortType = sp.getPortType();
do {
DataOutputStream out = null;
IbisSocket s = null;
int result = -1;
sp.printManagementProperties(System.out);
try {
s = factory.createClientSocket(idAddr, timeout, fillTimeout,
sp.managementProperties());
s.setTcpNoDelay(true);
out = new DataOutputStream(new BufferedArrayOutputStream(
s.getOutputStream()));
out.writeUTF(name);
sp.getIdent().writeTo(out);
sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} |
14,274 | 1 | // Read receiveport type from input, to produce a
// better error message. | IbisSocket connect(TcpSendPort sp, ibis.ipl.impl.ReceivePortIdentifier rip,
int timeout, boolean fillTimeout) throws IOException {
IbisIdentifier id = (IbisIdentifier) rip.ibisIdentifier();
String name = rip.name();
IbisSocketAddress idAddr;
synchronized (addresses) {
idAddr = addresses.get(id);
if (idAddr == null) {
idAddr = new IbisSocketAddress(id.getImplementationData());
addresses.put(id, idAddr);
}
}
long startTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("--> Creating socket for connection to " + name
+ " at " + idAddr);
}
PortType sendPortType = sp.getPortType();
do {
DataOutputStream out = null;
IbisSocket s = null;
int result = -1;
sp.printManagementProperties(System.out);
try {
s = factory.createClientSocket(idAddr, timeout, fillTimeout,
sp.managementProperties());
s.setTcpNoDelay(true);
out = new DataOutputStream(new BufferedArrayOutputStream(
s.getOutputStream()));
out.writeUTF(name);
sp.getIdent().writeTo(out);
sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} | NONSATD | true | rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in); | sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
} | int result = -1;
sp.printManagementProperties(System.out);
try {
s = factory.createClientSocket(idAddr, timeout, fillTimeout,
sp.managementProperties());
s.setTcpNoDelay(true);
out = new DataOutputStream(new BufferedArrayOutputStream(
s.getOutputStream()));
out.writeUTF(name);
sp.getIdent().writeTo(out);
sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException( |
14,274 | 2 | // and try again if we did not reach the timeout... | IbisSocket connect(TcpSendPort sp, ibis.ipl.impl.ReceivePortIdentifier rip,
int timeout, boolean fillTimeout) throws IOException {
IbisIdentifier id = (IbisIdentifier) rip.ibisIdentifier();
String name = rip.name();
IbisSocketAddress idAddr;
synchronized (addresses) {
idAddr = addresses.get(id);
if (idAddr == null) {
idAddr = new IbisSocketAddress(id.getImplementationData());
addresses.put(id, idAddr);
}
}
long startTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("--> Creating socket for connection to " + name
+ " at " + idAddr);
}
PortType sendPortType = sp.getPortType();
do {
DataOutputStream out = null;
IbisSocket s = null;
int result = -1;
sp.printManagementProperties(System.out);
try {
s = factory.createClientSocket(idAddr, timeout, fillTimeout,
sp.managementProperties());
s.setTcpNoDelay(true);
out = new DataOutputStream(new BufferedArrayOutputStream(
s.getOutputStream()));
out.writeUTF(name);
sp.getIdent().writeTo(out);
sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} | NONSATD | true | case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) { | + message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect"); | + "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) { |
14,274 | 3 | // ignored | IbisSocket connect(TcpSendPort sp, ibis.ipl.impl.ReceivePortIdentifier rip,
int timeout, boolean fillTimeout) throws IOException {
IbisIdentifier id = (IbisIdentifier) rip.ibisIdentifier();
String name = rip.name();
IbisSocketAddress idAddr;
synchronized (addresses) {
idAddr = addresses.get(id);
if (idAddr == null) {
idAddr = new IbisSocketAddress(id.getImplementationData());
addresses.put(id, idAddr);
}
}
long startTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("--> Creating socket for connection to " + name
+ " at " + idAddr);
}
PortType sendPortType = sp.getPortType();
do {
DataOutputStream out = null;
IbisSocket s = null;
int result = -1;
sp.printManagementProperties(System.out);
try {
s = factory.createClientSocket(idAddr, timeout, fillTimeout,
sp.managementProperties());
s.setTcpNoDelay(true);
out = new DataOutputStream(new BufferedArrayOutputStream(
s.getOutputStream()));
out.writeUTF(name);
sp.getIdent().writeTo(out);
sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} | NONSATD | true | }
} catch (Throwable e) {
// ignored
}
try { | }
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100); | if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} |
14,274 | 4 | // ignored | IbisSocket connect(TcpSendPort sp, ibis.ipl.impl.ReceivePortIdentifier rip,
int timeout, boolean fillTimeout) throws IOException {
IbisIdentifier id = (IbisIdentifier) rip.ibisIdentifier();
String name = rip.name();
IbisSocketAddress idAddr;
synchronized (addresses) {
idAddr = addresses.get(id);
if (idAddr == null) {
idAddr = new IbisSocketAddress(id.getImplementationData());
addresses.put(id, idAddr);
}
}
long startTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("--> Creating socket for connection to " + name
+ " at " + idAddr);
}
PortType sendPortType = sp.getPortType();
do {
DataOutputStream out = null;
IbisSocket s = null;
int result = -1;
sp.printManagementProperties(System.out);
try {
s = factory.createClientSocket(idAddr, timeout, fillTimeout,
sp.managementProperties());
s.setTcpNoDelay(true);
out = new DataOutputStream(new BufferedArrayOutputStream(
s.getOutputStream()));
out.writeUTF(name);
sp.getIdent().writeTo(out);
sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} | NONSATD | true | }
} catch (Throwable e) {
// ignored
}
try { | }
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100); | if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} |
14,274 | 5 | // ignore | IbisSocket connect(TcpSendPort sp, ibis.ipl.impl.ReceivePortIdentifier rip,
int timeout, boolean fillTimeout) throws IOException {
IbisIdentifier id = (IbisIdentifier) rip.ibisIdentifier();
String name = rip.name();
IbisSocketAddress idAddr;
synchronized (addresses) {
idAddr = addresses.get(id);
if (idAddr == null) {
idAddr = new IbisSocketAddress(id.getImplementationData());
addresses.put(id, idAddr);
}
}
long startTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("--> Creating socket for connection to " + name
+ " at " + idAddr);
}
PortType sendPortType = sp.getPortType();
do {
DataOutputStream out = null;
IbisSocket s = null;
int result = -1;
sp.printManagementProperties(System.out);
try {
s = factory.createClientSocket(idAddr, timeout, fillTimeout,
sp.managementProperties());
s.setTcpNoDelay(true);
out = new DataOutputStream(new BufferedArrayOutputStream(
s.getOutputStream()));
out.writeUTF(name);
sp.getIdent().writeTo(out);
sendPortType.writeTo(out);
out.flush();
result = s.getInputStream().read();
switch (result) {
case ReceivePort.ACCEPTED:
return s;
case ReceivePort.ALREADY_CONNECTED:
throw new AlreadyConnectedException("Already connected",
rip);
case ReceivePort.TYPE_MISMATCH:
// Read receiveport type from input, to produce a
// better error message.
DataInputStream in = new DataInputStream(s.getInputStream());
PortType rtp = new PortType(in);
CapabilitySet s1 = rtp.unmatchedCapabilities(sendPortType);
CapabilitySet s2 = sendPortType.unmatchedCapabilities(rtp);
String message = "";
if (s1.size() != 0) {
message = message
+ "\nUnmatched receiveport capabilities: "
+ s1.toString() + ".";
}
if (s2.size() != 0) {
message = message
+ "\nUnmatched sendport capabilities: "
+ s2.toString() + ".";
}
throw new PortMismatchException(
"Cannot connect ports of different port types."
+ message, rip);
case ReceivePort.DENIED:
throw new ConnectionRefusedException(
"Receiver denied connection", rip);
case ReceivePort.NO_MANY_TO_X:
throw new ConnectionRefusedException(
"Receiver already has a connection and neither ManyToOne not ManyToMany "
+ "is set", rip);
case ReceivePort.NOT_PRESENT:
case ReceivePort.DISABLED:
// and try again if we did not reach the timeout...
if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} | NONSATD | true | }
} catch (Throwable e) {
// ignored
}
try { | }
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100); | if (timeout > 0
&& System.currentTimeMillis() > startTime + timeout) {
throw new ConnectionTimedOutException(
"Could not connect", rip);
}
break;
case -1:
throw new IOException("Encountered EOF in TcpIbis.connect");
default:
throw new IOException("Illegal opcode in TcpIbis.connect");
}
} catch (SocketTimeoutException e) {
throw new ConnectionTimedOutException("Could not connect", rip);
} finally {
if (result != ReceivePort.ACCEPTED) {
try {
if (out != null) {
out.close();
}
} catch (Throwable e) {
// ignored
}
try {
s.close();
} catch (Throwable e) {
// ignored
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
} while (true);
} |
14,278 | 0 | /**
* Do all of the "Welcome to the wonderful world of jsqsh activities"
*/ | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/
if (lastModified < 1392411017075L) {
return;
}
}
HelpTopic welcome = helpManager.getTopic("welcome");
System.out.println(welcome.getHelp());
session.out.println();
session.out.println("You will now enter the jsqsh setup wizard.");
try {
getConsole().readline("Hit enter to continue: ", false);
Command command = session.getCommandManager().getCommand("\\setup");
command.execute(session, new String [] { });
}
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
}
} | NONSATD | true | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/
if (lastModified < 1392411017075L) {
return;
}
}
HelpTopic welcome = helpManager.getTopic("welcome");
System.out.println(welcome.getHelp());
session.out.println();
session.out.println("You will now enter the jsqsh setup wizard.");
try {
getConsole().readline("Hit enter to continue: ", false);
Command command = session.getCommandManager().getCommand("\\setup");
command.execute(session, new String [] { });
}
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
}
} | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/
if (lastModified < 1392411017075L) {
return;
}
}
HelpTopic welcome = helpManager.getTopic("welcome");
System.out.println(welcome.getHelp());
session.out.println();
session.out.println("You will now enter the jsqsh setup wizard.");
try {
getConsole().readline("Hit enter to continue: ", false);
Command command = session.getCommandManager().getCommand("\\setup");
command.execute(session, new String [] { });
}
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
}
} | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/
if (lastModified < 1392411017075L) {
return;
}
}
HelpTopic welcome = helpManager.getTopic("welcome");
System.out.println(welcome.getHelp());
session.out.println();
session.out.println("You will now enter the jsqsh setup wizard.");
try {
getConsole().readline("Hit enter to continue: ", false);
Command command = session.getCommandManager().getCommand("\\setup");
command.execute(session, new String [] { });
}
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
}
} |
14,278 | 1 | /*
* Create the welcome file since we are going to welcome them!
*/ | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/
if (lastModified < 1392411017075L) {
return;
}
}
HelpTopic welcome = helpManager.getTopic("welcome");
System.out.println(welcome.getHelp());
session.out.println();
session.out.println("You will now enter the jsqsh setup wizard.");
try {
getConsole().readline("Hit enter to continue: ", false);
Command command = session.getCommandManager().getCommand("\\setup");
command.execute(session, new String [] { });
}
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
}
} | NONSATD | true | return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile(); | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/* |
14,278 | 2 | /*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/ | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/
if (lastModified < 1392411017075L) {
return;
}
}
HelpTopic welcome = helpManager.getTopic("welcome");
System.out.println(welcome.getHelp());
session.out.println();
session.out.println("You will now enter the jsqsh setup wizard.");
try {
getConsole().readline("Hit enter to continue: ", false);
Command command = session.getCommandManager().getCommand("\\setup");
command.execute(session, new String [] { });
}
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
}
} | NONSATD | true | return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage()); | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities. | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/
if (lastModified < 1392411017075L) { |
14,278 | 3 | /*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/ | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/
if (lastModified < 1392411017075L) {
return;
}
}
HelpTopic welcome = helpManager.getTopic("welcome");
System.out.println(welcome.getHelp());
session.out.println();
session.out.println("You will now enter the jsqsh setup wizard.");
try {
getConsole().readline("Hit enter to continue: ", false);
Command command = session.getCommandManager().getCommand("\\setup");
command.execute(session, new String [] { });
}
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
}
} | NONSATD | true | return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
} | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment), |
14,278 | 4 | /* NOT SURE WHAT TO DO HERE */ | private void doWelcome(Session session) {
if (! session.isInteractive()) {
return;
}
File confDir = getConfigDirectory();
File welcomeFile = new File(confDir, ".welcome");
if (welcomeFile.exists()) {
return;
}
/*
* Create the welcome file since we are going to welcome them!
*/
try {
welcomeFile.createNewFile();
}
catch (IOException e) {
System.err.println("WARNING: Failed to create " + welcomeFile
+ ": " + e.getMessage());
return;
}
/*
* Here's a hack. The ".welcome" file is a recent change to jsqsh, and
* we don't want to do the whole welcome thing if an existing jsqsh user
* already has a ~/.jsqsh but doesn't have a .welcome file in it. To avoid
* this, check to see if drivers.xml is older than the date at which this
* comment was written and don't do the setup activities.
*/
File driversFile = new File(confDir, "drivers.xml");
if (driversFile.exists())
{
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/
if (lastModified < 1392411017075L) {
return;
}
}
HelpTopic welcome = helpManager.getTopic("welcome");
System.out.println(welcome.getHelp());
session.out.println();
session.out.println("You will now enter the jsqsh setup wizard.");
try {
getConsole().readline("Hit enter to continue: ", false);
Command command = session.getCommandManager().getCommand("\\setup");
command.execute(session, new String [] { });
}
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
}
} | DESIGN | true | }
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
} | HelpTopic welcome = helpManager.getTopic("welcome");
System.out.println(welcome.getHelp());
session.out.println();
session.out.println("You will now enter the jsqsh setup wizard.");
try {
getConsole().readline("Hit enter to continue: ", false);
Command command = session.getCommandManager().getCommand("\\setup");
command.execute(session, new String [] { });
}
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
}
} | {
long lastModified = driversFile.lastModified();
/*
* Directory was created prior to "now" (when I am typing this comment),
* so pretend the welcome was done
*/
if (lastModified < 1392411017075L) {
return;
}
}
HelpTopic welcome = helpManager.getTopic("welcome");
System.out.println(welcome.getHelp());
session.out.println();
session.out.println("You will now enter the jsqsh setup wizard.");
try {
getConsole().readline("Hit enter to continue: ", false);
Command command = session.getCommandManager().getCommand("\\setup");
command.execute(session, new String [] { });
}
catch (Exception e) {
/* NOT SURE WHAT TO DO HERE */
e.printStackTrace();
}
} |
22,471 | 0 | //FIXME: Create an item or a collection containing the special characters before searching for them | @Test
public void inexistentItemTest() {
String searchQuery = "awobsafhtui5we5t57zuo77izufh";
SearchResultsPage searchQueryPage = startPage.getSearchComponent().searchFor(searchQuery);
String searchQueryDisplayText = searchQueryPage.getItemSearchQuery();
Assert.assertEquals(searchQueryDisplayText, searchQuery);
int numResults = searchQueryPage.getResultCount();
Assert.assertEquals(numResults, 0, "Non-matching results were displayed.");
} | IMPLEMENTATION | true | @Test
public void inexistentItemTest() {
String searchQuery = "awobsafhtui5we5t57zuo77izufh";
SearchResultsPage searchQueryPage = startPage.getSearchComponent().searchFor(searchQuery);
String searchQueryDisplayText = searchQueryPage.getItemSearchQuery();
Assert.assertEquals(searchQueryDisplayText, searchQuery);
int numResults = searchQueryPage.getResultCount();
Assert.assertEquals(numResults, 0, "Non-matching results were displayed.");
} | @Test
public void inexistentItemTest() {
String searchQuery = "awobsafhtui5we5t57zuo77izufh";
SearchResultsPage searchQueryPage = startPage.getSearchComponent().searchFor(searchQuery);
String searchQueryDisplayText = searchQueryPage.getItemSearchQuery();
Assert.assertEquals(searchQueryDisplayText, searchQuery);
int numResults = searchQueryPage.getResultCount();
Assert.assertEquals(numResults, 0, "Non-matching results were displayed.");
} | @Test
public void inexistentItemTest() {
String searchQuery = "awobsafhtui5we5t57zuo77izufh";
SearchResultsPage searchQueryPage = startPage.getSearchComponent().searchFor(searchQuery);
String searchQueryDisplayText = searchQueryPage.getItemSearchQuery();
Assert.assertEquals(searchQueryDisplayText, searchQuery);
int numResults = searchQueryPage.getResultCount();
Assert.assertEquals(numResults, 0, "Non-matching results were displayed.");
} |
22,476 | 0 | // TODO: i18n: Externalize.
// TODO: Enhance: Print link to updated shop. | @AllowedMethod
@Transactional(TransactionType.WRITE)
public String update()
{
log.debug("---------------- update()");
saveOrUpdate();
// TODO: i18n: Externalize.
// TODO: Enhance: Print link to updated shop.
addActionMessage("Shop <strong>" + escape(shop.getName()) + "</strong> updated successfully.");
return RESULT_REDIRECT_VIEW;
} | IMPLEMENTATION | true | log.debug("---------------- update()");
saveOrUpdate();
// TODO: i18n: Externalize.
// TODO: Enhance: Print link to updated shop.
addActionMessage("Shop <strong>" + escape(shop.getName()) + "</strong> updated successfully.");
return RESULT_REDIRECT_VIEW; | @AllowedMethod
@Transactional(TransactionType.WRITE)
public String update()
{
log.debug("---------------- update()");
saveOrUpdate();
// TODO: i18n: Externalize.
// TODO: Enhance: Print link to updated shop.
addActionMessage("Shop <strong>" + escape(shop.getName()) + "</strong> updated successfully.");
return RESULT_REDIRECT_VIEW;
} | @AllowedMethod
@Transactional(TransactionType.WRITE)
public String update()
{
log.debug("---------------- update()");
saveOrUpdate();
// TODO: i18n: Externalize.
// TODO: Enhance: Print link to updated shop.
addActionMessage("Shop <strong>" + escape(shop.getName()) + "</strong> updated successfully.");
return RESULT_REDIRECT_VIEW;
} |
30,694 | 0 | // TODO: do not use until it is able to choose the best cardinality | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} | DESIGN | true | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} |
30,694 | 1 | // Seleccionamos el directorio en el que se van a recoger todos los | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} | NONSATD | true | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff")); | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------"); | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName()); |
30,694 | 2 | //Create the DiscreteDataSet | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} | NONSATD | true | try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------"); | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm); | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} |
30,694 | 3 | // Learn the LTM | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} | NONSATD | true | System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format | String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
} | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} |
30,694 | 4 | // Save it in BIF format | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} | NONSATD | true | // Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm); | try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} | public static void learnAndSaveAllModels(){
// Seleccionamos el directorio en el que se van a recoger todos los
String input_path = "data/automatic_learn/";
File[] inputFiles = new File(input_path).listFiles(x -> x.getName().endsWith(".arff"));
String output_path = "results/automatic_learn/LCM/";
for (File inputFile : inputFiles) {
try {
if (inputFile.isFile()) {
//Create the DiscreteDataSet
DiscreteDataSet data = new DiscreteDataSet(DataFileLoader.loadData(input_path + inputFile.getName(), DiscreteVariable.class));
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("------------------------------------------------------------------------------");
System.out.println("############## "+ data.getName() + " ############## \n");
// Learn the LTM
LTM ltm = learnBestLCMVaryingCardinality(data);
// Save it in BIF format
newBifWriter writer = new newBifWriter(new FileOutputStream(output_path + "LCM_" + FilenameUtils.removeExtension(inputFile.getName()) + ".bif"), false);
writer.write(ltm);
}
}catch(Exception e){
System.out.println("Error with " + inputFile.getName());
e.printStackTrace();
}
}
} |
14,329 | 0 | /* Alliance info */ | public void importAlliancesScoring(HashMap<MatchGeneral, MatchDetailRelicJSON> scores){
File allianceFile = new File(Config.SCORING_DIR + File.separator + "alliances.txt");
if (allianceFile.exists()) {
try {
BufferedReader reader = new BufferedReader(new FileReader(allianceFile));
String line;
alliances = new Alliance[4];
while ((line = reader.readLine()) != null) {
/* Alliance info */
String[] allianceInfo = line.split("\\|");
int division = Integer.parseInt(allianceInfo[0]);
int allianceNumber = Integer.parseInt(allianceInfo[1]);
int[] allianceNumbers = {Integer.parseInt(allianceInfo[3]), Integer.parseInt(allianceInfo[4]), Integer.parseInt(allianceInfo[5])};
alliances[allianceNumber-1] = new Alliance(division, allianceNumber, allianceNumbers);
}
reader.close();
/* TODO - Make Upload Alliances so we can uncomment this
controller.btnUploadAlliances.setDisable(false);*/
updateAllianceLabels(scores);
TOALogger.log(Level.INFO, "Alliance import successful.");
} catch (Exception e) {
e.printStackTrace();
controller.sendError("Could not open file. " + e.getLocalizedMessage());
}
} else {
controller.sendError("Could not locate alliances.txt from the Scoring System. Did you generate an elimination bracket?");
}
} | NONSATD | true | alliances = new Alliance[4];
while ((line = reader.readLine()) != null) {
/* Alliance info */
String[] allianceInfo = line.split("\\|");
int division = Integer.parseInt(allianceInfo[0]); | public void importAlliancesScoring(HashMap<MatchGeneral, MatchDetailRelicJSON> scores){
File allianceFile = new File(Config.SCORING_DIR + File.separator + "alliances.txt");
if (allianceFile.exists()) {
try {
BufferedReader reader = new BufferedReader(new FileReader(allianceFile));
String line;
alliances = new Alliance[4];
while ((line = reader.readLine()) != null) {
/* Alliance info */
String[] allianceInfo = line.split("\\|");
int division = Integer.parseInt(allianceInfo[0]);
int allianceNumber = Integer.parseInt(allianceInfo[1]);
int[] allianceNumbers = {Integer.parseInt(allianceInfo[3]), Integer.parseInt(allianceInfo[4]), Integer.parseInt(allianceInfo[5])};
alliances[allianceNumber-1] = new Alliance(division, allianceNumber, allianceNumbers);
}
reader.close();
/* TODO - Make Upload Alliances so we can uncomment this
controller.btnUploadAlliances.setDisable(false);*/
updateAllianceLabels(scores); | public void importAlliancesScoring(HashMap<MatchGeneral, MatchDetailRelicJSON> scores){
File allianceFile = new File(Config.SCORING_DIR + File.separator + "alliances.txt");
if (allianceFile.exists()) {
try {
BufferedReader reader = new BufferedReader(new FileReader(allianceFile));
String line;
alliances = new Alliance[4];
while ((line = reader.readLine()) != null) {
/* Alliance info */
String[] allianceInfo = line.split("\\|");
int division = Integer.parseInt(allianceInfo[0]);
int allianceNumber = Integer.parseInt(allianceInfo[1]);
int[] allianceNumbers = {Integer.parseInt(allianceInfo[3]), Integer.parseInt(allianceInfo[4]), Integer.parseInt(allianceInfo[5])};
alliances[allianceNumber-1] = new Alliance(division, allianceNumber, allianceNumbers);
}
reader.close();
/* TODO - Make Upload Alliances so we can uncomment this
controller.btnUploadAlliances.setDisable(false);*/
updateAllianceLabels(scores);
TOALogger.log(Level.INFO, "Alliance import successful.");
} catch (Exception e) {
e.printStackTrace();
controller.sendError("Could not open file. " + e.getLocalizedMessage());
}
} else {
controller.sendError("Could not locate alliances.txt from the Scoring System. Did you generate an elimination bracket?");
}
} |
14,329 | 1 | /* TODO - Make Upload Alliances so we can uncomment this
controller.btnUploadAlliances.setDisable(false);*/ | public void importAlliancesScoring(HashMap<MatchGeneral, MatchDetailRelicJSON> scores){
File allianceFile = new File(Config.SCORING_DIR + File.separator + "alliances.txt");
if (allianceFile.exists()) {
try {
BufferedReader reader = new BufferedReader(new FileReader(allianceFile));
String line;
alliances = new Alliance[4];
while ((line = reader.readLine()) != null) {
/* Alliance info */
String[] allianceInfo = line.split("\\|");
int division = Integer.parseInt(allianceInfo[0]);
int allianceNumber = Integer.parseInt(allianceInfo[1]);
int[] allianceNumbers = {Integer.parseInt(allianceInfo[3]), Integer.parseInt(allianceInfo[4]), Integer.parseInt(allianceInfo[5])};
alliances[allianceNumber-1] = new Alliance(division, allianceNumber, allianceNumbers);
}
reader.close();
/* TODO - Make Upload Alliances so we can uncomment this
controller.btnUploadAlliances.setDisable(false);*/
updateAllianceLabels(scores);
TOALogger.log(Level.INFO, "Alliance import successful.");
} catch (Exception e) {
e.printStackTrace();
controller.sendError("Could not open file. " + e.getLocalizedMessage());
}
} else {
controller.sendError("Could not locate alliances.txt from the Scoring System. Did you generate an elimination bracket?");
}
} | IMPLEMENTATION | true | }
reader.close();
/* TODO - Make Upload Alliances so we can uncomment this
controller.btnUploadAlliances.setDisable(false);*/
updateAllianceLabels(scores);
TOALogger.log(Level.INFO, "Alliance import successful."); | alliances = new Alliance[4];
while ((line = reader.readLine()) != null) {
/* Alliance info */
String[] allianceInfo = line.split("\\|");
int division = Integer.parseInt(allianceInfo[0]);
int allianceNumber = Integer.parseInt(allianceInfo[1]);
int[] allianceNumbers = {Integer.parseInt(allianceInfo[3]), Integer.parseInt(allianceInfo[4]), Integer.parseInt(allianceInfo[5])};
alliances[allianceNumber-1] = new Alliance(division, allianceNumber, allianceNumbers);
}
reader.close();
/* TODO - Make Upload Alliances so we can uncomment this
controller.btnUploadAlliances.setDisable(false);*/
updateAllianceLabels(scores);
TOALogger.log(Level.INFO, "Alliance import successful.");
} catch (Exception e) {
e.printStackTrace();
controller.sendError("Could not open file. " + e.getLocalizedMessage());
}
} else {
controller.sendError("Could not locate alliances.txt from the Scoring System. Did you generate an elimination bracket?");
}
} | public void importAlliancesScoring(HashMap<MatchGeneral, MatchDetailRelicJSON> scores){
File allianceFile = new File(Config.SCORING_DIR + File.separator + "alliances.txt");
if (allianceFile.exists()) {
try {
BufferedReader reader = new BufferedReader(new FileReader(allianceFile));
String line;
alliances = new Alliance[4];
while ((line = reader.readLine()) != null) {
/* Alliance info */
String[] allianceInfo = line.split("\\|");
int division = Integer.parseInt(allianceInfo[0]);
int allianceNumber = Integer.parseInt(allianceInfo[1]);
int[] allianceNumbers = {Integer.parseInt(allianceInfo[3]), Integer.parseInt(allianceInfo[4]), Integer.parseInt(allianceInfo[5])};
alliances[allianceNumber-1] = new Alliance(division, allianceNumber, allianceNumbers);
}
reader.close();
/* TODO - Make Upload Alliances so we can uncomment this
controller.btnUploadAlliances.setDisable(false);*/
updateAllianceLabels(scores);
TOALogger.log(Level.INFO, "Alliance import successful.");
} catch (Exception e) {
e.printStackTrace();
controller.sendError("Could not open file. " + e.getLocalizedMessage());
}
} else {
controller.sendError("Could not locate alliances.txt from the Scoring System. Did you generate an elimination bracket?");
}
} |
14,341 | 0 | // add MQTT listener | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} | NONSATD | true | public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} |
14,341 | 1 | // need to bind the UI activity and the background service | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} | NONSATD | true | // add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} |
14,341 | 2 | // change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} | DESIGN | true | // need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} |
14,341 | 3 | // TODO: this function is only used for >=API 8.0, so may be need to support other version's API | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} | IMPLEMENTATION | true | // TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// add MQTT listener
MqttService.add_mqttListener(this);
// need to bind the UI activity and the background service
Intent intent=new Intent(getActivity(),MqttService.class);
// change the current msg-->different page has different topic
// TODO: may use '#' to receive all msg, and different listener to select the topic they need
MqttService.setCur_topic("pic_data");
// TODO: this function is only used for >=API 8.0, so may be need to support other version's API
startForegroundService(getActivity(),intent);
} |
22,550 | 0 | /**
* Remove element from the queue
* @return element
*/ | public T dequeue(){
//TODO resolve queue with single element
T result = current.get();
current = current.next();
return result;
} | NONSATD | true | public T dequeue(){
//TODO resolve queue with single element
T result = current.get();
current = current.next();
return result;
} | public T dequeue(){
//TODO resolve queue with single element
T result = current.get();
current = current.next();
return result;
} | public T dequeue(){
//TODO resolve queue with single element
T result = current.get();
current = current.next();
return result;
} |
22,550 | 1 | //TODO resolve queue with single element | public T dequeue(){
//TODO resolve queue with single element
T result = current.get();
current = current.next();
return result;
} | IMPLEMENTATION | true | public T dequeue(){
//TODO resolve queue with single element
T result = current.get();
current = current.next(); | public T dequeue(){
//TODO resolve queue with single element
T result = current.get();
current = current.next();
return result;
} | public T dequeue(){
//TODO resolve queue with single element
T result = current.get();
current = current.next();
return result;
} |
22,556 | 0 | // compute the subnet mask address | private boolean updateAddressFilter(String filter)
{
String[] pieces = filter.split("/");
if(pieces.length != 2)
{
searchTextField.setBackground(Color.RED);
return false;
}
InetAddress new_filter_address;
InetAddress new_filter_mask;
boolean new_filter_enabled = !(pieces[1].equals("0"));
try {
new_filter_address = InetAddress.getByName(pieces[0]);
// compute the subnet mask address
byte[] byte_mask = new byte[4];
int slash = Integer.parseInt(pieces[1]);
// compute the mask address
// there is probably a way easier way to do this
for (int j=0; slash-- > 0; j++) {
if (j<8) byte_mask[0] += Math.pow(2,j);
if (j<16) byte_mask[1] += Math.pow(2,j-8);
if (j<24) byte_mask[2] += Math.pow(2,j-16);
if (j<32) byte_mask[3] += Math.pow(2,j-24);
}
new_filter_mask = InetAddress.getByAddress(byte_mask);
}
catch (Exception e) {
searchTextField.setBackground(Color.RED);
return false;
}
ip_filter_enabled = new_filter_enabled;
filter_address = new_filter_address;
filter_mask = new_filter_mask;
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
System.out.println("Updating filter succeeded!");
searchTextField.setBackground(Color.WHITE);
return true;
} | NONSATD | true | try {
new_filter_address = InetAddress.getByName(pieces[0]);
// compute the subnet mask address
byte[] byte_mask = new byte[4];
int slash = Integer.parseInt(pieces[1]); | if(pieces.length != 2)
{
searchTextField.setBackground(Color.RED);
return false;
}
InetAddress new_filter_address;
InetAddress new_filter_mask;
boolean new_filter_enabled = !(pieces[1].equals("0"));
try {
new_filter_address = InetAddress.getByName(pieces[0]);
// compute the subnet mask address
byte[] byte_mask = new byte[4];
int slash = Integer.parseInt(pieces[1]);
// compute the mask address
// there is probably a way easier way to do this
for (int j=0; slash-- > 0; j++) {
if (j<8) byte_mask[0] += Math.pow(2,j);
if (j<16) byte_mask[1] += Math.pow(2,j-8);
if (j<24) byte_mask[2] += Math.pow(2,j-16);
if (j<32) byte_mask[3] += Math.pow(2,j-24);
} | private boolean updateAddressFilter(String filter)
{
String[] pieces = filter.split("/");
if(pieces.length != 2)
{
searchTextField.setBackground(Color.RED);
return false;
}
InetAddress new_filter_address;
InetAddress new_filter_mask;
boolean new_filter_enabled = !(pieces[1].equals("0"));
try {
new_filter_address = InetAddress.getByName(pieces[0]);
// compute the subnet mask address
byte[] byte_mask = new byte[4];
int slash = Integer.parseInt(pieces[1]);
// compute the mask address
// there is probably a way easier way to do this
for (int j=0; slash-- > 0; j++) {
if (j<8) byte_mask[0] += Math.pow(2,j);
if (j<16) byte_mask[1] += Math.pow(2,j-8);
if (j<24) byte_mask[2] += Math.pow(2,j-16);
if (j<32) byte_mask[3] += Math.pow(2,j-24);
}
new_filter_mask = InetAddress.getByAddress(byte_mask);
}
catch (Exception e) {
searchTextField.setBackground(Color.RED);
return false;
}
ip_filter_enabled = new_filter_enabled;
filter_address = new_filter_address;
filter_mask = new_filter_mask;
fireExpressionChangedEvent(); |
22,556 | 1 | // compute the mask address
// there is probably a way easier way to do this | private boolean updateAddressFilter(String filter)
{
String[] pieces = filter.split("/");
if(pieces.length != 2)
{
searchTextField.setBackground(Color.RED);
return false;
}
InetAddress new_filter_address;
InetAddress new_filter_mask;
boolean new_filter_enabled = !(pieces[1].equals("0"));
try {
new_filter_address = InetAddress.getByName(pieces[0]);
// compute the subnet mask address
byte[] byte_mask = new byte[4];
int slash = Integer.parseInt(pieces[1]);
// compute the mask address
// there is probably a way easier way to do this
for (int j=0; slash-- > 0; j++) {
if (j<8) byte_mask[0] += Math.pow(2,j);
if (j<16) byte_mask[1] += Math.pow(2,j-8);
if (j<24) byte_mask[2] += Math.pow(2,j-16);
if (j<32) byte_mask[3] += Math.pow(2,j-24);
}
new_filter_mask = InetAddress.getByAddress(byte_mask);
}
catch (Exception e) {
searchTextField.setBackground(Color.RED);
return false;
}
ip_filter_enabled = new_filter_enabled;
filter_address = new_filter_address;
filter_mask = new_filter_mask;
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
System.out.println("Updating filter succeeded!");
searchTextField.setBackground(Color.WHITE);
return true;
} | NONSATD | true | byte[] byte_mask = new byte[4];
int slash = Integer.parseInt(pieces[1]);
// compute the mask address
// there is probably a way easier way to do this
for (int j=0; slash-- > 0; j++) {
if (j<8) byte_mask[0] += Math.pow(2,j); | return false;
}
InetAddress new_filter_address;
InetAddress new_filter_mask;
boolean new_filter_enabled = !(pieces[1].equals("0"));
try {
new_filter_address = InetAddress.getByName(pieces[0]);
// compute the subnet mask address
byte[] byte_mask = new byte[4];
int slash = Integer.parseInt(pieces[1]);
// compute the mask address
// there is probably a way easier way to do this
for (int j=0; slash-- > 0; j++) {
if (j<8) byte_mask[0] += Math.pow(2,j);
if (j<16) byte_mask[1] += Math.pow(2,j-8);
if (j<24) byte_mask[2] += Math.pow(2,j-16);
if (j<32) byte_mask[3] += Math.pow(2,j-24);
}
new_filter_mask = InetAddress.getByAddress(byte_mask);
}
catch (Exception e) {
searchTextField.setBackground(Color.RED); | private boolean updateAddressFilter(String filter)
{
String[] pieces = filter.split("/");
if(pieces.length != 2)
{
searchTextField.setBackground(Color.RED);
return false;
}
InetAddress new_filter_address;
InetAddress new_filter_mask;
boolean new_filter_enabled = !(pieces[1].equals("0"));
try {
new_filter_address = InetAddress.getByName(pieces[0]);
// compute the subnet mask address
byte[] byte_mask = new byte[4];
int slash = Integer.parseInt(pieces[1]);
// compute the mask address
// there is probably a way easier way to do this
for (int j=0; slash-- > 0; j++) {
if (j<8) byte_mask[0] += Math.pow(2,j);
if (j<16) byte_mask[1] += Math.pow(2,j-8);
if (j<24) byte_mask[2] += Math.pow(2,j-16);
if (j<32) byte_mask[3] += Math.pow(2,j-24);
}
new_filter_mask = InetAddress.getByAddress(byte_mask);
}
catch (Exception e) {
searchTextField.setBackground(Color.RED);
return false;
}
ip_filter_enabled = new_filter_enabled;
filter_address = new_filter_address;
filter_mask = new_filter_mask;
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
System.out.println("Updating filter succeeded!");
searchTextField.setBackground(Color.WHITE); |
22,556 | 2 | //TODO: make data listen to this so that we don't need this call | private boolean updateAddressFilter(String filter)
{
String[] pieces = filter.split("/");
if(pieces.length != 2)
{
searchTextField.setBackground(Color.RED);
return false;
}
InetAddress new_filter_address;
InetAddress new_filter_mask;
boolean new_filter_enabled = !(pieces[1].equals("0"));
try {
new_filter_address = InetAddress.getByName(pieces[0]);
// compute the subnet mask address
byte[] byte_mask = new byte[4];
int slash = Integer.parseInt(pieces[1]);
// compute the mask address
// there is probably a way easier way to do this
for (int j=0; slash-- > 0; j++) {
if (j<8) byte_mask[0] += Math.pow(2,j);
if (j<16) byte_mask[1] += Math.pow(2,j-8);
if (j<24) byte_mask[2] += Math.pow(2,j-16);
if (j<32) byte_mask[3] += Math.pow(2,j-24);
}
new_filter_mask = InetAddress.getByAddress(byte_mask);
}
catch (Exception e) {
searchTextField.setBackground(Color.RED);
return false;
}
ip_filter_enabled = new_filter_enabled;
filter_address = new_filter_address;
filter_mask = new_filter_mask;
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
System.out.println("Updating filter succeeded!");
searchTextField.setBackground(Color.WHITE);
return true;
} | DESIGN | true | filter_mask = new_filter_mask;
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
System.out.println("Updating filter succeeded!"); | new_filter_mask = InetAddress.getByAddress(byte_mask);
}
catch (Exception e) {
searchTextField.setBackground(Color.RED);
return false;
}
ip_filter_enabled = new_filter_enabled;
filter_address = new_filter_address;
filter_mask = new_filter_mask;
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
System.out.println("Updating filter succeeded!");
searchTextField.setBackground(Color.WHITE);
return true;
} | byte[] byte_mask = new byte[4];
int slash = Integer.parseInt(pieces[1]);
// compute the mask address
// there is probably a way easier way to do this
for (int j=0; slash-- > 0; j++) {
if (j<8) byte_mask[0] += Math.pow(2,j);
if (j<16) byte_mask[1] += Math.pow(2,j-8);
if (j<24) byte_mask[2] += Math.pow(2,j-16);
if (j<32) byte_mask[3] += Math.pow(2,j-24);
}
new_filter_mask = InetAddress.getByAddress(byte_mask);
}
catch (Exception e) {
searchTextField.setBackground(Color.RED);
return false;
}
ip_filter_enabled = new_filter_enabled;
filter_address = new_filter_address;
filter_mask = new_filter_mask;
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
System.out.println("Updating filter succeeded!");
searchTextField.setBackground(Color.WHITE);
return true;
} |
22,557 | 0 | // get the minimum degree rank | private void updateRanges()
{
// get the minimum degree rank
min_degree_rank = (float)(degreeRangeSlider.getLowValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
max_degree_rank = (float)(degreeRangeSlider.getHighValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
min_bandwidth_rank = (float)(bandwidthRangeSlider.getLowValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
max_bandwidth_rank = (float)(bandwidthRangeSlider.getHighValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
min_degree_enabled = degreeRangeSlider.getLowValue() != degreeRangeSlider.getMinimum();
max_degree_enabled = degreeRangeSlider.getHighValue() != degreeRangeSlider.getMaximum();
min_bandwidth_enabled = bandwidthRangeSlider.getLowValue() != bandwidthRangeSlider.getMinimum();
max_bandwidth_enabled = bandwidthRangeSlider.getHighValue() != bandwidthRangeSlider.getMaximum();
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
} | NONSATD | true | private void updateRanges()
{
// get the minimum degree rank
min_degree_rank = (float)(degreeRangeSlider.getLowValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum()); | private void updateRanges()
{
// get the minimum degree rank
min_degree_rank = (float)(degreeRangeSlider.getLowValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
max_degree_rank = (float)(degreeRangeSlider.getHighValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
min_bandwidth_rank = (float)(bandwidthRangeSlider.getLowValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
max_bandwidth_rank = (float)(bandwidthRangeSlider.getHighValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
min_degree_enabled = degreeRangeSlider.getLowValue() != degreeRangeSlider.getMinimum();
max_degree_enabled = degreeRangeSlider.getHighValue() != degreeRangeSlider.getMaximum(); | private void updateRanges()
{
// get the minimum degree rank
min_degree_rank = (float)(degreeRangeSlider.getLowValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
max_degree_rank = (float)(degreeRangeSlider.getHighValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
min_bandwidth_rank = (float)(bandwidthRangeSlider.getLowValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
max_bandwidth_rank = (float)(bandwidthRangeSlider.getHighValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
min_degree_enabled = degreeRangeSlider.getLowValue() != degreeRangeSlider.getMinimum();
max_degree_enabled = degreeRangeSlider.getHighValue() != degreeRangeSlider.getMaximum();
min_bandwidth_enabled = bandwidthRangeSlider.getLowValue() != bandwidthRangeSlider.getMinimum();
max_bandwidth_enabled = bandwidthRangeSlider.getHighValue() != bandwidthRangeSlider.getMaximum();
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
} |
22,557 | 1 | //TODO: make data listen to this so that we don't need this call | private void updateRanges()
{
// get the minimum degree rank
min_degree_rank = (float)(degreeRangeSlider.getLowValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
max_degree_rank = (float)(degreeRangeSlider.getHighValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
min_bandwidth_rank = (float)(bandwidthRangeSlider.getLowValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
max_bandwidth_rank = (float)(bandwidthRangeSlider.getHighValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
min_degree_enabled = degreeRangeSlider.getLowValue() != degreeRangeSlider.getMinimum();
max_degree_enabled = degreeRangeSlider.getHighValue() != degreeRangeSlider.getMaximum();
min_bandwidth_enabled = bandwidthRangeSlider.getLowValue() != bandwidthRangeSlider.getMinimum();
max_bandwidth_enabled = bandwidthRangeSlider.getHighValue() != bandwidthRangeSlider.getMaximum();
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
} | DESIGN | true | max_bandwidth_enabled = bandwidthRangeSlider.getHighValue() != bandwidthRangeSlider.getMaximum();
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
} | (float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
min_bandwidth_rank = (float)(bandwidthRangeSlider.getLowValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
max_bandwidth_rank = (float)(bandwidthRangeSlider.getHighValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
min_degree_enabled = degreeRangeSlider.getLowValue() != degreeRangeSlider.getMinimum();
max_degree_enabled = degreeRangeSlider.getHighValue() != degreeRangeSlider.getMaximum();
min_bandwidth_enabled = bandwidthRangeSlider.getLowValue() != bandwidthRangeSlider.getMinimum();
max_bandwidth_enabled = bandwidthRangeSlider.getHighValue() != bandwidthRangeSlider.getMaximum();
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
} | private void updateRanges()
{
// get the minimum degree rank
min_degree_rank = (float)(degreeRangeSlider.getLowValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
max_degree_rank = (float)(degreeRangeSlider.getHighValue() - degreeRangeSlider.getMinimum()) /
(float)(degreeRangeSlider.getMaximum() - degreeRangeSlider.getMinimum());
min_bandwidth_rank = (float)(bandwidthRangeSlider.getLowValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
max_bandwidth_rank = (float)(bandwidthRangeSlider.getHighValue() - bandwidthRangeSlider.getMinimum()) /
(float)(bandwidthRangeSlider.getMaximum() - bandwidthRangeSlider.getMinimum());
min_degree_enabled = degreeRangeSlider.getLowValue() != degreeRangeSlider.getMinimum();
max_degree_enabled = degreeRangeSlider.getHighValue() != degreeRangeSlider.getMaximum();
min_bandwidth_enabled = bandwidthRangeSlider.getLowValue() != bandwidthRangeSlider.getMinimum();
max_bandwidth_enabled = bandwidthRangeSlider.getHighValue() != bandwidthRangeSlider.getMaximum();
fireExpressionChangedEvent();
//TODO: make data listen to this so that we don't need this call
data.setFilterPredicate(this);
} |
30,751 | 0 | // Resolve reference to constantPool by index in constants | private void resolveConstantPoolReferences(ConstantInfo[] constantPool) {
for (ConstantInfo constant : constantPool) {
if (constant instanceof ConstantInfo.Class) {
ConstantInfo.Class info = (ConstantInfo.Class)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Fieldref) {
ConstantInfo.Fieldref info = (ConstantInfo.Fieldref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.Methodref) {
ConstantInfo.Methodref info = (ConstantInfo.Methodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.InterfaceMethodref) {
ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} | NONSATD | true | private void resolveConstantPoolReferences(ConstantInfo[] constantPool) {
for (ConstantInfo constant : constantPool) {
if (constant instanceof ConstantInfo.Class) {
ConstantInfo.Class info = (ConstantInfo.Class)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Fieldref) {
ConstantInfo.Fieldref info = (ConstantInfo.Fieldref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.Methodref) {
ConstantInfo.Methodref info = (ConstantInfo.Methodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.InterfaceMethodref) {
ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} | private void resolveConstantPoolReferences(ConstantInfo[] constantPool) {
for (ConstantInfo constant : constantPool) {
if (constant instanceof ConstantInfo.Class) {
ConstantInfo.Class info = (ConstantInfo.Class)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Fieldref) {
ConstantInfo.Fieldref info = (ConstantInfo.Fieldref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.Methodref) {
ConstantInfo.Methodref info = (ConstantInfo.Methodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.InterfaceMethodref) {
ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} | private void resolveConstantPoolReferences(ConstantInfo[] constantPool) {
for (ConstantInfo constant : constantPool) {
if (constant instanceof ConstantInfo.Class) {
ConstantInfo.Class info = (ConstantInfo.Class)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Fieldref) {
ConstantInfo.Fieldref info = (ConstantInfo.Fieldref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.Methodref) {
ConstantInfo.Methodref info = (ConstantInfo.Methodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.InterfaceMethodref) {
ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} |
30,751 | 1 | // not needed | private void resolveConstantPoolReferences(ConstantInfo[] constantPool) {
for (ConstantInfo constant : constantPool) {
if (constant instanceof ConstantInfo.Class) {
ConstantInfo.Class info = (ConstantInfo.Class)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Fieldref) {
ConstantInfo.Fieldref info = (ConstantInfo.Fieldref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.Methodref) {
ConstantInfo.Methodref info = (ConstantInfo.Methodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.InterfaceMethodref) {
ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} | NONSATD | true | || constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant; | ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet | info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Fieldref) {
ConstantInfo.Fieldref info = (ConstantInfo.Fieldref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.Methodref) {
ConstantInfo.Methodref info = (ConstantInfo.Methodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.InterfaceMethodref) {
ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} |
30,751 | 2 | // not needed | private void resolveConstantPoolReferences(ConstantInfo[] constantPool) {
for (ConstantInfo constant : constantPool) {
if (constant instanceof ConstantInfo.Class) {
ConstantInfo.Class info = (ConstantInfo.Class)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Fieldref) {
ConstantInfo.Fieldref info = (ConstantInfo.Fieldref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.Methodref) {
ConstantInfo.Methodref info = (ConstantInfo.Methodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.InterfaceMethodref) {
ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} | NONSATD | true | || constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant; | ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet | info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Fieldref) {
ConstantInfo.Fieldref info = (ConstantInfo.Fieldref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.Methodref) {
ConstantInfo.Methodref info = (ConstantInfo.Methodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.InterfaceMethodref) {
ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} |
30,751 | 3 | // not used yet | private void resolveConstantPoolReferences(ConstantInfo[] constantPool) {
for (ConstantInfo constant : constantPool) {
if (constant instanceof ConstantInfo.Class) {
ConstantInfo.Class info = (ConstantInfo.Class)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Fieldref) {
ConstantInfo.Fieldref info = (ConstantInfo.Fieldref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.Methodref) {
ConstantInfo.Methodref info = (ConstantInfo.Methodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.InterfaceMethodref) {
ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} | DESIGN | true | || constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant); | // not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} | ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} |
30,751 | 4 | // Long/Double may leave create a blank space | private void resolveConstantPoolReferences(ConstantInfo[] constantPool) {
for (ConstantInfo constant : constantPool) {
if (constant instanceof ConstantInfo.Class) {
ConstantInfo.Class info = (ConstantInfo.Class)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Fieldref) {
ConstantInfo.Fieldref info = (ConstantInfo.Fieldref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.Methodref) {
ConstantInfo.Methodref info = (ConstantInfo.Methodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.InterfaceMethodref) {
ConstantInfo.InterfaceMethodref info = (ConstantInfo.InterfaceMethodref)constant;
info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} | NONSATD | true | || constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
} | } else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} | info.setClassInfo((ConstantInfo.Class)constantPool[info.getClassIndex() - 1]);
info.setNameAndType((ConstantInfo.NameAndType)constantPool[info.getNameAndTypeIndex() - 1]);
} else if (constant instanceof ConstantInfo.String) {
ConstantInfo.String info = (ConstantInfo.String)constant;
info.setString(((ConstantInfo.Utf8)constantPool[info.getStringIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Integer
|| constant instanceof ConstantInfo.Float
|| constant instanceof ConstantInfo.Long
|| constant instanceof ConstantInfo.Double) {
// not needed
} else if (constant instanceof ConstantInfo.NameAndType) {
ConstantInfo.NameAndType info = (ConstantInfo.NameAndType)constant;
info.setName(((ConstantInfo.Utf8)constantPool[info.getNameIndex() - 1]).getString());
info.setDescriptor(((ConstantInfo.Utf8)constantPool[info.getDescriptorIndex() - 1]).getString());
} else if (constant instanceof ConstantInfo.Utf8) {
// not needed
} else if (constant instanceof ConstantInfo.MethodHandle
|| constant instanceof ConstantInfo.MethodType
|| constant instanceof ConstantInfo.InvokeDynamic) {
// not used yet
} else if (constant != null) { // Long/Double may leave create a blank space
throw new UnsupportedOperationException("Unhandled ConstantType: " + constant);
}
}
} |
14,375 | 0 | //GEN-FIRST:event_networkNameMouseClicked | private void networkNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_networkNameMouseClicked
// TODO add your handling code here:
// jTextField1.setText("");
} | NONSATD | true | private void networkNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_networkNameMouseClicked
// TODO add your handling code here:
// jTextField1.setText(""); | private void networkNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_networkNameMouseClicked
// TODO add your handling code here:
// jTextField1.setText("");
} | private void networkNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_networkNameMouseClicked
// TODO add your handling code here:
// jTextField1.setText("");
} |
14,375 | 1 | // TODO add your handling code here:
// jTextField1.setText(""); | private void networkNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_networkNameMouseClicked
// TODO add your handling code here:
// jTextField1.setText("");
} | IMPLEMENTATION | true | private void networkNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_networkNameMouseClicked
// TODO add your handling code here:
// jTextField1.setText("");
} | private void networkNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_networkNameMouseClicked
// TODO add your handling code here:
// jTextField1.setText("");
} | private void networkNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_networkNameMouseClicked
// TODO add your handling code here:
// jTextField1.setText("");
} |
22,568 | 0 | // Figure out where we need to jump to... | public long forceSkip(long bytesToSkip) throws IOException {
long skipped = mUpstream.skip(bytesToSkip);
try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer);
Arrays.fill(skipBuffer, (byte) 0);
} catch (Exception e) {
return 0;
}
return skipped;
} | NONSATD | true | long skipped = mUpstream.skip(bytesToSkip);
try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip; | public long forceSkip(long bytesToSkip) throws IOException {
long skipped = mUpstream.skip(bytesToSkip);
try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE]; | public long forceSkip(long bytesToSkip) throws IOException {
long skipped = mUpstream.skip(bytesToSkip);
try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer); |
22,568 | 1 | // TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode | public long forceSkip(long bytesToSkip) throws IOException {
long skipped = mUpstream.skip(bytesToSkip);
try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer);
Arrays.fill(skipBuffer, (byte) 0);
} catch (Exception e) {
return 0;
}
return skipped;
} | DESIGN | true | long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray(); | public long forceSkip(long bytesToSkip) throws IOException {
long skipped = mUpstream.skip(bytesToSkip);
try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
} | public long forceSkip(long bytesToSkip) throws IOException {
long skipped = mUpstream.skip(bytesToSkip);
try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer);
Arrays.fill(skipBuffer, (byte) 0);
} catch (Exception e) {
return 0;
}
return skipped; |
22,568 | 2 | // Setup the cipher to use the new IV at the proper offset... | public long forceSkip(long bytesToSkip) throws IOException {
long skipped = mUpstream.skip(bytesToSkip);
try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer);
Arrays.fill(skipBuffer, (byte) 0);
} catch (Exception e) {
return 0;
}
return skipped;
} | NONSATD | true | computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip]; | BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer);
Arrays.fill(skipBuffer, (byte) 0);
} catch (Exception e) {
return 0;
}
return skipped;
} | public long forceSkip(long bytesToSkip) throws IOException {
long skipped = mUpstream.skip(bytesToSkip);
try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer);
Arrays.fill(skipBuffer, (byte) 0);
} catch (Exception e) {
return 0;
}
return skipped;
} |
22,568 | 3 | // And read/update the buffer to be decrypted | public long forceSkip(long bytesToSkip) throws IOException {
long skipped = mUpstream.skip(bytesToSkip);
try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer);
Arrays.fill(skipBuffer, (byte) 0);
} catch (Exception e) {
return 0;
}
return skipped;
} | NONSATD | true | mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer);
Arrays.fill(skipBuffer, (byte) 0); | if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer);
Arrays.fill(skipBuffer, (byte) 0);
} catch (Exception e) {
return 0;
}
return skipped;
} | try {
// Figure out where we need to jump to...
int skip = (int) (bytesToSkip % AES_BLOCK_SIZE);
long blockOffset = bytesToSkip - skip;
long numberOfBlocks = blockOffset / AES_BLOCK_SIZE;
// TODO: This is designed for CTS mode, for other modes this routine code has to be changed
// So that we don't have to read the entire stream, we have to compute what the IV should be at this point in time in CTS mode
BigInteger ivForOffsetAsBigInteger = new BigInteger(1, mIvParameterSpec.getIV()).add(BigInteger.valueOf(numberOfBlocks));
byte[] ivForOffsetByteArray = ivForOffsetAsBigInteger.toByteArray();
IvParameterSpec computedIvParameterSpecForOffset;
if (ivForOffsetByteArray.length < AES_BLOCK_SIZE) {
byte[] resizedIvForOffsetByteArray = new byte[AES_BLOCK_SIZE];
System.arraycopy(ivForOffsetByteArray, 0, resizedIvForOffsetByteArray, AES_BLOCK_SIZE - ivForOffsetByteArray.length, ivForOffsetByteArray.length);
computedIvParameterSpecForOffset = new IvParameterSpec(resizedIvForOffsetByteArray);
} else {
computedIvParameterSpecForOffset = new IvParameterSpec(ivForOffsetByteArray, ivForOffsetByteArray.length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
}
// Setup the cipher to use the new IV at the proper offset...
mCipher.init(Cipher.ENCRYPT_MODE, mSecretKeySpec, computedIvParameterSpecForOffset);
byte[] skipBuffer = new byte[skip];
// And read/update the buffer to be decrypted
mCipher.update(skipBuffer, 0, skip, skipBuffer);
Arrays.fill(skipBuffer, (byte) 0);
} catch (Exception e) {
return 0;
}
return skipped;
} |
14,380 | 0 | /**
*
* TODO figure out how to test this
*
* @throws Exception
*/ | public void testEmit() throws Exception {
eh.on("ok", new EventEmitter.Listener() {
@Override
public void onEvent(Object data) {
String ss = (String) data;
if (ss == "ok")
Log.d(TAG, "pass@" + ss);
else
Log.d(TAG, "fail@" + ss);
}
});
eh.on("no", new EventEmitter.Listener() {
@Override
public void onEvent(Object data) {
String ss = (String) data;
if (ss == "no")
Log.d(TAG, "pass@" + ss);
else
Log.d(TAG, "fail@" + ss);
}
});
eh.emit("ok");
eh.emit("ok", "ok");
eh.emit("ok", "no");
eh.emit("no");
eh.emit("no", "no");
eh.emit("no", "ok");
eh.emit("unknown");
eh.emit("unknown", "ok");
eh.emit("unknown", "no");
fail(); // FIXME these tests are not correct
} | TEST | true | public void testEmit() throws Exception {
eh.on("ok", new EventEmitter.Listener() {
@Override
public void onEvent(Object data) {
String ss = (String) data;
if (ss == "ok")
Log.d(TAG, "pass@" + ss);
else
Log.d(TAG, "fail@" + ss);
}
});
eh.on("no", new EventEmitter.Listener() {
@Override
public void onEvent(Object data) {
String ss = (String) data;
if (ss == "no")
Log.d(TAG, "pass@" + ss);
else
Log.d(TAG, "fail@" + ss);
}
});
eh.emit("ok");
eh.emit("ok", "ok");
eh.emit("ok", "no");
eh.emit("no");
eh.emit("no", "no");
eh.emit("no", "ok");
eh.emit("unknown");
eh.emit("unknown", "ok");
eh.emit("unknown", "no");
fail(); // FIXME these tests are not correct
} | public void testEmit() throws Exception {
eh.on("ok", new EventEmitter.Listener() {
@Override
public void onEvent(Object data) {
String ss = (String) data;
if (ss == "ok")
Log.d(TAG, "pass@" + ss);
else
Log.d(TAG, "fail@" + ss);
}
});
eh.on("no", new EventEmitter.Listener() {
@Override
public void onEvent(Object data) {
String ss = (String) data;
if (ss == "no")
Log.d(TAG, "pass@" + ss);
else
Log.d(TAG, "fail@" + ss);
}
});
eh.emit("ok");
eh.emit("ok", "ok");
eh.emit("ok", "no");
eh.emit("no");
eh.emit("no", "no");
eh.emit("no", "ok");
eh.emit("unknown");
eh.emit("unknown", "ok");
eh.emit("unknown", "no");
fail(); // FIXME these tests are not correct
} | public void testEmit() throws Exception {
eh.on("ok", new EventEmitter.Listener() {
@Override
public void onEvent(Object data) {
String ss = (String) data;
if (ss == "ok")
Log.d(TAG, "pass@" + ss);
else
Log.d(TAG, "fail@" + ss);
}
});
eh.on("no", new EventEmitter.Listener() {
@Override
public void onEvent(Object data) {
String ss = (String) data;
if (ss == "no")
Log.d(TAG, "pass@" + ss);
else
Log.d(TAG, "fail@" + ss);
}
});
eh.emit("ok");
eh.emit("ok", "ok");
eh.emit("ok", "no");
eh.emit("no");
eh.emit("no", "no");
eh.emit("no", "ok");
eh.emit("unknown");
eh.emit("unknown", "ok");
eh.emit("unknown", "no");
fail(); // FIXME these tests are not correct
} |