_id
stringlengths 2
7
| title
stringlengths 3
140
| partition
stringclasses 3
values | text
stringlengths 73
34.1k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q179300
|
FlowItemClient.sendFormToFlow
|
test
|
public FluidItem sendFormToFlow(
Form formToSendToFlowParam,
String flowParam) {
FluidItem itemToSend = new FluidItem();
itemToSend.setForm(formToSendToFlowParam);
itemToSend.setFlow(flowParam);
if (this.serviceTicket != null) {
itemToSend.setServiceTicket(this.serviceTicket);
}
try {
return new FluidItem(this.postJson(
itemToSend, WS.Path.FlowItem.Version1.sendFlowItemToFlow()));
} catch (JSONException e) {
throw new FluidClientException(e.getMessage(), e,
FluidClientException.ErrorCode.JSON_PARSING);
}
}
|
java
|
{
"resource": ""
}
|
q179301
|
WebSocketClient.onClose
|
test
|
@OnClose
public void onClose(Session userSessionParam, CloseReason reasonParam) {
this.userSession = null;
if (this.messageHandlers != null) {
this.messageHandlers.values().forEach(handle ->{
handle.connectionClosed();
});
}
}
|
java
|
{
"resource": ""
}
|
q179302
|
WebSocketClient.onMessage
|
test
|
@OnMessage
public void onMessage(String messageParam) {
boolean handlerFoundForMsg = false;
for(IMessageResponseHandler handler : new ArrayList<>(this.messageHandlers.values())) {
Object qualifyObj = handler.doesHandlerQualifyForProcessing(messageParam);
if(qualifyObj instanceof Error) {
handler.handleMessage(qualifyObj);
} else if(qualifyObj instanceof JSONObject) {
handler.handleMessage(qualifyObj);
handlerFoundForMsg = true;
break;
}
}
if(!handlerFoundForMsg) {
throw new FluidClientException(
"No handler found for message;\n"+messageParam,
FluidClientException.ErrorCode.IO_ERROR);
}
}
|
java
|
{
"resource": ""
}
|
q179303
|
WebSocketClient.sendMessage
|
test
|
public void sendMessage(ABaseFluidJSONObject aBaseFluidJSONObjectParam) {
if(aBaseFluidJSONObjectParam == null) {
throw new FluidClientException(
"No JSON Object to send.",
FluidClientException.ErrorCode.IO_ERROR);
} else {
this.sendMessage(aBaseFluidJSONObjectParam.toJsonObject().toString());
}
}
|
java
|
{
"resource": ""
}
|
q179304
|
WebSocketClient.sendMessage
|
test
|
public void sendMessage(String messageToSendParam) {
if(this.userSession == null) {
throw new FluidClientException(
"User Session is not set. Check if connection is open.",
FluidClientException.ErrorCode.IO_ERROR);
}
RemoteEndpoint.Async asyncRemote = null;
if((asyncRemote = this.userSession.getAsyncRemote()) == null) {
throw new FluidClientException(
"Remote Session is not set. Check if connection is open.",
FluidClientException.ErrorCode.IO_ERROR);
}
asyncRemote.sendText(messageToSendParam);
}
|
java
|
{
"resource": ""
}
|
q179305
|
WebSocketClient.closeSession
|
test
|
public void closeSession() {
if(this.userSession == null) {
return;
}
try {
this.userSession.close();
} catch (IOException e) {
throw new FluidClientException(
"Unable to close session. "+e.getMessage(),
e,FluidClientException.ErrorCode.IO_ERROR);
}
}
|
java
|
{
"resource": ""
}
|
q179306
|
SQLUtilWebSocketExecuteNativeSQLClient.executeNativeSQLSynchronized
|
test
|
public List<SQLResultSet> executeNativeSQLSynchronized(
NativeSQLQuery nativeSQLQueryParam) {
if(nativeSQLQueryParam == null)
{
return null;
}
if(nativeSQLQueryParam.getDatasourceName() == null ||
nativeSQLQueryParam.getDatasourceName().isEmpty())
{
throw new FluidClientException(
"No data-source name provided. Not allowed.",
FluidClientException.ErrorCode.FIELD_VALIDATE);
}
//No query to execute...
if((nativeSQLQueryParam.getQuery() == null ||
nativeSQLQueryParam.getQuery().isEmpty()) &&
(nativeSQLQueryParam.getStoredProcedure() == null ||
nativeSQLQueryParam.getStoredProcedure().isEmpty()))
{
return null;
}
//Validate the echo...
this.setEchoIfNotSet(nativeSQLQueryParam);
//Start a new request...
String uniqueReqId = this.initNewRequest();
//Send the actual message...
this.sendMessage(nativeSQLQueryParam, uniqueReqId);
try {
List<SQLResultSet> returnValue =
this.getHandler(uniqueReqId).getCF().get(
this.getTimeoutInMillis(),TimeUnit.MILLISECONDS);
//Connection was closed.. this is a problem....
if(this.getHandler(uniqueReqId).isConnectionClosed())
{
throw new FluidClientException(
"SQLUtil-WebSocket-ExecuteNativeSQL: " +
"The connection was closed by the server prior to the response received.",
FluidClientException.ErrorCode.IO_ERROR);
}
return returnValue;
}
//Interrupted...
catch (InterruptedException exceptParam) {
throw new FluidClientException(
"SQLUtil-WebSocket-ExecuteNativeSQL: " +
exceptParam.getMessage(),
exceptParam,
FluidClientException.ErrorCode.STATEMENT_EXECUTION_ERROR);
}
//Error on the web-socket...
catch (ExecutionException executeProblem) {
Throwable cause = executeProblem.getCause();
//Fluid client exception...
if(cause instanceof FluidClientException)
{
throw (FluidClientException)cause;
}
else
{
throw new FluidClientException(
"SQLUtil-WebSocket-ExecuteNativeSQL: " +
cause.getMessage(), cause,
FluidClientException.ErrorCode.STATEMENT_EXECUTION_ERROR);
}
}
//Timeout...
catch (TimeoutException eParam) {
throw new FluidClientException(
"SQLUtil-WebSocket-ExecuteNativeSQL: Timeout while waiting for all return data. There were '"
+this.getHandler(uniqueReqId).getReturnValue().size()
+"' items after a Timeout of "+(
TimeUnit.MILLISECONDS.toSeconds(this.getTimeoutInMillis()))+" seconds."
,FluidClientException.ErrorCode.IO_ERROR);
}
finally {
this.removeHandler(uniqueReqId);
}
}
|
java
|
{
"resource": ""
}
|
q179307
|
FluidLicenseClient.requestLicense
|
test
|
public String requestLicense(LicenseRequest licenseRequestParam) {
if(licenseRequestParam != null &&
this.serviceTicket != null)
{
licenseRequestParam.setServiceTicket(this.serviceTicket);
}
return this.executeTxtReceiveTxt(
HttpMethod.POST,
null,
false,
(licenseRequestParam == null) ? null :
licenseRequestParam.toJsonObject().toString(),
ContentType.APPLICATION_JSON,
Version1.licenseRequest());
}
|
java
|
{
"resource": ""
}
|
q179308
|
FluidLicenseClient.applyLicense
|
test
|
public LicenseRequest applyLicense(String licenseToApplyParam)
{
LicenseRequest liceReq = new LicenseRequest();
liceReq.setLicenseCipherText(licenseToApplyParam);
if(this.serviceTicket != null)
{
liceReq.setServiceTicket(this.serviceTicket);
}
return new LicenseRequest(this.postJson(
liceReq, Version1.licenseApply()));
}
|
java
|
{
"resource": ""
}
|
q179309
|
RouteFieldClient.createFieldTextPlain
|
test
|
public Field createFieldTextPlain(Field routeFieldParam) {
if(routeFieldParam != null && this.serviceTicket != null) {
routeFieldParam.setServiceTicket(this.serviceTicket);
}
if(routeFieldParam != null) {
routeFieldParam.setTypeAsEnum(Field.Type.Text);
routeFieldParam.setTypeMetaData(FieldMetaData.Text.PLAIN);
}
return new Field(this.putJson(
routeFieldParam, Version1.routeFieldCreate()));
}
|
java
|
{
"resource": ""
}
|
q179310
|
RouteFieldClient.createFieldParagraphTextPlain
|
test
|
public Field createFieldParagraphTextPlain(Field routeFieldParam) {
if(routeFieldParam != null && this.serviceTicket != null) {
routeFieldParam.setServiceTicket(this.serviceTicket);
}
if(routeFieldParam != null) {
routeFieldParam.setTypeAsEnum(Field.Type.ParagraphText);
routeFieldParam.setTypeMetaData(FieldMetaData.ParagraphText.PLAIN);
}
return new Field(this.putJson(
routeFieldParam, Version1.routeFieldCreate()));
}
|
java
|
{
"resource": ""
}
|
q179311
|
RouteFieldClient.createFieldParagraphTextHTML
|
test
|
public Field createFieldParagraphTextHTML(Field routeFieldParam) {
if(routeFieldParam != null && this.serviceTicket != null) {
routeFieldParam.setServiceTicket(this.serviceTicket);
}
if(routeFieldParam != null) {
routeFieldParam.setTypeAsEnum(Field.Type.ParagraphText);
routeFieldParam.setTypeMetaData(FieldMetaData.ParagraphText.HTML);
}
return new Field(this.putJson(
routeFieldParam, Version1.routeFieldCreate()));
}
|
java
|
{
"resource": ""
}
|
q179312
|
RouteFieldClient.createFieldMultiChoiceSelectMany
|
test
|
public Field createFieldMultiChoiceSelectMany(
Field routeFieldParam,
List<String> multiChoiceValuesParam
) {
if(routeFieldParam != null && this.serviceTicket != null) {
routeFieldParam.setServiceTicket(this.serviceTicket);
}
if(multiChoiceValuesParam == null ||
multiChoiceValuesParam.isEmpty()) {
throw new FluidClientException(
"No Multi-choice values provided.",
FluidClientException.ErrorCode.FIELD_VALIDATE);
}
if(routeFieldParam != null) {
routeFieldParam.setTypeAsEnum(Field.Type.MultipleChoice);
routeFieldParam.setTypeMetaData(FieldMetaData.MultiChoice.SELECT_MANY);
routeFieldParam.setFieldValue(new MultiChoice(multiChoiceValuesParam));
}
return new Field(this.putJson(
routeFieldParam, Version1.routeFieldCreate()));
}
|
java
|
{
"resource": ""
}
|
q179313
|
RouteFieldClient.createFieldDateTimeDate
|
test
|
public Field createFieldDateTimeDate(Field routeFieldParam) {
if(routeFieldParam != null && this.serviceTicket != null) {
routeFieldParam.setServiceTicket(this.serviceTicket);
}
if(routeFieldParam != null) {
routeFieldParam.setTypeAsEnum(Field.Type.DateTime);
routeFieldParam.setTypeMetaData(FieldMetaData.DateTime.DATE);
}
return new Field(this.putJson(
routeFieldParam, Version1.routeFieldCreate()));
}
|
java
|
{
"resource": ""
}
|
q179314
|
RouteFieldClient.updateFieldTextPlain
|
test
|
public Field updateFieldTextPlain(Field routeFieldParam) {
if(routeFieldParam != null && this.serviceTicket != null) {
routeFieldParam.setServiceTicket(this.serviceTicket);
}
if(routeFieldParam != null) {
routeFieldParam.setTypeAsEnum(Field.Type.Text);
routeFieldParam.setTypeMetaData(FieldMetaData.Text.PLAIN);
}
return new Field(this.postJson(
routeFieldParam, Version1.routeFieldUpdate()));
}
|
java
|
{
"resource": ""
}
|
q179315
|
RouteFieldClient.updateFieldParagraphTextHTML
|
test
|
public Field updateFieldParagraphTextHTML(Field routeFieldParam) {
if(routeFieldParam != null && this.serviceTicket != null) {
routeFieldParam.setServiceTicket(this.serviceTicket);
}
if(routeFieldParam != null) {
routeFieldParam.setTypeAsEnum(Field.Type.ParagraphText);
routeFieldParam.setTypeMetaData(FieldMetaData.ParagraphText.HTML);
}
return new Field(this.postJson(
routeFieldParam, Version1.routeFieldUpdate()));
}
|
java
|
{
"resource": ""
}
|
q179316
|
RouteFieldClient.updateFieldDateTimeDateAndTime
|
test
|
public Field updateFieldDateTimeDateAndTime(Field routeFieldParam) {
if(routeFieldParam != null && this.serviceTicket != null) {
routeFieldParam.setServiceTicket(this.serviceTicket);
}
if(routeFieldParam != null) {
routeFieldParam.setTypeAsEnum(Field.Type.DateTime);
routeFieldParam.setTypeMetaData(FieldMetaData.DateTime.DATE_AND_TIME);
}
return new Field(this.postJson(
routeFieldParam, Version1.routeFieldUpdate()));
}
|
java
|
{
"resource": ""
}
|
q179317
|
RouteFieldClient.updateFieldDecimalPlain
|
test
|
public Field updateFieldDecimalPlain(Field routeFieldParam) {
if(routeFieldParam != null && this.serviceTicket != null) {
routeFieldParam.setServiceTicket(this.serviceTicket);
}
if(routeFieldParam != null) {
routeFieldParam.setTypeAsEnum(Field.Type.Decimal);
routeFieldParam.setTypeMetaData(FieldMetaData.Decimal.PLAIN);
}
return new Field(this.postJson(
routeFieldParam, Version1.routeFieldUpdate()));
}
|
java
|
{
"resource": ""
}
|
q179318
|
RouteFieldClient.updateFieldValue
|
test
|
public Field updateFieldValue(Field routeFieldValueParam) {
if(routeFieldValueParam != null && this.serviceTicket != null) {
routeFieldValueParam.setServiceTicket(this.serviceTicket);
}
return new Field(this.postJson(
routeFieldValueParam, Version1.routeFieldUpdateValue()));
}
|
java
|
{
"resource": ""
}
|
q179319
|
RouteFieldClient.createFieldValue
|
test
|
public Field createFieldValue(
Field routeFieldValueToCreateParam,
FluidItem fluidItemParam) {
if(routeFieldValueToCreateParam != null && this.serviceTicket != null) {
routeFieldValueToCreateParam.setServiceTicket(this.serviceTicket);
}
Long fluidItmId = (fluidItemParam == null) ? null : fluidItemParam.getId();
return new Field(this.putJson(
routeFieldValueToCreateParam,
Version1.routeFieldCreateValue(fluidItmId)));
}
|
java
|
{
"resource": ""
}
|
q179320
|
ConfigurationClient.getConfigurationByKey
|
test
|
public Configuration getConfigurationByKey(String configurationKeyParam)
{
Configuration configuration = new Configuration();
configuration.setKey(configurationKeyParam);
if(this.serviceTicket != null)
{
configuration.setServiceTicket(this.serviceTicket);
}
return new Configuration(this.postJson(
configuration, WS.Path.Configuration.Version1.getByKey()));
}
|
java
|
{
"resource": ""
}
|
q179321
|
ConfigurationClient.getAllConfigurations
|
test
|
public ConfigurationListing getAllConfigurations()
{
Configuration configuration = new Configuration();
if(this.serviceTicket != null)
{
configuration.setServiceTicket(this.serviceTicket);
}
return new ConfigurationListing(this.postJson(
configuration, WS.Path.Configuration.Version1.getAllConfigurations()));
}
|
java
|
{
"resource": ""
}
|
q179322
|
AttachmentClient.createAttachment
|
test
|
public Attachment createAttachment(Attachment attachmentParam)
{
if(attachmentParam != null && this.serviceTicket != null)
{
attachmentParam.setServiceTicket(this.serviceTicket);
}
return new Attachment(this.putJson(
attachmentParam, WS.Path.Attachment.Version1.attachmentCreate()));
}
|
java
|
{
"resource": ""
}
|
q179323
|
AttachmentClient.getAttachmentById
|
test
|
public Attachment getAttachmentById(
Long attachmentIdParam,
boolean includeAttachmentDataParam)
{
Attachment attachment = new Attachment(attachmentIdParam);
if(this.serviceTicket != null)
{
attachment.setServiceTicket(this.serviceTicket);
}
return new Attachment(this.postJson(
attachment, WS.Path.Attachment.Version1.getById(
includeAttachmentDataParam)));
}
|
java
|
{
"resource": ""
}
|
q179324
|
AttachmentClient.deleteAttachment
|
test
|
public Attachment deleteAttachment(Attachment attachmentParam)
{
if(attachmentParam != null && this.serviceTicket != null)
{
attachmentParam.setServiceTicket(this.serviceTicket);
}
return new Attachment(this.postJson(
attachmentParam, WS.Path.Attachment.Version1.attachmentDelete()));
}
|
java
|
{
"resource": ""
}
|
q179325
|
AttachmentClient.forceDeleteAttachment
|
test
|
public Attachment forceDeleteAttachment(Attachment attachmentParam)
{
if(attachmentParam != null && this.serviceTicket != null)
{
attachmentParam.setServiceTicket(this.serviceTicket);
}
return new Attachment(this.postJson(
attachmentParam,
WS.Path.Attachment.Version1.attachmentDelete(true)));
}
|
java
|
{
"resource": ""
}
|
q179326
|
XsdParserJar.parseJarFile
|
test
|
private void parseJarFile(InputStream inputStream) {
//https://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/
try {
Node schemaNode = getSchemaNode(inputStream);
if (isXsdSchema(schemaNode)){
XsdSchema.parse(this, schemaNode);
} else {
throw new ParsingException("The top level element of a XSD file should be the xsd:schema node.");
}
} catch (SAXException | IOException | ParserConfigurationException e) {
Logger.getAnonymousLogger().log(Level.SEVERE, "Exception while parsing.", e);
}
}
|
java
|
{
"resource": ""
}
|
q179327
|
XsdParserJar.setClassLoader
|
test
|
private void setClassLoader(String jarPath) {
if (!jarPath.endsWith(".jar")){
throw new ParsingException("The jarPath received doesn't represent a jar file.");
}
ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
URL url = originalCl.getResource(jarPath);
if (url == null){
try {
url = new URL("file:/" + jarPath);
} catch (MalformedURLException e) {
throw new ParsingException("Invalid jar name.");
}
}
// Create class loader using given codebase
// Use prevCl as parent to maintain current visibility
ClassLoader urlCl = URLClassLoader.newInstance(new URL[]{url}, originalCl);
Thread.currentThread().setContextClassLoader(urlCl);
classLoader = urlCl;
}
|
java
|
{
"resource": ""
}
|
q179328
|
XsdGroup.rule2
|
test
|
private void rule2() {
if (!(parent instanceof XsdSchema) && name != null){
throw new ParsingException(XSD_TAG + " element: The " + NAME_TAG + " should only be used when the parent of the " + XSD_TAG + " is the " + XsdSchema.XSD_TAG + " element." );
}
}
|
java
|
{
"resource": ""
}
|
q179329
|
XsdGroup.rule3
|
test
|
private void rule3() {
if (parent instanceof XsdSchema && name == null){
throw new ParsingException(XSD_TAG + " element: The " + NAME_TAG + " should is required the parent of the " + XSD_TAG + " is the " + XsdSchema.XSD_TAG + " element." );
}
}
|
java
|
{
"resource": ""
}
|
q179330
|
XsdAttribute.rule3
|
test
|
private void rule3() {
if (attributesMap.containsKey(REF_TAG) && (simpleType != null || form != null || type != null)){
throw new ParsingException(XSD_TAG + " element: If " + REF_TAG + " attribute is present, simpleType element, form attribute and type attribute cannot be present at the same time.");
}
}
|
java
|
{
"resource": ""
}
|
q179331
|
XsdParser.getSchemaNode
|
test
|
private Node getSchemaNode(String filePath) throws IOException, SAXException, ParserConfigurationException {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(filePath);
doc.getDocumentElement().normalize();
return doc.getFirstChild();
}
|
java
|
{
"resource": ""
}
|
q179332
|
XsdElement.rule7
|
test
|
private void rule7() {
if (parent instanceof XsdSchema && attributesMap.containsKey(FORM_TAG)){
throw new ParsingException(XSD_TAG + " element: The " + FORM_TAG + " attribute can only be present when the parent of the " + xsdElementIsXsdSchema);
}
}
|
java
|
{
"resource": ""
}
|
q179333
|
XsdElement.rule3
|
test
|
private void rule3() {
if (parent instanceof XsdSchema && attributesMap.containsKey(REF_TAG)){
throw new ParsingException(XSD_TAG + " element: The " + REF_TAG + " attribute cannot be present when the parent of the " + xsdElementIsXsdSchema);
}
}
|
java
|
{
"resource": ""
}
|
q179334
|
ConvertTypeOfObject.convert
|
test
|
@Override public T convert(final Object value) {
if (value == null) {
return null;
} else if (isIterable() && Iterable.class.isAssignableFrom(value.getClass())) {
return convertIterable(value);
} else if (reflectedKlass.assignableFromObject(value)) {
return (T) value;
} else if (reflectedKlass.canBeUnboxed(value.getClass())) {
return (T) value;
} else if (reflectedKlass.canBeBoxed(value.getClass())) {
return (T) value;
}
FluentClass<?> klassToCreate;
if (reflectedKlass.isPrimitive()) {
klassToCreate = reflectedKlass.boxedType();
} else {
klassToCreate = reflectedKlass;
}
return (T) convertValueTo(value, klassToCreate);
}
|
java
|
{
"resource": ""
}
|
q179335
|
CliFactory.createCli
|
test
|
public static <O> Cli<O> createCli(final Class<O> klass) throws InvalidOptionSpecificationException
{
return new CliInterfaceImpl<O>(klass);
}
|
java
|
{
"resource": ""
}
|
q179336
|
CliFactory.createCliUsingInstance
|
test
|
public static <O> Cli<O> createCliUsingInstance(final O options) throws InvalidOptionSpecificationException
{
return new CliInstanceImpl<O>(options);
}
|
java
|
{
"resource": ""
}
|
q179337
|
CliFactory.parseArguments
|
test
|
public static <O> O parseArguments(final Class<O> klass, final String... arguments)
throws ArgumentValidationException, InvalidOptionSpecificationException
{
return createCli(klass).parseArguments(arguments);
}
|
java
|
{
"resource": ""
}
|
q179338
|
CliFactory.parseArgumentsUsingInstance
|
test
|
public static <O> O parseArgumentsUsingInstance(final O options, final String... arguments)
throws ArgumentValidationException, InvalidOptionSpecificationException
{
return createCliUsingInstance(options).parseArguments(arguments);
}
|
java
|
{
"resource": ""
}
|
q179339
|
DiscoveryApi.urlBuilder
|
test
|
Builder urlBuilder(String path) {
Builder builder =
baseUrlBuilder().addPathSegment(configuration.getApiPackage())
.addPathSegment(configuration.getApiVersion()).addPathSegment(path);
if (configuration.getPathModifier() != DiscoveryApiConfiguration.PathModifier.NONE) {
builder.addPathSegment(configuration.getPathModifier().getModifier());
}
return builder;
}
|
java
|
{
"resource": ""
}
|
q179340
|
HeaderGridView.removeFooterView
|
test
|
public boolean removeFooterView(View v) {
if (mFooterViewInfos.size() > 0) {
boolean result = false;
if (mAdapter != null && ((FooterViewGridAdapter) mAdapter).removeFooter(v)) {
notifiyChanged();
result = true;
}
removeFixedViewInfo(v, mFooterViewInfos);
return result;
}
return false;
}
|
java
|
{
"resource": ""
}
|
q179341
|
Line.getValue
|
test
|
public double getValue(double p) {
if (module == null) {
throw new NoModuleException();
}
double x = (x1 - x0) * p + x0;
double y = (y1 - y0) * p + y0;
double z = (z1 - z0) * p + z0;
double value = module.getValue(x, y, z);
if (attenuate) {
return p * (1.0 - p) * 4 * value;
} else {
return value;
}
}
|
java
|
{
"resource": ""
}
|
q179342
|
Noise.gradientNoise3D
|
test
|
public static double gradientNoise3D(double fx, double fy, double fz, int ix, int iy, int iz, int seed) {
// Randomly generate a gradient vector given the integer coordinates of the
// input value. This implementation generates a random number and uses it
// as an index into a normalized-vector lookup table.
int vectorIndex = (X_NOISE_GEN * ix + Y_NOISE_GEN * iy + Z_NOISE_GEN * iz + SEED_NOISE_GEN * seed);
vectorIndex ^= (vectorIndex >> SHIFT_NOISE_GEN);
vectorIndex &= 0xff;
double xvGradient = Utils.RANDOM_VECTORS[(vectorIndex << 2)];
double yvGradient = Utils.RANDOM_VECTORS[(vectorIndex << 2) + 1];
double zvGradient = Utils.RANDOM_VECTORS[(vectorIndex << 2) + 2];
// Set up us another vector equal to the distance between the two vectors
// passed to this function.
double xvPoint = (fx - ix);
double yvPoint = (fy - iy);
double zvPoint = (fz - iz);
// Now compute the dot product of the gradient vector with the distance
// vector. The resulting value is gradient noise. Apply a scaling and
// offset value so that this noise value ranges from 0 to 1.
return ((xvGradient * xvPoint) + (yvGradient * yvPoint) + (zvGradient * zvPoint)) + 0.5;
}
|
java
|
{
"resource": ""
}
|
q179343
|
Noise.intValueNoise3D
|
test
|
public static int intValueNoise3D(int x, int y, int z, int seed) {
// All constants are primes and must remain prime in order for this noise
// function to work correctly.
int n = (X_NOISE_GEN * x + Y_NOISE_GEN * y + Z_NOISE_GEN * z + SEED_NOISE_GEN * seed) & 0x7fffffff;
n = (n >> 13) ^ n;
return (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
}
|
java
|
{
"resource": ""
}
|
q179344
|
Noise.valueNoise3D
|
test
|
public static double valueNoise3D(int x, int y, int z, int seed) {
return intValueNoise3D(x, y, z, seed) / 2147483647.0;
}
|
java
|
{
"resource": ""
}
|
q179345
|
Utils.cubicInterp
|
test
|
public static double cubicInterp(double n0, double n1, double n2, double n3, double a) {
double p = (n3 - n2) - (n0 - n1);
double q = (n0 - n1) - p;
double r = n2 - n0;
return p * a * a * a + q * a * a + r * a + n1;
}
|
java
|
{
"resource": ""
}
|
q179346
|
Utils.sCurve5
|
test
|
public static double sCurve5(double a) {
double a3 = a * a * a;
double a4 = a3 * a;
double a5 = a4 * a;
return (6.0 * a5) - (15.0 * a4) + (10.0 * a3);
}
|
java
|
{
"resource": ""
}
|
q179347
|
Range.setBounds
|
test
|
public void setBounds(double currentLower, double currentUpper, double newLower,
double newUpper) {
if (currentLower == currentUpper) {
throw new IllegalArgumentException("currentLower must not equal currentUpper. Both are " + currentUpper);
}
if (newLower == newUpper) {
throw new IllegalArgumentException("newLowerBound must not equal newUpperBound. Both are " + newUpper);
}
currentLowerBound = currentLower;
currentUpperBound = currentUpper;
newLowerBound = newLower;
newUpperBound = newUpper;
recalculateScaleBias();
}
|
java
|
{
"resource": ""
}
|
q179348
|
PluginEventsProcessor.doProcess
|
test
|
protected void doProcess(final CloudTrailEvent event) {
for (final FullstopPlugin plugin : getPluginsForEvent(event)) {
doProcess(event, plugin);
}
}
|
java
|
{
"resource": ""
}
|
q179349
|
PluginEventsProcessor.doProcess
|
test
|
protected void doProcess(final CloudTrailEvent event, final FullstopPlugin plugin) {
try {
plugin.processEvent(event);
} catch (HystrixRuntimeException | HttpServerErrorException e) {
log.warn(e.getMessage(), e);
} catch (final Exception e) {
log.error(e.getMessage(), e);
}
}
|
java
|
{
"resource": ""
}
|
q179350
|
CloudTrailEventSupport.getAccountId
|
test
|
public static String getAccountId(final CloudTrailEvent event) {
final CloudTrailEventData eventData = getEventData(event);
final UserIdentity userIdentity = checkNotNull(eventData.getUserIdentity(), USER_IDENTITY_SHOULD_NEVER_BE_NULL);
final String value = ofNullable(userIdentity.getAccountId()).orElse(eventData.getRecipientAccountId());
return checkNotNull(value, ACCOUNT_ID_OR_RECIPIENT_SHOULD_NEVER_BE_NULL);
}
|
java
|
{
"resource": ""
}
|
q179351
|
WhitelistRulesEvaluator.apply
|
test
|
@Override
public Boolean apply(final RuleEntity ruleEntity, final ViolationEntity violationEntity) {
final List<Predicate<ViolationEntity>> predicates = newArrayList();
trimOptional(ruleEntity.getAccountId())
.map(WhitelistRulesEvaluator::accountIsEqual)
.ifPresent(predicates::add);
trimOptional(ruleEntity.getRegion())
.map(WhitelistRulesEvaluator::regionIsEqual)
.ifPresent(predicates::add);
trimOptional(ruleEntity.getViolationTypeEntityId())
.map(WhitelistRulesEvaluator::violationTypeIdIsEqual)
.ifPresent(predicates::add);
trimOptional(ruleEntity.getImageName())
.map(WhitelistRulesEvaluator::imageNameMatches)
.ifPresent(predicates::add);
trimOptional(ruleEntity.getImageOwner())
.map(WhitelistRulesEvaluator::imageOwnerIsEqual)
.ifPresent(predicates::add);
trimOptional(ruleEntity.getApplicationId())
.map(WhitelistRulesEvaluator::applicationIdIsEqual)
.ifPresent(predicates::add);
trimOptional(ruleEntity.getApplicationVersion())
.map(WhitelistRulesEvaluator::applicationVersionIsEqual)
.ifPresent(predicates::add);
trimOptional(ruleEntity.getMetaInfoJsonPath())
.map(this::metaInfoJsonPathExists)
.ifPresent(predicates::add);
final Optional<Predicate<ViolationEntity>> whiteListTest = predicates.stream().reduce(Predicate::and);
return whiteListTest.isPresent() && whiteListTest.get().test(violationEntity);
}
|
java
|
{
"resource": ""
}
|
q179352
|
FileEventReader.getEventSerializer
|
test
|
private EventSerializer getEventSerializer(final GZIPInputStream inputStream, final CloudTrailLog ctLog)
throws IOException {
final EventSerializer serializer;
if (isEnableRawEventInfo) {
final String logFileContent = new String(LibraryUtils.toByteArray(inputStream), StandardCharsets.UTF_8);
final JsonParser jsonParser = this.mapper.getFactory().createParser(logFileContent);
serializer = new RawLogDeliveryEventSerializer(logFileContent, ctLog, jsonParser);
}
else {
final JsonParser jsonParser = this.mapper.getFactory().createParser(inputStream);
serializer = new DefaultEventSerializer(ctLog, jsonParser);
}
return serializer;
}
|
java
|
{
"resource": ""
}
|
q179353
|
TemporaryFolder.createFile
|
test
|
public File createFile(String fileName) throws IOException {
Path path = Paths.get(rootFolder.getPath(), fileName);
return Files.createFile(path).toFile();
}
|
java
|
{
"resource": ""
}
|
q179354
|
TemporaryFolder.createDirectory
|
test
|
public File createDirectory(String directoryName) {
Path path = Paths.get(rootFolder.getPath(), directoryName);
try {
return Files.createDirectory(path).toFile();
} catch (IOException ex) {
throw new TemporaryFolderException(
String.format("Failed to create directory: '%s'", path.toString()), ex);
}
}
|
java
|
{
"resource": ""
}
|
q179355
|
RestoreContext.restore
|
test
|
public void restore() {
for (String propertyName : propertyNames) {
if (restoreProperties.containsKey(propertyName)) {
// reinstate the original value
System.setProperty(propertyName, restoreProperties.get(propertyName));
} else {
// remove the (previously unset) property
System.clearProperty(propertyName);
}
}
}
|
java
|
{
"resource": ""
}
|
q179356
|
LazyMap.createImplementation
|
test
|
private Map<K, V> createImplementation()
{
if (delegate instanceof HashMap == false)
return new HashMap<K, V>(delegate);
return delegate;
}
|
java
|
{
"resource": ""
}
|
q179357
|
CachedCollection.add
|
test
|
public boolean add(final Object obj) {
maintain();
SoftObject soft = SoftObject.create(obj, queue);
return collection.add(soft);
}
|
java
|
{
"resource": ""
}
|
q179358
|
Property.set
|
test
|
public static String set(String name, String value)
{
return PropertyManager.setProperty(name, value);
}
|
java
|
{
"resource": ""
}
|
q179359
|
Property.getArray
|
test
|
public static String[] getArray(String base, String[] defaultValues)
{
return PropertyManager.getArrayProperty(base, defaultValues);
}
|
java
|
{
"resource": ""
}
|
q179360
|
StateMachine.nextState
|
test
|
public State nextState(String actionName)
throws IllegalTransitionException
{
Transition t = currentState.getTransition(actionName);
if( t == null )
{
String msg = "No transition for action: '" + actionName
+ "' from state: '" + currentState.getName() + "'";
throw new IllegalTransitionException(msg);
}
State nextState = t.getTarget();
log.trace("nextState("+actionName+") = "+nextState);
currentState = nextState;
return currentState;
}
|
java
|
{
"resource": ""
}
|
q179361
|
SoftSet.processQueue
|
test
|
private void processQueue()
{
ComparableSoftReference cr;
while( (cr = (ComparableSoftReference) gcqueue.poll()) != null )
{
map.remove(cr.getKey());
}
}
|
java
|
{
"resource": ""
}
|
q179362
|
WeakTypeCache.get
|
test
|
@SuppressWarnings({"unchecked", "cast"})
public T get(Type type)
{
if (type == null)
throw new IllegalArgumentException("Null type");
if (type instanceof ParameterizedType)
return getParameterizedType((ParameterizedType) type);
else if (type instanceof Class)
return getClass((Class<?>) type);
else if (type instanceof TypeVariable)
// TODO Figure out why we need this cast with the Sun compiler?
return (T) getTypeVariable((TypeVariable) type);
else if (type instanceof GenericArrayType)
return getGenericArrayType((GenericArrayType) type);
else if (type instanceof WildcardType)
return getWildcardType((WildcardType) type);
else
throw new UnsupportedOperationException("Unknown type: " + type + " class=" + type.getClass());
}
|
java
|
{
"resource": ""
}
|
q179363
|
WeakTypeCache.getParameterizedType
|
test
|
protected T getParameterizedType(ParameterizedType type)
{
// First check if we already have it
T result = peek(type);
if (result != null)
return result;
// Instantiate
result = instantiate(type);
// Put the perlimanary result into the cache
put(type, result);
// Generate the details
generate(type, result);
return result;
}
|
java
|
{
"resource": ""
}
|
q179364
|
WeakTypeCache.getTypeVariable
|
test
|
protected <D extends GenericDeclaration> T getTypeVariable(TypeVariable<D> type)
{
// TODO JBMICROCONT-131 improve this
return get(type.getBounds()[0]);
}
|
java
|
{
"resource": ""
}
|
q179365
|
NestedRuntimeException.printStackTrace
|
test
|
public void printStackTrace(final PrintStream stream) {
if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
super.printStackTrace(stream);
}
NestedThrowable.Util.print(nested, stream);
}
|
java
|
{
"resource": ""
}
|
q179366
|
NestedRuntimeException.printStackTrace
|
test
|
public void printStackTrace(final PrintWriter writer) {
if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
super.printStackTrace(writer);
}
NestedThrowable.Util.print(nested, writer);
}
|
java
|
{
"resource": ""
}
|
q179367
|
MarshalledValueOutputStream.replaceObject
|
test
|
protected Object replaceObject(Object obj) throws IOException
{
if( (obj instanceof Remote) && !(obj instanceof RemoteStub) )
{
Remote remote = (Remote) obj;
try
{
obj = RemoteObject.toStub(remote);
}
catch(IOException ignore)
{
// Let the Serialization layer try with the orignal obj
}
}
return obj;
}
|
java
|
{
"resource": ""
}
|
q179368
|
BasicTaskWrapper.run
|
test
|
public void run()
{
// Get the execution thread
this.runThread = Thread.currentThread();
// Check for a start timeout
long runTime = getElapsedTime();
if (startTimeout > 0l && runTime >= startTimeout)
{
taskRejected(new StartTimeoutException("Start Timeout exceeded for task " + taskString));
return;
}
// We are about to start, check for a stop
boolean stopped = false;
synchronized (stateLock)
{
if (state == TASK_STOPPED)
{
stopped = true;
}
else
{
state = TASK_STARTED;
taskStarted();
if (waitType == Task.WAIT_FOR_START)
stateLock.notifyAll();
}
}
if (stopped)
{
taskRejected(new TaskStoppedException("Task stopped for task " + taskString));
return;
}
// Run the task
Throwable throwable = null;
try
{
task.execute();
}
catch (Throwable t)
{
throwable = t;
}
// It is complete
taskCompleted(throwable);
// We are completed
synchronized (stateLock)
{
state = TASK_COMPLETED;
if (waitType == Task.WAIT_FOR_COMPLETE)
stateLock.notifyAll();
}
}
|
java
|
{
"resource": ""
}
|
q179369
|
BasicTaskWrapper.setTask
|
test
|
protected void setTask(Task task)
{
if (task == null)
throw new IllegalArgumentException("Null task");
this.task = task;
this.taskString = task.toString();
this.startTime = System.currentTimeMillis();
this.waitType = task.getWaitType();
this.priority = task.getPriority();
this.startTimeout = task.getStartTimeout();
this.completionTimeout = task.getCompletionTimeout();
}
|
java
|
{
"resource": ""
}
|
q179370
|
BasicTaskWrapper.taskAccepted
|
test
|
protected boolean taskAccepted()
{
try
{
task.accepted(getElapsedTime());
return true;
}
catch (Throwable t)
{
log.warn("Unexpected error during 'accepted' for task: " + taskString, t);
return false;
}
}
|
java
|
{
"resource": ""
}
|
q179371
|
BasicTaskWrapper.taskRejected
|
test
|
protected boolean taskRejected(RuntimeException e)
{
try
{
task.rejected(getElapsedTime(), e);
return true;
}
catch (Throwable t)
{
log.warn("Unexpected error during 'rejected' for task: " + taskString, t);
if (e != null)
log.warn("Original reason for rejection of task: " + taskString, e);
return false;
}
}
|
java
|
{
"resource": ""
}
|
q179372
|
BasicTaskWrapper.taskStarted
|
test
|
protected boolean taskStarted()
{
try
{
task.started(getElapsedTime());
return true;
}
catch (Throwable t)
{
log.warn("Unexpected error during 'started' for task: " + taskString, t);
return false;
}
}
|
java
|
{
"resource": ""
}
|
q179373
|
BasicTaskWrapper.taskCompleted
|
test
|
protected boolean taskCompleted(Throwable throwable)
{
try
{
task.completed(getElapsedTime(), throwable);
return true;
}
catch (Throwable t)
{
log.warn("Unexpected error during 'completed' for task: " + taskString, t);
if (throwable != null)
log.warn("Original error during 'run' for task: " + taskString, throwable);
return false;
}
}
|
java
|
{
"resource": ""
}
|
q179374
|
BasicTaskWrapper.taskStop
|
test
|
protected boolean taskStop()
{
try
{
task.stop();
return true;
}
catch (Throwable t)
{
log.warn("Unexpected error during 'stop' for task: " + taskString, t);
return false;
}
}
|
java
|
{
"resource": ""
}
|
q179375
|
WorkerQueue.getJobImpl
|
test
|
protected Executable getJobImpl() throws InterruptedException
{
// While the queue is empty, wait();
// when notified take an event from the queue and return it.
while (m_currentJob == null) {wait();}
// This one is the job to return
JobItem item = m_currentJob;
// Go on to the next object for the next call.
m_currentJob = m_currentJob.m_next;
return item.m_job;
}
|
java
|
{
"resource": ""
}
|
q179376
|
WorkerQueue.putJobImpl
|
test
|
protected void putJobImpl(Executable job)
{
JobItem posted = new JobItem(job);
if (m_currentJob == null)
{
// The queue is empty, set the current job to process and
// wake up the thread waiting in method getJob
m_currentJob = posted;
notifyAll();
}
else
{
JobItem item = m_currentJob;
// The queue is not empty, find the end of the queue ad add the
// posted job at the end
while (item.m_next != null) {item = item.m_next;}
item.m_next = posted;
}
}
|
java
|
{
"resource": ""
}
|
q179377
|
BlockingMode.toBlockingMode
|
test
|
public static final BlockingMode toBlockingMode(String name)
{
BlockingMode mode = null;
if( name == null )
{
mode = null;
}
else if( name.equalsIgnoreCase("run") )
{
mode = RUN;
}
else if( name.equalsIgnoreCase("wait") )
{
mode = WAIT;
}
else if( name.equalsIgnoreCase("discard") )
{
mode = DISCARD;
}
else if( name.equalsIgnoreCase("discardOldest") )
{
mode = DISCARD_OLDEST;
}
else if( name.equalsIgnoreCase("abort") )
{
mode = ABORT;
}
return mode;
}
|
java
|
{
"resource": ""
}
|
q179378
|
BlockingMode.readResolve
|
test
|
Object readResolve() throws ObjectStreamException
{
// Replace the marshalled instance type with the local instance
BlockingMode mode = ABORT;
switch( type )
{
case RUN_TYPE:
mode = RUN;
break;
case WAIT_TYPE:
mode = RUN;
break;
case DISCARD_TYPE:
mode = RUN;
break;
case DISCARD_OLDEST_TYPE:
mode = RUN;
break;
case ABORT_TYPE:
mode = RUN;
break;
}
return mode;
}
|
java
|
{
"resource": ""
}
|
q179379
|
Catalog.setupReaders
|
test
|
public void setupReaders() {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(false);
SAXCatalogReader saxReader = new SAXCatalogReader(spf);
saxReader.setCatalogParser(null, "XMLCatalog",
"org.apache.xml.resolver.readers.XCatalogReader");
saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName,
"catalog",
"org.apache.xml.resolver.readers.OASISXMLCatalogReader");
addReader("application/xml", saxReader);
TR9401CatalogReader textReader = new TR9401CatalogReader();
addReader("text/plain", textReader);
}
|
java
|
{
"resource": ""
}
|
q179380
|
Catalog.addReader
|
test
|
public void addReader(String mimeType, CatalogReader reader) {
if (readerMap.containsKey(mimeType)) {
Integer pos = (Integer) readerMap.get(mimeType);
readerArr.set(pos.intValue(), reader);
} else {
readerArr.add(reader);
Integer pos = new Integer(readerArr.size()-1);
readerMap.put(mimeType, pos);
}
}
|
java
|
{
"resource": ""
}
|
q179381
|
Catalog.copyReaders
|
test
|
protected void copyReaders(Catalog newCatalog) {
// Have to copy the readers in the right order...convert hash to arr
Vector mapArr = new Vector(readerMap.size());
// Pad the mapArr out to the right length
for (int count = 0; count < readerMap.size(); count++) {
mapArr.add(null);
}
Enumeration enumt = readerMap.keys();
while (enumt.hasMoreElements()) {
String mimeType = (String) enumt.nextElement();
Integer pos = (Integer) readerMap.get(mimeType);
mapArr.set(pos.intValue(), mimeType);
}
for (int count = 0; count < mapArr.size(); count++) {
String mimeType = (String) mapArr.get(count);
Integer pos = (Integer) readerMap.get(mimeType);
newCatalog.addReader(mimeType,
(CatalogReader)
readerArr.get(pos.intValue()));
}
}
|
java
|
{
"resource": ""
}
|
q179382
|
Catalog.newCatalog
|
test
|
protected Catalog newCatalog() {
String catalogClass = this.getClass().getName();
try {
Catalog c = (Catalog) (Class.forName(catalogClass).newInstance());
c.setCatalogManager(catalogManager);
copyReaders(c);
return c;
} catch (ClassNotFoundException cnfe) {
catalogManager.debug.message(1, "Class Not Found Exception: " + catalogClass);
} catch (IllegalAccessException iae) {
catalogManager.debug.message(1, "Illegal Access Exception: " + catalogClass);
} catch (InstantiationException ie) {
catalogManager.debug.message(1, "Instantiation Exception: " + catalogClass);
} catch (ClassCastException cce) {
catalogManager.debug.message(1, "Class Cast Exception: " + catalogClass);
} catch (Exception e) {
catalogManager.debug.message(1, "Other Exception: " + catalogClass);
}
Catalog c = new Catalog();
c.setCatalogManager(catalogManager);
copyReaders(c);
return c;
}
|
java
|
{
"resource": ""
}
|
q179383
|
Catalog.loadSystemCatalogs
|
test
|
public void loadSystemCatalogs()
throws MalformedURLException, IOException {
Vector catalogs = catalogManager.getCatalogFiles();
if (catalogs != null) {
for (int count = 0; count < catalogs.size(); count++) {
catalogFiles.addElement(catalogs.elementAt(count));
}
}
if (catalogFiles.size() > 0) {
// This is a little odd. The parseCatalog() method expects
// a filename, but it adds that name to the end of the
// catalogFiles vector, and then processes that vector.
// This allows the system to handle CATALOG entries
// correctly.
//
// In this init case, we take the last element off the
// catalogFiles vector and pass it to parseCatalog. This
// will "do the right thing" in the init case, and allow
// parseCatalog() to do the right thing in the non-init
// case. Honest.
//
String catfile = (String) catalogFiles.lastElement();
catalogFiles.removeElement(catfile);
parseCatalog(catfile);
}
}
|
java
|
{
"resource": ""
}
|
q179384
|
Catalog.parseCatalog
|
test
|
public synchronized void parseCatalog(URL aUrl) throws IOException {
catalogCwd = aUrl;
base = aUrl;
default_override = catalogManager.getPreferPublic();
catalogManager.debug.message(4, "Parse catalog: " + aUrl.toString());
DataInputStream inStream = null;
boolean parsed = false;
for (int count = 0; !parsed && count < readerArr.size(); count++) {
CatalogReader reader = (CatalogReader) readerArr.get(count);
try {
inStream = new DataInputStream(aUrl.openStream());
} catch (FileNotFoundException fnfe) {
// No catalog; give up!
break;
}
try {
reader.readCatalog(this, inStream);
parsed=true;
} catch (CatalogException ce) {
if (ce.getExceptionType() == CatalogException.PARSE_FAILED) {
// give up!
break;
} else {
// try again!
}
}
try {
inStream.close();
} catch (IOException e) {
//nop
}
}
if (parsed) parsePendingCatalogs();
}
|
java
|
{
"resource": ""
}
|
q179385
|
Catalog.parsePendingCatalogs
|
test
|
protected synchronized void parsePendingCatalogs()
throws MalformedURLException, IOException {
if (!localCatalogFiles.isEmpty()) {
// Move all the localCatalogFiles into the front of
// the catalogFiles queue
Vector newQueue = new Vector();
Enumeration q = localCatalogFiles.elements();
while (q.hasMoreElements()) {
newQueue.addElement(q.nextElement());
}
// Put the rest of the catalogs on the end of the new list
for (int curCat = 0; curCat < catalogFiles.size(); curCat++) {
String catfile = (String) catalogFiles.elementAt(curCat);
newQueue.addElement(catfile);
}
catalogFiles = newQueue;
localCatalogFiles.clear();
}
// Suppose there are no catalog files to process, but the
// single catalog already parsed included some delegate
// entries? Make sure they don't get lost.
if (catalogFiles.isEmpty() && !localDelegate.isEmpty()) {
Enumeration e = localDelegate.elements();
while (e.hasMoreElements()) {
catalogEntries.addElement(e.nextElement());
}
localDelegate.clear();
}
// Now process all the files on the catalogFiles vector. This
// vector can grow during processing if CATALOG entries are
// encountered in the catalog
while (!catalogFiles.isEmpty()) {
String catfile = (String) catalogFiles.elementAt(0);
try {
catalogFiles.remove(0);
} catch (ArrayIndexOutOfBoundsException e) {
// can't happen
}
if (catalogEntries.size() == 0 && catalogs.size() == 0) {
// We haven't parsed any catalogs yet, let this
// catalog be the first...
try {
parseCatalogFile(catfile);
} catch (CatalogException ce) {
System.out.println("FIXME: " + ce.toString());
}
} else {
// This is a subordinate catalog. We save its name,
// but don't bother to load it unless it's necessary.
catalogs.addElement(catfile);
}
if (!localCatalogFiles.isEmpty()) {
// Move all the localCatalogFiles into the front of
// the catalogFiles queue
Vector newQueue = new Vector();
Enumeration q = localCatalogFiles.elements();
while (q.hasMoreElements()) {
newQueue.addElement(q.nextElement());
}
// Put the rest of the catalogs on the end of the new list
for (int curCat = 0; curCat < catalogFiles.size(); curCat++) {
catfile = (String) catalogFiles.elementAt(curCat);
newQueue.addElement(catfile);
}
catalogFiles = newQueue;
localCatalogFiles.clear();
}
if (!localDelegate.isEmpty()) {
Enumeration e = localDelegate.elements();
while (e.hasMoreElements()) {
catalogEntries.addElement(e.nextElement());
}
localDelegate.clear();
}
}
// We've parsed them all, reinit the vector...
catalogFiles.clear();
}
|
java
|
{
"resource": ""
}
|
q179386
|
Catalog.parseCatalogFile
|
test
|
protected synchronized void parseCatalogFile(String fileName)
throws MalformedURLException, IOException, CatalogException {
// The base-base is the cwd. If the catalog file is specified
// with a relative path, this assures that it gets resolved
// properly...
try {
// tack on a basename because URLs point to files not dirs
String userdir = fixSlashes(System.getProperty("user.dir"));
catalogCwd = new URL("file:" + userdir + "/basename");
} catch (MalformedURLException e) {
String userdir = fixSlashes(System.getProperty("user.dir"));
catalogManager.debug.message(1, "Malformed URL on cwd", userdir);
catalogCwd = null;
}
// The initial base URI is the location of the catalog file
try {
base = new URL(catalogCwd, fixSlashes(fileName));
} catch (MalformedURLException e) {
try {
base = new URL("file:" + fixSlashes(fileName));
} catch (MalformedURLException e2) {
catalogManager.debug.message(1, "Malformed URL on catalog filename",
fixSlashes(fileName));
base = null;
}
}
catalogManager.debug.message(2, "Loading catalog", fileName);
catalogManager.debug.message(4, "Default BASE", base.toString());
fileName = base.toString();
DataInputStream inStream = null;
boolean parsed = false;
boolean notFound = false;
for (int count = 0; !parsed && count < readerArr.size(); count++) {
CatalogReader reader = (CatalogReader) readerArr.get(count);
try {
notFound = false;
inStream = new DataInputStream(base.openStream());
} catch (FileNotFoundException fnfe) {
// No catalog; give up!
notFound = true;
break;
}
try {
reader.readCatalog(this, inStream);
parsed = true;
} catch (CatalogException ce) {
if (ce.getExceptionType() == CatalogException.PARSE_FAILED) {
// give up!
break;
} else {
// try again!
}
}
try {
inStream.close();
} catch (IOException e) {
//nop
}
}
if (!parsed) {
if (notFound) {
catalogManager.debug.message(3, "Catalog does not exist", fileName);
} else {
catalogManager.debug.message(1, "Failed to parse catalog", fileName);
}
}
}
|
java
|
{
"resource": ""
}
|
q179387
|
Catalog.unknownEntry
|
test
|
public void unknownEntry(Vector strings) {
if (strings != null && strings.size() > 0) {
String keyword = (String) strings.elementAt(0);
catalogManager.debug.message(2, "Unrecognized token parsing catalog", keyword);
}
}
|
java
|
{
"resource": ""
}
|
q179388
|
Catalog.parseAllCatalogs
|
test
|
public void parseAllCatalogs()
throws MalformedURLException, IOException {
// Parse all the subordinate catalogs
for (int catPos = 0; catPos < catalogs.size(); catPos++) {
Catalog c = null;
try {
c = (Catalog) catalogs.elementAt(catPos);
} catch (ClassCastException e) {
String catfile = (String) catalogs.elementAt(catPos);
c = newCatalog();
c.parseCatalog(catfile);
catalogs.setElementAt(c, catPos);
c.parseAllCatalogs();
}
}
// Parse all the DELEGATE catalogs
Enumeration enumt = catalogEntries.elements();
while (enumt.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) enumt.nextElement();
if (e.getEntryType() == DELEGATE_PUBLIC
|| e.getEntryType() == DELEGATE_SYSTEM
|| e.getEntryType() == DELEGATE_URI) {
Catalog dcat = newCatalog();
dcat.parseCatalog(e.getEntryArg(1));
}
}
}
|
java
|
{
"resource": ""
}
|
q179389
|
Catalog.resolveDoctype
|
test
|
public String resolveDoctype(String entityName,
String publicId,
String systemId)
throws MalformedURLException, IOException {
String resolved = null;
catalogManager.debug.message(3, "resolveDoctype("
+entityName+","+publicId+","+systemId+")");
systemId = normalizeURI(systemId);
if (publicId != null && publicId.startsWith("urn:publicid:")) {
publicId = PublicId.decodeURN(publicId);
}
if (systemId != null && systemId.startsWith("urn:publicid:")) {
systemId = PublicId.decodeURN(systemId);
if (publicId != null && !publicId.equals(systemId)) {
catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier");
systemId = null;
} else {
publicId = systemId;
systemId = null;
}
}
if (systemId != null) {
// If there's a SYSTEM entry in this catalog, use it
resolved = resolveLocalSystem(systemId);
if (resolved != null) {
return resolved;
}
}
if (publicId != null) {
// If there's a PUBLIC entry in this catalog, use it
resolved = resolveLocalPublic(DOCTYPE,
entityName,
publicId,
systemId);
if (resolved != null) {
return resolved;
}
}
// If there's a DOCTYPE entry in this catalog, use it
boolean over = default_override;
Enumeration enumt = catalogEntries.elements();
while (enumt.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) enumt.nextElement();
if (e.getEntryType() == OVERRIDE) {
over = e.getEntryArg(0).equalsIgnoreCase("YES");
continue;
}
if (e.getEntryType() == DOCTYPE
&& e.getEntryArg(0).equals(entityName)) {
if (over || systemId == null) {
return e.getEntryArg(1);
}
}
}
// Otherwise, look in the subordinate catalogs
return resolveSubordinateCatalogs(DOCTYPE,
entityName,
publicId,
systemId);
}
|
java
|
{
"resource": ""
}
|
q179390
|
Catalog.resolveDocument
|
test
|
public String resolveDocument()
throws MalformedURLException, IOException {
// If there's a DOCUMENT entry, return it
catalogManager.debug.message(3, "resolveDocument");
Enumeration enumt = catalogEntries.elements();
while (enumt.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) enumt.nextElement();
if (e.getEntryType() == DOCUMENT) {
return e.getEntryArg(1); //FIXME check this
}
}
return resolveSubordinateCatalogs(DOCUMENT,
null, null, null);
}
|
java
|
{
"resource": ""
}
|
q179391
|
Catalog.resolveSystem
|
test
|
public String resolveSystem(String systemId)
throws MalformedURLException, IOException {
catalogManager.debug.message(3, "resolveSystem("+systemId+")");
systemId = normalizeURI(systemId);
if (systemId != null && systemId.startsWith("urn:publicid:")) {
systemId = PublicId.decodeURN(systemId);
return resolvePublic(systemId, null);
}
// If there's a SYSTEM entry in this catalog, use it
if (systemId != null) {
String resolved = resolveLocalSystem(systemId);
if (resolved != null) {
return resolved;
}
}
// Otherwise, look in the subordinate catalogs
return resolveSubordinateCatalogs(SYSTEM,
null,
null,
systemId);
}
|
java
|
{
"resource": ""
}
|
q179392
|
Catalog.resolveLocalURI
|
test
|
protected String resolveLocalURI(String uri)
throws MalformedURLException, IOException {
Enumeration enumt = catalogEntries.elements();
while (enumt.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) enumt.nextElement();
if (e.getEntryType() == URI
&& (e.getEntryArg(0).equals(uri))) {
return e.getEntryArg(1);
}
}
// If there's a REWRITE_URI entry in this catalog, use it
enumt = catalogEntries.elements();
String startString = null;
String prefix = null;
while (enumt.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) enumt.nextElement();
if (e.getEntryType() == REWRITE_URI) {
String p = e.getEntryArg(0);
if (p.length() <= uri.length()
&& p.equals(uri.substring(0, p.length()))) {
// Is this the longest prefix?
if (startString == null
|| p.length() > startString.length()) {
startString = p;
prefix = e.getEntryArg(1);
}
}
}
if (prefix != null) {
// return the systemId with the new prefix
return prefix + uri.substring(startString.length());
}
}
// If there's a DELEGATE_URI entry in this catalog, use it
enumt = catalogEntries.elements();
Vector delCats = new Vector();
while (enumt.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) enumt.nextElement();
if (e.getEntryType() == DELEGATE_URI) {
String p = e.getEntryArg(0);
if (p.length() <= uri.length()
&& p.equals(uri.substring(0, p.length()))) {
// delegate this match to the other catalog
delCats.addElement(e.getEntryArg(1));
}
}
}
if (delCats.size() > 0) {
Enumeration enumCats = delCats.elements();
if (catalogManager.debug.getDebug() > 1) {
catalogManager.debug.message(2, "Switching to delegated catalog(s):");
while (enumCats.hasMoreElements()) {
String delegatedCatalog = (String) enumCats.nextElement();
catalogManager.debug.message(2, "\t" + delegatedCatalog);
}
}
Catalog dcat = newCatalog();
enumCats = delCats.elements();
while (enumCats.hasMoreElements()) {
String delegatedCatalog = (String) enumCats.nextElement();
dcat.parseCatalog(delegatedCatalog);
}
return dcat.resolveURI(uri);
}
return null;
}
|
java
|
{
"resource": ""
}
|
q179393
|
Catalog.resolveSubordinateCatalogs
|
test
|
protected synchronized String resolveSubordinateCatalogs(int entityType,
String entityName,
String publicId,
String systemId)
throws MalformedURLException, IOException {
for (int catPos = 0; catPos < catalogs.size(); catPos++) {
Catalog c = null;
try {
c = (Catalog) catalogs.elementAt(catPos);
} catch (ClassCastException e) {
String catfile = (String) catalogs.elementAt(catPos);
c = newCatalog();
try {
c.parseCatalog(catfile);
} catch (MalformedURLException mue) {
catalogManager.debug.message(1, "Malformed Catalog URL", catfile);
} catch (FileNotFoundException fnfe) {
catalogManager.debug.message(1, "Failed to load catalog, file not found",
catfile);
} catch (IOException ioe) {
catalogManager.debug.message(1, "Failed to load catalog, I/O error", catfile);
}
catalogs.setElementAt(c, catPos);
}
String resolved = null;
// Ok, now what are we supposed to call here?
if (entityType == DOCTYPE) {
resolved = c.resolveDoctype(entityName,
publicId,
systemId);
} else if (entityType == DOCUMENT) {
resolved = c.resolveDocument();
} else if (entityType == ENTITY) {
resolved = c.resolveEntity(entityName,
publicId,
systemId);
} else if (entityType == NOTATION) {
resolved = c.resolveNotation(entityName,
publicId,
systemId);
} else if (entityType == PUBLIC) {
resolved = c.resolvePublic(publicId, systemId);
} else if (entityType == SYSTEM) {
resolved = c.resolveSystem(systemId);
} else if (entityType == URI) {
resolved = c.resolveURI(systemId);
}
if (resolved != null) {
return resolved;
}
}
return null;
}
|
java
|
{
"resource": ""
}
|
q179394
|
Catalog.makeAbsolute
|
test
|
protected String makeAbsolute(String sysid) {
URL local = null;
sysid = fixSlashes(sysid);
try {
local = new URL(base, sysid);
} catch (MalformedURLException e) {
catalogManager.debug.message(1, "Malformed URL on system identifier", sysid);
}
if (local != null) {
return local.toString();
} else {
return sysid;
}
}
|
java
|
{
"resource": ""
}
|
q179395
|
Catalog.normalizeURI
|
test
|
protected String normalizeURI(String uriref) {
String newRef = "";
byte[] bytes;
if (uriref == null) {
return null;
}
try {
bytes = uriref.getBytes("UTF-8");
} catch (UnsupportedEncodingException uee) {
// this can't happen
catalogManager.debug.message(1, "UTF-8 is an unsupported encoding!?");
return uriref;
}
for (int count = 0; count < bytes.length; count++) {
int ch = bytes[count] & 0xFF;
if ((ch <= 0x20) // ctrl
|| (ch > 0x7F) // high ascii
|| (ch == 0x22) // "
|| (ch == 0x3C) // <
|| (ch == 0x3E) // >
|| (ch == 0x5C) // \
|| (ch == 0x5E) // ^
|| (ch == 0x60) // `
|| (ch == 0x7B) // {
|| (ch == 0x7C) // |
|| (ch == 0x7D) // }
|| (ch == 0x7F)) {
newRef += encodedByte(ch);
} else {
newRef += (char) bytes[count];
}
}
return newRef;
}
|
java
|
{
"resource": ""
}
|
q179396
|
Catalog.encodedByte
|
test
|
protected String encodedByte (int b) {
String hex = Integer.toHexString(b).toUpperCase();
if (hex.length() < 2) {
return "%0" + hex;
} else {
return "%" + hex;
}
}
|
java
|
{
"resource": ""
}
|
q179397
|
Catalog.addDelegate
|
test
|
protected void addDelegate(CatalogEntry entry) {
int pos = 0;
String partial = entry.getEntryArg(0);
Enumeration local = localDelegate.elements();
while (local.hasMoreElements()) {
CatalogEntry dpe = (CatalogEntry) local.nextElement();
String dp = dpe.getEntryArg(0);
if (dp.equals(partial)) {
// we already have this prefix
return;
}
if (dp.length() > partial.length()) {
pos++;
}
if (dp.length() < partial.length()) {
break;
}
}
// now insert partial into the vector at [pos]
if (localDelegate.size() == 0) {
localDelegate.addElement(entry);
} else {
localDelegate.insertElementAt(entry, pos);
}
}
|
java
|
{
"resource": ""
}
|
q179398
|
SoftValueRef.create
|
test
|
static <K, V> SoftValueRef<K, V> create(K key, V val, ReferenceQueue<V> q)
{
if (val == null)
return null;
else
return new SoftValueRef<K, V>(key, val, q);
}
|
java
|
{
"resource": ""
}
|
q179399
|
ThrowableHandler.fireOnThrowable
|
test
|
protected static void fireOnThrowable(int type, Throwable t) {
Object[] list = listeners.toArray();
for (int i=0; i<list.length; i++) {
((ThrowableListener)list[i]).onThrowable(type, t);
}
}
|
java
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.