id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
160,300 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/feature/EventFeatureImpl.java
|
EventFeatureImpl.detectWSAddressingFeature
|
private boolean detectWSAddressingFeature(InterceptorProvider provider, Bus bus) {
//detect on the bus level
if (bus.getFeatures() != null) {
Iterator<Feature> busFeatures = bus.getFeatures().iterator();
while (busFeatures.hasNext()) {
Feature busFeature = busFeatures.next();
if (busFeature instanceof WSAddressingFeature) {
return true;
}
}
}
//detect on the endpoint/client level
Iterator<Interceptor<? extends Message>> interceptors = provider.getInInterceptors().iterator();
while (interceptors.hasNext()) {
Interceptor<? extends Message> ic = interceptors.next();
if (ic instanceof MAPAggregator) {
return true;
}
}
return false;
}
|
java
|
private boolean detectWSAddressingFeature(InterceptorProvider provider, Bus bus) {
//detect on the bus level
if (bus.getFeatures() != null) {
Iterator<Feature> busFeatures = bus.getFeatures().iterator();
while (busFeatures.hasNext()) {
Feature busFeature = busFeatures.next();
if (busFeature instanceof WSAddressingFeature) {
return true;
}
}
}
//detect on the endpoint/client level
Iterator<Interceptor<? extends Message>> interceptors = provider.getInInterceptors().iterator();
while (interceptors.hasNext()) {
Interceptor<? extends Message> ic = interceptors.next();
if (ic instanceof MAPAggregator) {
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"detectWSAddressingFeature",
"(",
"InterceptorProvider",
"provider",
",",
"Bus",
"bus",
")",
"{",
"//detect on the bus level",
"if",
"(",
"bus",
".",
"getFeatures",
"(",
")",
"!=",
"null",
")",
"{",
"Iterator",
"<",
"Feature",
">",
"busFeatures",
"=",
"bus",
".",
"getFeatures",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"busFeatures",
".",
"hasNext",
"(",
")",
")",
"{",
"Feature",
"busFeature",
"=",
"busFeatures",
".",
"next",
"(",
")",
";",
"if",
"(",
"busFeature",
"instanceof",
"WSAddressingFeature",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"//detect on the endpoint/client level",
"Iterator",
"<",
"Interceptor",
"<",
"?",
"extends",
"Message",
">",
">",
"interceptors",
"=",
"provider",
".",
"getInInterceptors",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"interceptors",
".",
"hasNext",
"(",
")",
")",
"{",
"Interceptor",
"<",
"?",
"extends",
"Message",
">",
"ic",
"=",
"interceptors",
".",
"next",
"(",
")",
";",
"if",
"(",
"ic",
"instanceof",
"MAPAggregator",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
detect if WS Addressing feature already enabled.
@param provider the interceptor provider
@param bus the bus
@return true, if successful
|
[
"detect",
"if",
"WS",
"Addressing",
"feature",
"already",
"enabled",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/feature/EventFeatureImpl.java#L181-L203
|
160,301 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/feature/EventFeatureImpl.java
|
EventFeatureImpl.addWSAddressingInterceptors
|
private void addWSAddressingInterceptors(InterceptorProvider provider) {
MAPAggregator mapAggregator = new MAPAggregator();
MAPCodec mapCodec = new MAPCodec();
provider.getInInterceptors().add(mapAggregator);
provider.getInInterceptors().add(mapCodec);
provider.getOutInterceptors().add(mapAggregator);
provider.getOutInterceptors().add(mapCodec);
provider.getInFaultInterceptors().add(mapAggregator);
provider.getInFaultInterceptors().add(mapCodec);
provider.getOutFaultInterceptors().add(mapAggregator);
provider.getOutFaultInterceptors().add(mapCodec);
}
|
java
|
private void addWSAddressingInterceptors(InterceptorProvider provider) {
MAPAggregator mapAggregator = new MAPAggregator();
MAPCodec mapCodec = new MAPCodec();
provider.getInInterceptors().add(mapAggregator);
provider.getInInterceptors().add(mapCodec);
provider.getOutInterceptors().add(mapAggregator);
provider.getOutInterceptors().add(mapCodec);
provider.getInFaultInterceptors().add(mapAggregator);
provider.getInFaultInterceptors().add(mapCodec);
provider.getOutFaultInterceptors().add(mapAggregator);
provider.getOutFaultInterceptors().add(mapCodec);
}
|
[
"private",
"void",
"addWSAddressingInterceptors",
"(",
"InterceptorProvider",
"provider",
")",
"{",
"MAPAggregator",
"mapAggregator",
"=",
"new",
"MAPAggregator",
"(",
")",
";",
"MAPCodec",
"mapCodec",
"=",
"new",
"MAPCodec",
"(",
")",
";",
"provider",
".",
"getInInterceptors",
"(",
")",
".",
"add",
"(",
"mapAggregator",
")",
";",
"provider",
".",
"getInInterceptors",
"(",
")",
".",
"add",
"(",
"mapCodec",
")",
";",
"provider",
".",
"getOutInterceptors",
"(",
")",
".",
"add",
"(",
"mapAggregator",
")",
";",
"provider",
".",
"getOutInterceptors",
"(",
")",
".",
"add",
"(",
"mapCodec",
")",
";",
"provider",
".",
"getInFaultInterceptors",
"(",
")",
".",
"add",
"(",
"mapAggregator",
")",
";",
"provider",
".",
"getInFaultInterceptors",
"(",
")",
".",
"add",
"(",
"mapCodec",
")",
";",
"provider",
".",
"getOutFaultInterceptors",
"(",
")",
".",
"add",
"(",
"mapAggregator",
")",
";",
"provider",
".",
"getOutFaultInterceptors",
"(",
")",
".",
"add",
"(",
"mapCodec",
")",
";",
"}"
] |
Add WSAddressing Interceptors to InterceptorProvider, in order to using
AddressingProperties to get MessageID.
@param provider the interceptor provider
|
[
"Add",
"WSAddressing",
"Interceptors",
"to",
"InterceptorProvider",
"in",
"order",
"to",
"using",
"AddressingProperties",
"to",
"get",
"MessageID",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/feature/EventFeatureImpl.java#L211-L226
|
160,302 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdSoapCodec.java
|
FlowIdSoapCodec.readFlowId
|
public static String readFlowId(Message message) {
if (!(message instanceof SoapMessage)) {
return null;
}
String flowId = null;
Header hdFlowId = ((SoapMessage)message).getHeader(FLOW_ID_QNAME);
if (hdFlowId != null) {
if (hdFlowId.getObject() instanceof String) {
flowId = (String)hdFlowId.getObject();
} else if (hdFlowId.getObject() instanceof Node) {
Node headerNode = (Node)hdFlowId.getObject();
flowId = headerNode.getTextContent();
} else {
LOG.warning("Found FlowId soap header but value is not a String or a Node! Value: "
+ hdFlowId.getObject().toString());
}
}
return flowId;
}
|
java
|
public static String readFlowId(Message message) {
if (!(message instanceof SoapMessage)) {
return null;
}
String flowId = null;
Header hdFlowId = ((SoapMessage)message).getHeader(FLOW_ID_QNAME);
if (hdFlowId != null) {
if (hdFlowId.getObject() instanceof String) {
flowId = (String)hdFlowId.getObject();
} else if (hdFlowId.getObject() instanceof Node) {
Node headerNode = (Node)hdFlowId.getObject();
flowId = headerNode.getTextContent();
} else {
LOG.warning("Found FlowId soap header but value is not a String or a Node! Value: "
+ hdFlowId.getObject().toString());
}
}
return flowId;
}
|
[
"public",
"static",
"String",
"readFlowId",
"(",
"Message",
"message",
")",
"{",
"if",
"(",
"!",
"(",
"message",
"instanceof",
"SoapMessage",
")",
")",
"{",
"return",
"null",
";",
"}",
"String",
"flowId",
"=",
"null",
";",
"Header",
"hdFlowId",
"=",
"(",
"(",
"SoapMessage",
")",
"message",
")",
".",
"getHeader",
"(",
"FLOW_ID_QNAME",
")",
";",
"if",
"(",
"hdFlowId",
"!=",
"null",
")",
"{",
"if",
"(",
"hdFlowId",
".",
"getObject",
"(",
")",
"instanceof",
"String",
")",
"{",
"flowId",
"=",
"(",
"String",
")",
"hdFlowId",
".",
"getObject",
"(",
")",
";",
"}",
"else",
"if",
"(",
"hdFlowId",
".",
"getObject",
"(",
")",
"instanceof",
"Node",
")",
"{",
"Node",
"headerNode",
"=",
"(",
"Node",
")",
"hdFlowId",
".",
"getObject",
"(",
")",
";",
"flowId",
"=",
"headerNode",
".",
"getTextContent",
"(",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"warning",
"(",
"\"Found FlowId soap header but value is not a String or a Node! Value: \"",
"+",
"hdFlowId",
".",
"getObject",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"return",
"flowId",
";",
"}"
] |
Read flow id.
@param message the message
@return flow id from the message
|
[
"Read",
"flow",
"id",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdSoapCodec.java#L55-L73
|
160,303 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdSoapCodec.java
|
FlowIdSoapCodec.writeFlowId
|
public static void writeFlowId(Message message, String flowId) {
if (!(message instanceof SoapMessage)) {
return;
}
SoapMessage soapMessage = (SoapMessage)message;
Header hdFlowId = soapMessage.getHeader(FLOW_ID_QNAME);
if (hdFlowId != null) {
LOG.warning("FlowId already existing in soap header, need not to write FlowId header.");
return;
}
try {
soapMessage.getHeaders().add(
new Header(FLOW_ID_QNAME, flowId, new JAXBDataBinding(String.class)));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Stored flowId '" + flowId + "' in soap header: " + FLOW_ID_QNAME);
}
} catch (JAXBException e) {
LOG.log(Level.SEVERE, "Couldn't create flowId header.", e);
}
}
|
java
|
public static void writeFlowId(Message message, String flowId) {
if (!(message instanceof SoapMessage)) {
return;
}
SoapMessage soapMessage = (SoapMessage)message;
Header hdFlowId = soapMessage.getHeader(FLOW_ID_QNAME);
if (hdFlowId != null) {
LOG.warning("FlowId already existing in soap header, need not to write FlowId header.");
return;
}
try {
soapMessage.getHeaders().add(
new Header(FLOW_ID_QNAME, flowId, new JAXBDataBinding(String.class)));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Stored flowId '" + flowId + "' in soap header: " + FLOW_ID_QNAME);
}
} catch (JAXBException e) {
LOG.log(Level.SEVERE, "Couldn't create flowId header.", e);
}
}
|
[
"public",
"static",
"void",
"writeFlowId",
"(",
"Message",
"message",
",",
"String",
"flowId",
")",
"{",
"if",
"(",
"!",
"(",
"message",
"instanceof",
"SoapMessage",
")",
")",
"{",
"return",
";",
"}",
"SoapMessage",
"soapMessage",
"=",
"(",
"SoapMessage",
")",
"message",
";",
"Header",
"hdFlowId",
"=",
"soapMessage",
".",
"getHeader",
"(",
"FLOW_ID_QNAME",
")",
";",
"if",
"(",
"hdFlowId",
"!=",
"null",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"FlowId already existing in soap header, need not to write FlowId header.\"",
")",
";",
"return",
";",
"}",
"try",
"{",
"soapMessage",
".",
"getHeaders",
"(",
")",
".",
"add",
"(",
"new",
"Header",
"(",
"FLOW_ID_QNAME",
",",
"flowId",
",",
"new",
"JAXBDataBinding",
"(",
"String",
".",
"class",
")",
")",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"Stored flowId '\"",
"+",
"flowId",
"+",
"\"' in soap header: \"",
"+",
"FLOW_ID_QNAME",
")",
";",
"}",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Couldn't create flowId header.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Write flow id to message.
@param message the message
@param flowId the flow id
|
[
"Write",
"flow",
"id",
"to",
"message",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdSoapCodec.java#L81-L102
|
160,304 |
Talend/tesb-rt-se
|
security-common/src/main/java/org/talend/esb/security/saml/STSClientUtils.java
|
STSClientUtils.createSTSX509Client
|
public static STSClient createSTSX509Client(Bus bus, Map<String, String> stsProps) {
final STSClient stsClient = createClient(bus, stsProps);
stsClient.setWsdlLocation(stsProps.get(STS_X509_WSDL_LOCATION));
stsClient.setEndpointQName(new QName(stsProps.get(STS_NAMESPACE), stsProps.get(STS_X509_ENDPOINT_NAME)));
return stsClient;
}
|
java
|
public static STSClient createSTSX509Client(Bus bus, Map<String, String> stsProps) {
final STSClient stsClient = createClient(bus, stsProps);
stsClient.setWsdlLocation(stsProps.get(STS_X509_WSDL_LOCATION));
stsClient.setEndpointQName(new QName(stsProps.get(STS_NAMESPACE), stsProps.get(STS_X509_ENDPOINT_NAME)));
return stsClient;
}
|
[
"public",
"static",
"STSClient",
"createSTSX509Client",
"(",
"Bus",
"bus",
",",
"Map",
"<",
"String",
",",
"String",
">",
"stsProps",
")",
"{",
"final",
"STSClient",
"stsClient",
"=",
"createClient",
"(",
"bus",
",",
"stsProps",
")",
";",
"stsClient",
".",
"setWsdlLocation",
"(",
"stsProps",
".",
"get",
"(",
"STS_X509_WSDL_LOCATION",
")",
")",
";",
"stsClient",
".",
"setEndpointQName",
"(",
"new",
"QName",
"(",
"stsProps",
".",
"get",
"(",
"STS_NAMESPACE",
")",
",",
"stsProps",
".",
"get",
"(",
"STS_X509_ENDPOINT_NAME",
")",
")",
")",
";",
"return",
"stsClient",
";",
"}"
] |
for bpm connector
|
[
"for",
"bpm",
"connector"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/security-common/src/main/java/org/talend/esb/security/saml/STSClientUtils.java#L70-L77
|
160,305 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/SingleBusLocatorRegistrar.java
|
SingleBusLocatorRegistrar.isSecuredByPolicy
|
private boolean isSecuredByPolicy(Server server) {
boolean isSecured = false;
EndpointInfo ei = server.getEndpoint().getEndpointInfo();
PolicyEngine pe = bus.getExtension(PolicyEngine.class);
if (null == pe) {
LOG.finest("No Policy engine found");
return isSecured;
}
Destination destination = server.getDestination();
EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination, null);
Collection<Assertion> assertions = ep.getChosenAlternative();
for (Assertion a : assertions) {
if (a instanceof TransportBinding) {
TransportBinding tb = (TransportBinding) a;
TransportToken tt = tb.getTransportToken();
AbstractToken t = tt.getToken();
if (t instanceof HttpsToken) {
isSecured = true;
break;
}
}
}
Policy policy = ep.getPolicy();
List<PolicyComponent> pcList = policy.getPolicyComponents();
for (PolicyComponent a : pcList) {
if (a instanceof TransportBinding) {
TransportBinding tb = (TransportBinding) a;
TransportToken tt = tb.getTransportToken();
AbstractToken t = tt.getToken();
if (t instanceof HttpsToken) {
isSecured = true;
break;
}
}
}
return isSecured;
}
|
java
|
private boolean isSecuredByPolicy(Server server) {
boolean isSecured = false;
EndpointInfo ei = server.getEndpoint().getEndpointInfo();
PolicyEngine pe = bus.getExtension(PolicyEngine.class);
if (null == pe) {
LOG.finest("No Policy engine found");
return isSecured;
}
Destination destination = server.getDestination();
EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination, null);
Collection<Assertion> assertions = ep.getChosenAlternative();
for (Assertion a : assertions) {
if (a instanceof TransportBinding) {
TransportBinding tb = (TransportBinding) a;
TransportToken tt = tb.getTransportToken();
AbstractToken t = tt.getToken();
if (t instanceof HttpsToken) {
isSecured = true;
break;
}
}
}
Policy policy = ep.getPolicy();
List<PolicyComponent> pcList = policy.getPolicyComponents();
for (PolicyComponent a : pcList) {
if (a instanceof TransportBinding) {
TransportBinding tb = (TransportBinding) a;
TransportToken tt = tb.getTransportToken();
AbstractToken t = tt.getToken();
if (t instanceof HttpsToken) {
isSecured = true;
break;
}
}
}
return isSecured;
}
|
[
"private",
"boolean",
"isSecuredByPolicy",
"(",
"Server",
"server",
")",
"{",
"boolean",
"isSecured",
"=",
"false",
";",
"EndpointInfo",
"ei",
"=",
"server",
".",
"getEndpoint",
"(",
")",
".",
"getEndpointInfo",
"(",
")",
";",
"PolicyEngine",
"pe",
"=",
"bus",
".",
"getExtension",
"(",
"PolicyEngine",
".",
"class",
")",
";",
"if",
"(",
"null",
"==",
"pe",
")",
"{",
"LOG",
".",
"finest",
"(",
"\"No Policy engine found\"",
")",
";",
"return",
"isSecured",
";",
"}",
"Destination",
"destination",
"=",
"server",
".",
"getDestination",
"(",
")",
";",
"EndpointPolicy",
"ep",
"=",
"pe",
".",
"getServerEndpointPolicy",
"(",
"ei",
",",
"destination",
",",
"null",
")",
";",
"Collection",
"<",
"Assertion",
">",
"assertions",
"=",
"ep",
".",
"getChosenAlternative",
"(",
")",
";",
"for",
"(",
"Assertion",
"a",
":",
"assertions",
")",
"{",
"if",
"(",
"a",
"instanceof",
"TransportBinding",
")",
"{",
"TransportBinding",
"tb",
"=",
"(",
"TransportBinding",
")",
"a",
";",
"TransportToken",
"tt",
"=",
"tb",
".",
"getTransportToken",
"(",
")",
";",
"AbstractToken",
"t",
"=",
"tt",
".",
"getToken",
"(",
")",
";",
"if",
"(",
"t",
"instanceof",
"HttpsToken",
")",
"{",
"isSecured",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"Policy",
"policy",
"=",
"ep",
".",
"getPolicy",
"(",
")",
";",
"List",
"<",
"PolicyComponent",
">",
"pcList",
"=",
"policy",
".",
"getPolicyComponents",
"(",
")",
";",
"for",
"(",
"PolicyComponent",
"a",
":",
"pcList",
")",
"{",
"if",
"(",
"a",
"instanceof",
"TransportBinding",
")",
"{",
"TransportBinding",
"tb",
"=",
"(",
"TransportBinding",
")",
"a",
";",
"TransportToken",
"tt",
"=",
"tb",
".",
"getTransportToken",
"(",
")",
";",
"AbstractToken",
"t",
"=",
"tt",
".",
"getToken",
"(",
")",
";",
"if",
"(",
"t",
"instanceof",
"HttpsToken",
")",
"{",
"isSecured",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"return",
"isSecured",
";",
"}"
] |
Is the transport secured by a policy
|
[
"Is",
"the",
"transport",
"secured",
"by",
"a",
"policy"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/SingleBusLocatorRegistrar.java#L247-L288
|
160,306 |
Talend/tesb-rt-se
|
locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/SingleBusLocatorRegistrar.java
|
SingleBusLocatorRegistrar.isSecuredByProperty
|
private boolean isSecuredByProperty(Server server) {
boolean isSecured = false;
Object value = server.getEndpoint().get("org.talend.tesb.endpoint.secured"); //Property name TBD
if (value instanceof String) {
try {
isSecured = Boolean.valueOf((String) value);
} catch (Exception ex) {
}
}
return isSecured;
}
|
java
|
private boolean isSecuredByProperty(Server server) {
boolean isSecured = false;
Object value = server.getEndpoint().get("org.talend.tesb.endpoint.secured"); //Property name TBD
if (value instanceof String) {
try {
isSecured = Boolean.valueOf((String) value);
} catch (Exception ex) {
}
}
return isSecured;
}
|
[
"private",
"boolean",
"isSecuredByProperty",
"(",
"Server",
"server",
")",
"{",
"boolean",
"isSecured",
"=",
"false",
";",
"Object",
"value",
"=",
"server",
".",
"getEndpoint",
"(",
")",
".",
"get",
"(",
"\"org.talend.tesb.endpoint.secured\"",
")",
";",
"//Property name TBD",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"try",
"{",
"isSecured",
"=",
"Boolean",
".",
"valueOf",
"(",
"(",
"String",
")",
"value",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"}",
"return",
"isSecured",
";",
"}"
] |
Is the transport secured by a JAX-WS property
|
[
"Is",
"the",
"transport",
"secured",
"by",
"a",
"JAX",
"-",
"WS",
"property"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator/src/main/java/org/talend/esb/servicelocator/cxf/internal/SingleBusLocatorRegistrar.java#L293-L305
|
160,307 |
Talend/tesb-rt-se
|
sam/sam-server/src/main/java/org/talend/esb/sam/server/persistence/EventRepositoryImpl.java
|
EventRepositoryImpl.writeCustomInfo
|
private void writeCustomInfo(Event event) {
// insert customInfo (key/value) into DB
for (Map.Entry<String, String> customInfo : event.getCustomInfo().entrySet()) {
long cust_id = dbDialect.getIncrementer().nextLongValue();
getJdbcTemplate()
.update("insert into EVENTS_CUSTOMINFO (ID, EVENT_ID, CUST_KEY, CUST_VALUE)"
+ " values (?,?,?,?)",
cust_id, event.getPersistedId(), customInfo.getKey(), customInfo.getValue());
}
}
|
java
|
private void writeCustomInfo(Event event) {
// insert customInfo (key/value) into DB
for (Map.Entry<String, String> customInfo : event.getCustomInfo().entrySet()) {
long cust_id = dbDialect.getIncrementer().nextLongValue();
getJdbcTemplate()
.update("insert into EVENTS_CUSTOMINFO (ID, EVENT_ID, CUST_KEY, CUST_VALUE)"
+ " values (?,?,?,?)",
cust_id, event.getPersistedId(), customInfo.getKey(), customInfo.getValue());
}
}
|
[
"private",
"void",
"writeCustomInfo",
"(",
"Event",
"event",
")",
"{",
"// insert customInfo (key/value) into DB",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"customInfo",
":",
"event",
".",
"getCustomInfo",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"long",
"cust_id",
"=",
"dbDialect",
".",
"getIncrementer",
"(",
")",
".",
"nextLongValue",
"(",
")",
";",
"getJdbcTemplate",
"(",
")",
".",
"update",
"(",
"\"insert into EVENTS_CUSTOMINFO (ID, EVENT_ID, CUST_KEY, CUST_VALUE)\"",
"+",
"\" values (?,?,?,?)\"",
",",
"cust_id",
",",
"event",
".",
"getPersistedId",
"(",
")",
",",
"customInfo",
".",
"getKey",
"(",
")",
",",
"customInfo",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
write CustomInfo list into table.
@param event the event
|
[
"write",
"CustomInfo",
"list",
"into",
"table",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-server/src/main/java/org/talend/esb/sam/server/persistence/EventRepositoryImpl.java#L115-L124
|
160,308 |
Talend/tesb-rt-se
|
sam/sam-server/src/main/java/org/talend/esb/sam/server/persistence/EventRepositoryImpl.java
|
EventRepositoryImpl.readCustomInfo
|
private Map<String, String> readCustomInfo(long eventId) {
List<Map<String, Object>> rows = getJdbcTemplate()
.queryForList("select * from EVENTS_CUSTOMINFO where EVENT_ID=" + eventId);
Map<String, String> customInfo = new HashMap<String, String>(rows.size());
for (Map<String, Object> row : rows) {
customInfo.put((String)row.get("CUST_KEY"), (String)row.get("CUST_VALUE"));
}
return customInfo;
}
|
java
|
private Map<String, String> readCustomInfo(long eventId) {
List<Map<String, Object>> rows = getJdbcTemplate()
.queryForList("select * from EVENTS_CUSTOMINFO where EVENT_ID=" + eventId);
Map<String, String> customInfo = new HashMap<String, String>(rows.size());
for (Map<String, Object> row : rows) {
customInfo.put((String)row.get("CUST_KEY"), (String)row.get("CUST_VALUE"));
}
return customInfo;
}
|
[
"private",
"Map",
"<",
"String",
",",
"String",
">",
"readCustomInfo",
"(",
"long",
"eventId",
")",
"{",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"rows",
"=",
"getJdbcTemplate",
"(",
")",
".",
"queryForList",
"(",
"\"select * from EVENTS_CUSTOMINFO where EVENT_ID=\"",
"+",
"eventId",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"customInfo",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
"rows",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"row",
":",
"rows",
")",
"{",
"customInfo",
".",
"put",
"(",
"(",
"String",
")",
"row",
".",
"get",
"(",
"\"CUST_KEY\"",
")",
",",
"(",
"String",
")",
"row",
".",
"get",
"(",
"\"CUST_VALUE\"",
")",
")",
";",
"}",
"return",
"customInfo",
";",
"}"
] |
read CustomInfo list from table.
@param eventId the event id
@return the map
|
[
"read",
"CustomInfo",
"list",
"from",
"table",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-server/src/main/java/org/talend/esb/sam/server/persistence/EventRepositoryImpl.java#L132-L140
|
160,309 |
Talend/tesb-rt-se
|
sam/sam-server/src/main/java/org/talend/esb/sam/server/persistence/criterias/PatternCriteria.java
|
PatternCriteria.toSQLPattern
|
private String toSQLPattern(String attribute) {
String pattern = attribute.replace("*", "%");
if (!pattern.startsWith("%")) {
pattern = "%" + pattern;
}
if (!pattern.endsWith("%")) {
pattern = pattern.concat("%");
}
return pattern;
}
|
java
|
private String toSQLPattern(String attribute) {
String pattern = attribute.replace("*", "%");
if (!pattern.startsWith("%")) {
pattern = "%" + pattern;
}
if (!pattern.endsWith("%")) {
pattern = pattern.concat("%");
}
return pattern;
}
|
[
"private",
"String",
"toSQLPattern",
"(",
"String",
"attribute",
")",
"{",
"String",
"pattern",
"=",
"attribute",
".",
"replace",
"(",
"\"*\"",
",",
"\"%\"",
")",
";",
"if",
"(",
"!",
"pattern",
".",
"startsWith",
"(",
"\"%\"",
")",
")",
"{",
"pattern",
"=",
"\"%\"",
"+",
"pattern",
";",
"}",
"if",
"(",
"!",
"pattern",
".",
"endsWith",
"(",
"\"%\"",
")",
")",
"{",
"pattern",
"=",
"pattern",
".",
"concat",
"(",
"\"%\"",
")",
";",
"}",
"return",
"pattern",
";",
"}"
] |
To sql pattern.
@param attribute the attribute
@return the string
|
[
"To",
"sql",
"pattern",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-server/src/main/java/org/talend/esb/sam/server/persistence/criterias/PatternCriteria.java#L95-L104
|
160,310 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/eventproducer/EventProducerInterceptor.java
|
EventProducerInterceptor.checkMessageID
|
private void checkMessageID(Message message) {
if (!MessageUtils.isOutbound(message)) return;
AddressingProperties maps =
ContextUtils.retrieveMAPs(message, false, MessageUtils.isOutbound(message));
if (maps == null) {
maps = new AddressingProperties();
}
if (maps.getMessageID() == null) {
String messageID = ContextUtils.generateUUID();
boolean isRequestor = ContextUtils.isRequestor(message);
maps.setMessageID(ContextUtils.getAttributedURI(messageID));
ContextUtils.storeMAPs(maps, message, ContextUtils.isOutbound(message), isRequestor);
}
}
|
java
|
private void checkMessageID(Message message) {
if (!MessageUtils.isOutbound(message)) return;
AddressingProperties maps =
ContextUtils.retrieveMAPs(message, false, MessageUtils.isOutbound(message));
if (maps == null) {
maps = new AddressingProperties();
}
if (maps.getMessageID() == null) {
String messageID = ContextUtils.generateUUID();
boolean isRequestor = ContextUtils.isRequestor(message);
maps.setMessageID(ContextUtils.getAttributedURI(messageID));
ContextUtils.storeMAPs(maps, message, ContextUtils.isOutbound(message), isRequestor);
}
}
|
[
"private",
"void",
"checkMessageID",
"(",
"Message",
"message",
")",
"{",
"if",
"(",
"!",
"MessageUtils",
".",
"isOutbound",
"(",
"message",
")",
")",
"return",
";",
"AddressingProperties",
"maps",
"=",
"ContextUtils",
".",
"retrieveMAPs",
"(",
"message",
",",
"false",
",",
"MessageUtils",
".",
"isOutbound",
"(",
"message",
")",
")",
";",
"if",
"(",
"maps",
"==",
"null",
")",
"{",
"maps",
"=",
"new",
"AddressingProperties",
"(",
")",
";",
"}",
"if",
"(",
"maps",
".",
"getMessageID",
"(",
")",
"==",
"null",
")",
"{",
"String",
"messageID",
"=",
"ContextUtils",
".",
"generateUUID",
"(",
")",
";",
"boolean",
"isRequestor",
"=",
"ContextUtils",
".",
"isRequestor",
"(",
"message",
")",
";",
"maps",
".",
"setMessageID",
"(",
"ContextUtils",
".",
"getAttributedURI",
"(",
"messageID",
")",
")",
";",
"ContextUtils",
".",
"storeMAPs",
"(",
"maps",
",",
"message",
",",
"ContextUtils",
".",
"isOutbound",
"(",
"message",
")",
",",
"isRequestor",
")",
";",
"}",
"}"
] |
check if MessageID exists in the message, if not, only generate new MessageID for outbound message.
@param message
|
[
"check",
"if",
"MessageID",
"exists",
"in",
"the",
"message",
"if",
"not",
"only",
"generate",
"new",
"MessageID",
"for",
"outbound",
"message",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/eventproducer/EventProducerInterceptor.java#L119-L133
|
160,311 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/message/CorrelationIdHelper.java
|
CorrelationIdHelper.getCorrelationId
|
public static String getCorrelationId(Message message) {
String correlationId = (String) message.get(CORRELATION_ID_KEY);
if(null == correlationId) {
correlationId = readCorrelationId(message);
}
if(null == correlationId) {
correlationId = readCorrelationIdSoap(message);
}
return correlationId;
}
|
java
|
public static String getCorrelationId(Message message) {
String correlationId = (String) message.get(CORRELATION_ID_KEY);
if(null == correlationId) {
correlationId = readCorrelationId(message);
}
if(null == correlationId) {
correlationId = readCorrelationIdSoap(message);
}
return correlationId;
}
|
[
"public",
"static",
"String",
"getCorrelationId",
"(",
"Message",
"message",
")",
"{",
"String",
"correlationId",
"=",
"(",
"String",
")",
"message",
".",
"get",
"(",
"CORRELATION_ID_KEY",
")",
";",
"if",
"(",
"null",
"==",
"correlationId",
")",
"{",
"correlationId",
"=",
"readCorrelationId",
"(",
"message",
")",
";",
"}",
"if",
"(",
"null",
"==",
"correlationId",
")",
"{",
"correlationId",
"=",
"readCorrelationIdSoap",
"(",
"message",
")",
";",
"}",
"return",
"correlationId",
";",
"}"
] |
Get CorrelationId from message.
@param message the message
@return correlationId or null if not set
|
[
"Get",
"CorrelationId",
"from",
"message",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/message/CorrelationIdHelper.java#L60-L69
|
160,312 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/message/CorrelationIdHelper.java
|
CorrelationIdHelper.readCorrelationId
|
public static String readCorrelationId(Message message) {
String correlationId = null;
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
List<String> correlationIds = headers.get(CORRELATION_ID_KEY);
if (correlationIds != null && correlationIds.size() > 0) {
correlationId = correlationIds.get(0);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + CORRELATION_ID_KEY + "' found: " + correlationId);
}
} else {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("No HTTP header '" + CORRELATION_ID_KEY + "' found");
}
}
return correlationId;
}
|
java
|
public static String readCorrelationId(Message message) {
String correlationId = null;
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
List<String> correlationIds = headers.get(CORRELATION_ID_KEY);
if (correlationIds != null && correlationIds.size() > 0) {
correlationId = correlationIds.get(0);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + CORRELATION_ID_KEY + "' found: " + correlationId);
}
} else {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("No HTTP header '" + CORRELATION_ID_KEY + "' found");
}
}
return correlationId;
}
|
[
"public",
"static",
"String",
"readCorrelationId",
"(",
"Message",
"message",
")",
"{",
"String",
"correlationId",
"=",
"null",
";",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
"=",
"getOrCreateProtocolHeader",
"(",
"message",
")",
";",
"List",
"<",
"String",
">",
"correlationIds",
"=",
"headers",
".",
"get",
"(",
"CORRELATION_ID_KEY",
")",
";",
"if",
"(",
"correlationIds",
"!=",
"null",
"&&",
"correlationIds",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"correlationId",
"=",
"correlationIds",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"HTTP header '\"",
"+",
"CORRELATION_ID_KEY",
"+",
"\"' found: \"",
"+",
"correlationId",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"No HTTP header '\"",
"+",
"CORRELATION_ID_KEY",
"+",
"\"' found\"",
")",
";",
"}",
"}",
"return",
"correlationId",
";",
"}"
] |
Read correlation id from message.
@param message the message
@return the CorrelationId as string
|
[
"Read",
"correlation",
"id",
"from",
"message",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/message/CorrelationIdHelper.java#L107-L123
|
160,313 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/message/CorrelationIdHelper.java
|
CorrelationIdHelper.getOrCreateProtocolHeader
|
private static Map<String, List<String>> getOrCreateProtocolHeader(
Message message) {
Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>) message
.get(Message.PROTOCOL_HEADERS));
if (headers == null) {
headers = new HashMap<String, List<String>>();
message.put(Message.PROTOCOL_HEADERS, headers);
}
return headers;
}
|
java
|
private static Map<String, List<String>> getOrCreateProtocolHeader(
Message message) {
Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>) message
.get(Message.PROTOCOL_HEADERS));
if (headers == null) {
headers = new HashMap<String, List<String>>();
message.put(Message.PROTOCOL_HEADERS, headers);
}
return headers;
}
|
[
"private",
"static",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"getOrCreateProtocolHeader",
"(",
"Message",
"message",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
"=",
"CastUtils",
".",
"cast",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"message",
".",
"get",
"(",
"Message",
".",
"PROTOCOL_HEADERS",
")",
")",
";",
"if",
"(",
"headers",
"==",
"null",
")",
"{",
"headers",
"=",
"new",
"HashMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"(",
")",
";",
"message",
".",
"put",
"(",
"Message",
".",
"PROTOCOL_HEADERS",
",",
"headers",
")",
";",
"}",
"return",
"headers",
";",
"}"
] |
Gets the or create protocol header.
@param message the message
@return the message headers map
|
[
"Gets",
"the",
"or",
"create",
"protocol",
"header",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/message/CorrelationIdHelper.java#L131-L140
|
160,314 |
Talend/tesb-rt-se
|
sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/MonitoringServiceImpl.java
|
MonitoringServiceImpl.putEvents
|
public void putEvents(List<Event> events) {
List<Event> filteredEvents = filterEvents(events);
executeHandlers(filteredEvents);
for (Event event : filteredEvents) {
persistenceHandler.writeEvent(event);
}
}
|
java
|
public void putEvents(List<Event> events) {
List<Event> filteredEvents = filterEvents(events);
executeHandlers(filteredEvents);
for (Event event : filteredEvents) {
persistenceHandler.writeEvent(event);
}
}
|
[
"public",
"void",
"putEvents",
"(",
"List",
"<",
"Event",
">",
"events",
")",
"{",
"List",
"<",
"Event",
">",
"filteredEvents",
"=",
"filterEvents",
"(",
"events",
")",
";",
"executeHandlers",
"(",
"filteredEvents",
")",
";",
"for",
"(",
"Event",
"event",
":",
"filteredEvents",
")",
"{",
"persistenceHandler",
".",
"writeEvent",
"(",
"event",
")",
";",
"}",
"}"
] |
Executes all event manipulating handler and writes the event with persist
handler.
@param events the events
|
[
"Executes",
"all",
"event",
"manipulating",
"handler",
"and",
"writes",
"the",
"event",
"with",
"persist",
"handler",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/MonitoringServiceImpl.java#L79-L85
|
160,315 |
Talend/tesb-rt-se
|
sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/MonitoringServiceImpl.java
|
MonitoringServiceImpl.filterEvents
|
private List<Event> filterEvents(List<Event> events) {
List<Event> filteredEvents = new ArrayList<Event>();
for (Event event : events) {
if (!filter(event)) {
filteredEvents.add(event);
}
}
return filteredEvents;
}
|
java
|
private List<Event> filterEvents(List<Event> events) {
List<Event> filteredEvents = new ArrayList<Event>();
for (Event event : events) {
if (!filter(event)) {
filteredEvents.add(event);
}
}
return filteredEvents;
}
|
[
"private",
"List",
"<",
"Event",
">",
"filterEvents",
"(",
"List",
"<",
"Event",
">",
"events",
")",
"{",
"List",
"<",
"Event",
">",
"filteredEvents",
"=",
"new",
"ArrayList",
"<",
"Event",
">",
"(",
")",
";",
"for",
"(",
"Event",
"event",
":",
"events",
")",
"{",
"if",
"(",
"!",
"filter",
"(",
"event",
")",
")",
"{",
"filteredEvents",
".",
"add",
"(",
"event",
")",
";",
"}",
"}",
"return",
"filteredEvents",
";",
"}"
] |
Filter events.
@param events the events
@return the list of filtered events
|
[
"Filter",
"events",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-service-soap/src/main/java/org/talend/esb/sam/service/soap/MonitoringServiceImpl.java#L108-L116
|
160,316 |
Talend/tesb-rt-se
|
sam/sam-common/src/main/java/org/talend/esb/sam/common/filter/impl/StringContentFilter.java
|
StringContentFilter.filter
|
public boolean filter(Event event) {
LOG.info("StringContentFilter called");
if (wordsToFilter != null) {
for (String filterWord : wordsToFilter) {
if (event.getContent() != null
&& -1 != event.getContent().indexOf(filterWord)) {
return true;
}
}
}
return false;
}
|
java
|
public boolean filter(Event event) {
LOG.info("StringContentFilter called");
if (wordsToFilter != null) {
for (String filterWord : wordsToFilter) {
if (event.getContent() != null
&& -1 != event.getContent().indexOf(filterWord)) {
return true;
}
}
}
return false;
}
|
[
"public",
"boolean",
"filter",
"(",
"Event",
"event",
")",
"{",
"LOG",
".",
"info",
"(",
"\"StringContentFilter called\"",
")",
";",
"if",
"(",
"wordsToFilter",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"filterWord",
":",
"wordsToFilter",
")",
"{",
"if",
"(",
"event",
".",
"getContent",
"(",
")",
"!=",
"null",
"&&",
"-",
"1",
"!=",
"event",
".",
"getContent",
"(",
")",
".",
"indexOf",
"(",
"filterWord",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Filter event if word occurs in wordsToFilter.
@param event the event
@return true, if successful
|
[
"Filter",
"event",
"if",
"word",
"occurs",
"in",
"wordsToFilter",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-common/src/main/java/org/talend/esb/sam/common/filter/impl/StringContentFilter.java#L61-L73
|
160,317 |
Talend/tesb-rt-se
|
examples/camel/claimcheck/server/src/main/java/org/apache/camel/example/claimcheck/DataStore.java
|
DataStore.checkIn
|
public String checkIn(byte[] data) {
String id = UUID.randomUUID().toString();
dataMap.put(id, data);
return id;
}
|
java
|
public String checkIn(byte[] data) {
String id = UUID.randomUUID().toString();
dataMap.put(id, data);
return id;
}
|
[
"public",
"String",
"checkIn",
"(",
"byte",
"[",
"]",
"data",
")",
"{",
"String",
"id",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"dataMap",
".",
"put",
"(",
"id",
",",
"data",
")",
";",
"return",
"id",
";",
"}"
] |
Store the given data and return a uuid for later retrieval of the data
@param data
@return unique id for the stored data
|
[
"Store",
"the",
"given",
"data",
"and",
"return",
"a",
"uuid",
"for",
"later",
"retrieval",
"of",
"the",
"data"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/camel/claimcheck/server/src/main/java/org/apache/camel/example/claimcheck/DataStore.java#L21-L25
|
160,318 |
Talend/tesb-rt-se
|
request-callback/src/main/java/org/talend/esb/mep/requestcallback/impl/RequestCallbackInInterceptor.java
|
RequestCallbackInInterceptor.setupFlowId
|
private static void setupFlowId(SoapMessage message) {
String flowId = FlowIdHelper.getFlowId(message);
if (flowId == null) {
flowId = FlowIdProtocolHeaderCodec.readFlowId(message);
}
if (flowId == null) {
flowId = FlowIdSoapCodec.readFlowId(message);
}
if (flowId == null) {
Exchange ex = message.getExchange();
if (null!=ex){
Message reqMsg = ex.getOutMessage();
if ( null != reqMsg) {
flowId = FlowIdHelper.getFlowId(reqMsg);
}
}
}
if (flowId != null && !flowId.isEmpty()) {
FlowIdHelper.setFlowId(message, flowId);
}
}
|
java
|
private static void setupFlowId(SoapMessage message) {
String flowId = FlowIdHelper.getFlowId(message);
if (flowId == null) {
flowId = FlowIdProtocolHeaderCodec.readFlowId(message);
}
if (flowId == null) {
flowId = FlowIdSoapCodec.readFlowId(message);
}
if (flowId == null) {
Exchange ex = message.getExchange();
if (null!=ex){
Message reqMsg = ex.getOutMessage();
if ( null != reqMsg) {
flowId = FlowIdHelper.getFlowId(reqMsg);
}
}
}
if (flowId != null && !flowId.isEmpty()) {
FlowIdHelper.setFlowId(message, flowId);
}
}
|
[
"private",
"static",
"void",
"setupFlowId",
"(",
"SoapMessage",
"message",
")",
"{",
"String",
"flowId",
"=",
"FlowIdHelper",
".",
"getFlowId",
"(",
"message",
")",
";",
"if",
"(",
"flowId",
"==",
"null",
")",
"{",
"flowId",
"=",
"FlowIdProtocolHeaderCodec",
".",
"readFlowId",
"(",
"message",
")",
";",
"}",
"if",
"(",
"flowId",
"==",
"null",
")",
"{",
"flowId",
"=",
"FlowIdSoapCodec",
".",
"readFlowId",
"(",
"message",
")",
";",
"}",
"if",
"(",
"flowId",
"==",
"null",
")",
"{",
"Exchange",
"ex",
"=",
"message",
".",
"getExchange",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"ex",
")",
"{",
"Message",
"reqMsg",
"=",
"ex",
".",
"getOutMessage",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"reqMsg",
")",
"{",
"flowId",
"=",
"FlowIdHelper",
".",
"getFlowId",
"(",
"reqMsg",
")",
";",
"}",
"}",
"}",
"if",
"(",
"flowId",
"!=",
"null",
"&&",
"!",
"flowId",
".",
"isEmpty",
"(",
")",
")",
"{",
"FlowIdHelper",
".",
"setFlowId",
"(",
"message",
",",
"flowId",
")",
";",
"}",
"}"
] |
This functions reads SAM flowId and sets it
as message property for subsequent store in CallContext
@param message
|
[
"This",
"functions",
"reads",
"SAM",
"flowId",
"and",
"sets",
"it",
"as",
"message",
"property",
"for",
"subsequent",
"store",
"in",
"CallContext"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/request-callback/src/main/java/org/talend/esb/mep/requestcallback/impl/RequestCallbackInInterceptor.java#L255-L279
|
160,319 |
Talend/tesb-rt-se
|
request-callback/src/main/java/org/talend/esb/mep/requestcallback/impl/RequestCallbackInInterceptor.java
|
RequestCallbackInInterceptor.getReqSigCert
|
private static X509Certificate getReqSigCert(Message message) {
List<WSHandlerResult> results =
CastUtils.cast((List<?>)
message.getExchange().getInMessage().get(WSHandlerConstants.RECV_RESULTS));
if (results == null) {
return null;
}
/*
* Scan the results for a matching actor. Use results only if the
* receiving Actor and the sending Actor match.
*/
for (WSHandlerResult rResult : results) {
List<WSSecurityEngineResult> wsSecEngineResults = rResult
.getResults();
/*
* Scan the results for the first Signature action. Use the
* certificate of this Signature to set the certificate for the
* encryption action :-).
*/
for (WSSecurityEngineResult wser : wsSecEngineResults) {
Integer actInt = (Integer) wser
.get(WSSecurityEngineResult.TAG_ACTION);
if (actInt.intValue() == WSConstants.SIGN) {
return (X509Certificate) wser
.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
}
}
}
return null;
}
|
java
|
private static X509Certificate getReqSigCert(Message message) {
List<WSHandlerResult> results =
CastUtils.cast((List<?>)
message.getExchange().getInMessage().get(WSHandlerConstants.RECV_RESULTS));
if (results == null) {
return null;
}
/*
* Scan the results for a matching actor. Use results only if the
* receiving Actor and the sending Actor match.
*/
for (WSHandlerResult rResult : results) {
List<WSSecurityEngineResult> wsSecEngineResults = rResult
.getResults();
/*
* Scan the results for the first Signature action. Use the
* certificate of this Signature to set the certificate for the
* encryption action :-).
*/
for (WSSecurityEngineResult wser : wsSecEngineResults) {
Integer actInt = (Integer) wser
.get(WSSecurityEngineResult.TAG_ACTION);
if (actInt.intValue() == WSConstants.SIGN) {
return (X509Certificate) wser
.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
}
}
}
return null;
}
|
[
"private",
"static",
"X509Certificate",
"getReqSigCert",
"(",
"Message",
"message",
")",
"{",
"List",
"<",
"WSHandlerResult",
">",
"results",
"=",
"CastUtils",
".",
"cast",
"(",
"(",
"List",
"<",
"?",
">",
")",
"message",
".",
"getExchange",
"(",
")",
".",
"getInMessage",
"(",
")",
".",
"get",
"(",
"WSHandlerConstants",
".",
"RECV_RESULTS",
")",
")",
";",
"if",
"(",
"results",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"/*\n\t\t * Scan the results for a matching actor. Use results only if the\n\t\t * receiving Actor and the sending Actor match.\n\t\t */",
"for",
"(",
"WSHandlerResult",
"rResult",
":",
"results",
")",
"{",
"List",
"<",
"WSSecurityEngineResult",
">",
"wsSecEngineResults",
"=",
"rResult",
".",
"getResults",
"(",
")",
";",
"/*\n\t\t\t * Scan the results for the first Signature action. Use the\n\t\t\t * certificate of this Signature to set the certificate for the\n\t\t\t * encryption action :-).\n\t\t\t */",
"for",
"(",
"WSSecurityEngineResult",
"wser",
":",
"wsSecEngineResults",
")",
"{",
"Integer",
"actInt",
"=",
"(",
"Integer",
")",
"wser",
".",
"get",
"(",
"WSSecurityEngineResult",
".",
"TAG_ACTION",
")",
";",
"if",
"(",
"actInt",
".",
"intValue",
"(",
")",
"==",
"WSConstants",
".",
"SIGN",
")",
"{",
"return",
"(",
"X509Certificate",
")",
"wser",
".",
"get",
"(",
"WSSecurityEngineResult",
".",
"TAG_X509_CERTIFICATE",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Refactor the method into public CXF utility and reuse it from CXF instead copy&paste
|
[
"Refactor",
"the",
"method",
"into",
"public",
"CXF",
"utility",
"and",
"reuse",
"it",
"from",
"CXF",
"instead",
"copy&paste"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/request-callback/src/main/java/org/talend/esb/mep/requestcallback/impl/RequestCallbackInInterceptor.java#L291-L322
|
160,320 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-advanced/client/src/main/java/client/RESTClient.java
|
RESTClient.useSearchService
|
private void useSearchService() throws Exception {
System.out.println("Searching...");
WebClient wc = WebClient.create("http://localhost:" + port + "/services/personservice/search");
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
wc.accept(MediaType.APPLICATION_XML);
// Moves to "/services/personservice/search"
wc.path("person");
SearchConditionBuilder builder = SearchConditionBuilder.instance();
System.out.println("Find people with the name Fred or Lorraine:");
String query = builder.is("name").equalTo("Fred").or()
.is("name").equalTo("Lorraine")
.query();
findPersons(wc, query);
System.out.println("Find all people who are no more than 30 years old");
query = builder.is("age").lessOrEqualTo(30)
.query();
findPersons(wc, query);
System.out.println("Find all people who are older than 28 and whose father name is John");
query = builder.is("age").greaterThan(28)
.and("fatherName").equalTo("John")
.query();
findPersons(wc, query);
System.out.println("Find all people who have children with name Fred");
query = builder.is("childName").equalTo("Fred")
.query();
findPersons(wc, query);
//Moves to "/services/personservice/personinfo"
wc.reset().accept(MediaType.APPLICATION_XML);
wc.path("personinfo");
System.out.println("Find all people younger than 40 using JPA2 Tuples");
query = builder.is("age").lessThan(40).query();
// Use URI path component to capture the query expression
wc.path(query);
Collection<? extends PersonInfo> personInfos = wc.getCollection(PersonInfo.class);
for (PersonInfo pi : personInfos) {
System.out.println("ID : " + pi.getId());
}
wc.close();
}
|
java
|
private void useSearchService() throws Exception {
System.out.println("Searching...");
WebClient wc = WebClient.create("http://localhost:" + port + "/services/personservice/search");
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
wc.accept(MediaType.APPLICATION_XML);
// Moves to "/services/personservice/search"
wc.path("person");
SearchConditionBuilder builder = SearchConditionBuilder.instance();
System.out.println("Find people with the name Fred or Lorraine:");
String query = builder.is("name").equalTo("Fred").or()
.is("name").equalTo("Lorraine")
.query();
findPersons(wc, query);
System.out.println("Find all people who are no more than 30 years old");
query = builder.is("age").lessOrEqualTo(30)
.query();
findPersons(wc, query);
System.out.println("Find all people who are older than 28 and whose father name is John");
query = builder.is("age").greaterThan(28)
.and("fatherName").equalTo("John")
.query();
findPersons(wc, query);
System.out.println("Find all people who have children with name Fred");
query = builder.is("childName").equalTo("Fred")
.query();
findPersons(wc, query);
//Moves to "/services/personservice/personinfo"
wc.reset().accept(MediaType.APPLICATION_XML);
wc.path("personinfo");
System.out.println("Find all people younger than 40 using JPA2 Tuples");
query = builder.is("age").lessThan(40).query();
// Use URI path component to capture the query expression
wc.path(query);
Collection<? extends PersonInfo> personInfos = wc.getCollection(PersonInfo.class);
for (PersonInfo pi : personInfos) {
System.out.println("ID : " + pi.getId());
}
wc.close();
}
|
[
"private",
"void",
"useSearchService",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Searching...\"",
")",
";",
"WebClient",
"wc",
"=",
"WebClient",
".",
"create",
"(",
"\"http://localhost:\"",
"+",
"port",
"+",
"\"/services/personservice/search\"",
")",
";",
"WebClient",
".",
"getConfig",
"(",
"wc",
")",
".",
"getHttpConduit",
"(",
")",
".",
"getClient",
"(",
")",
".",
"setReceiveTimeout",
"(",
"10000000L",
")",
";",
"wc",
".",
"accept",
"(",
"MediaType",
".",
"APPLICATION_XML",
")",
";",
"// Moves to \"/services/personservice/search\"",
"wc",
".",
"path",
"(",
"\"person\"",
")",
";",
"SearchConditionBuilder",
"builder",
"=",
"SearchConditionBuilder",
".",
"instance",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Find people with the name Fred or Lorraine:\"",
")",
";",
"String",
"query",
"=",
"builder",
".",
"is",
"(",
"\"name\"",
")",
".",
"equalTo",
"(",
"\"Fred\"",
")",
".",
"or",
"(",
")",
".",
"is",
"(",
"\"name\"",
")",
".",
"equalTo",
"(",
"\"Lorraine\"",
")",
".",
"query",
"(",
")",
";",
"findPersons",
"(",
"wc",
",",
"query",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Find all people who are no more than 30 years old\"",
")",
";",
"query",
"=",
"builder",
".",
"is",
"(",
"\"age\"",
")",
".",
"lessOrEqualTo",
"(",
"30",
")",
".",
"query",
"(",
")",
";",
"findPersons",
"(",
"wc",
",",
"query",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Find all people who are older than 28 and whose father name is John\"",
")",
";",
"query",
"=",
"builder",
".",
"is",
"(",
"\"age\"",
")",
".",
"greaterThan",
"(",
"28",
")",
".",
"and",
"(",
"\"fatherName\"",
")",
".",
"equalTo",
"(",
"\"John\"",
")",
".",
"query",
"(",
")",
";",
"findPersons",
"(",
"wc",
",",
"query",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Find all people who have children with name Fred\"",
")",
";",
"query",
"=",
"builder",
".",
"is",
"(",
"\"childName\"",
")",
".",
"equalTo",
"(",
"\"Fred\"",
")",
".",
"query",
"(",
")",
";",
"findPersons",
"(",
"wc",
",",
"query",
")",
";",
"//Moves to \"/services/personservice/personinfo\"",
"wc",
".",
"reset",
"(",
")",
".",
"accept",
"(",
"MediaType",
".",
"APPLICATION_XML",
")",
";",
"wc",
".",
"path",
"(",
"\"personinfo\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Find all people younger than 40 using JPA2 Tuples\"",
")",
";",
"query",
"=",
"builder",
".",
"is",
"(",
"\"age\"",
")",
".",
"lessThan",
"(",
"40",
")",
".",
"query",
"(",
")",
";",
"// Use URI path component to capture the query expression",
"wc",
".",
"path",
"(",
"query",
")",
";",
"Collection",
"<",
"?",
"extends",
"PersonInfo",
">",
"personInfos",
"=",
"wc",
".",
"getCollection",
"(",
"PersonInfo",
".",
"class",
")",
";",
"for",
"(",
"PersonInfo",
"pi",
":",
"personInfos",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"ID : \"",
"+",
"pi",
".",
"getId",
"(",
")",
")",
";",
"}",
"wc",
".",
"close",
"(",
")",
";",
"}"
] |
SearchService is a service which shares the information about Persons with the PersonService.
It lets users search for individual people using simple or complex search expressions.
The interaction with this service also verifies that the JAX-RS server is capable of supporting multiple
root resource classes
|
[
"SearchService",
"is",
"a",
"service",
"which",
"shares",
"the",
"information",
"about",
"Persons",
"with",
"the",
"PersonService",
".",
"It",
"lets",
"users",
"search",
"for",
"individual",
"people",
"using",
"simple",
"or",
"complex",
"search",
"expressions",
".",
"The",
"interaction",
"with",
"this",
"service",
"also",
"verifies",
"that",
"the",
"JAX",
"-",
"RS",
"server",
"is",
"capable",
"of",
"supporting",
"multiple",
"root",
"resource",
"classes"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-advanced/client/src/main/java/client/RESTClient.java#L201-L257
|
160,321 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-advanced/client/src/main/java/client/RESTClient.java
|
RESTClient.useSimpleProxy
|
public void useSimpleProxy() {
String webAppAddress = "http://localhost:" + port + "/services/personservice";
PersonService proxy = JAXRSClientFactory.create(webAppAddress, PersonService.class);
new PersonServiceProxyClient(proxy).useService();
}
|
java
|
public void useSimpleProxy() {
String webAppAddress = "http://localhost:" + port + "/services/personservice";
PersonService proxy = JAXRSClientFactory.create(webAppAddress, PersonService.class);
new PersonServiceProxyClient(proxy).useService();
}
|
[
"public",
"void",
"useSimpleProxy",
"(",
")",
"{",
"String",
"webAppAddress",
"=",
"\"http://localhost:\"",
"+",
"port",
"+",
"\"/services/personservice\"",
";",
"PersonService",
"proxy",
"=",
"JAXRSClientFactory",
".",
"create",
"(",
"webAppAddress",
",",
"PersonService",
".",
"class",
")",
";",
"new",
"PersonServiceProxyClient",
"(",
"proxy",
")",
".",
"useService",
"(",
")",
";",
"}"
] |
This function uses a proxy which is capable of transforming typed invocations into proper HTTP calls
which will be understood by RESTful services. This works for subresources as well. Interfaces and
concrete classes can be proxified, in the latter case a CGLIB runtime dependency is needed. CXF JAX-RS
proxies can be configured the same way as HTTP-centric WebClients and response status and headers can
also be checked. HTTP response errors can be converted into typed exceptions.
|
[
"This",
"function",
"uses",
"a",
"proxy",
"which",
"is",
"capable",
"of",
"transforming",
"typed",
"invocations",
"into",
"proper",
"HTTP",
"calls",
"which",
"will",
"be",
"understood",
"by",
"RESTful",
"services",
".",
"This",
"works",
"for",
"subresources",
"as",
"well",
".",
"Interfaces",
"and",
"concrete",
"classes",
"can",
"be",
"proxified",
"in",
"the",
"latter",
"case",
"a",
"CGLIB",
"runtime",
"dependency",
"is",
"needed",
".",
"CXF",
"JAX",
"-",
"RS",
"proxies",
"can",
"be",
"configured",
"the",
"same",
"way",
"as",
"HTTP",
"-",
"centric",
"WebClients",
"and",
"response",
"status",
"and",
"headers",
"can",
"also",
"be",
"checked",
".",
"HTTP",
"response",
"errors",
"can",
"be",
"converted",
"into",
"typed",
"exceptions",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-advanced/client/src/main/java/client/RESTClient.java#L280-L285
|
160,322 |
Talend/tesb-rt-se
|
policies/correlationid-policy/src/main/java/org/talend/esb/policy/correlation/impl/CorrelationIdSoapCodec.java
|
CorrelationIdSoapCodec.readCorrelationId
|
public static String readCorrelationId(Message message) {
if (!(message instanceof SoapMessage)) {
return null;
}
String correlationId = null;
Header hdCorrelationId = ((SoapMessage) message).getHeader(CORRELATION_ID_QNAME);
if (hdCorrelationId != null) {
if (hdCorrelationId.getObject() instanceof String) {
correlationId = (String) hdCorrelationId.getObject();
} else if (hdCorrelationId.getObject() instanceof Node) {
Node headerNode = (Node) hdCorrelationId.getObject();
correlationId = headerNode.getTextContent();
} else {
LOG.warning("Found CorrelationId soap header but value is not a String or a Node! Value: "
+ hdCorrelationId.getObject().toString());
}
}
return correlationId;
}
|
java
|
public static String readCorrelationId(Message message) {
if (!(message instanceof SoapMessage)) {
return null;
}
String correlationId = null;
Header hdCorrelationId = ((SoapMessage) message).getHeader(CORRELATION_ID_QNAME);
if (hdCorrelationId != null) {
if (hdCorrelationId.getObject() instanceof String) {
correlationId = (String) hdCorrelationId.getObject();
} else if (hdCorrelationId.getObject() instanceof Node) {
Node headerNode = (Node) hdCorrelationId.getObject();
correlationId = headerNode.getTextContent();
} else {
LOG.warning("Found CorrelationId soap header but value is not a String or a Node! Value: "
+ hdCorrelationId.getObject().toString());
}
}
return correlationId;
}
|
[
"public",
"static",
"String",
"readCorrelationId",
"(",
"Message",
"message",
")",
"{",
"if",
"(",
"!",
"(",
"message",
"instanceof",
"SoapMessage",
")",
")",
"{",
"return",
"null",
";",
"}",
"String",
"correlationId",
"=",
"null",
";",
"Header",
"hdCorrelationId",
"=",
"(",
"(",
"SoapMessage",
")",
"message",
")",
".",
"getHeader",
"(",
"CORRELATION_ID_QNAME",
")",
";",
"if",
"(",
"hdCorrelationId",
"!=",
"null",
")",
"{",
"if",
"(",
"hdCorrelationId",
".",
"getObject",
"(",
")",
"instanceof",
"String",
")",
"{",
"correlationId",
"=",
"(",
"String",
")",
"hdCorrelationId",
".",
"getObject",
"(",
")",
";",
"}",
"else",
"if",
"(",
"hdCorrelationId",
".",
"getObject",
"(",
")",
"instanceof",
"Node",
")",
"{",
"Node",
"headerNode",
"=",
"(",
"Node",
")",
"hdCorrelationId",
".",
"getObject",
"(",
")",
";",
"correlationId",
"=",
"headerNode",
".",
"getTextContent",
"(",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"warning",
"(",
"\"Found CorrelationId soap header but value is not a String or a Node! Value: \"",
"+",
"hdCorrelationId",
".",
"getObject",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"return",
"correlationId",
";",
"}"
] |
Read correlation id.
@param message the message
@return correlation id from the message
|
[
"Read",
"correlation",
"id",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/policies/correlationid-policy/src/main/java/org/talend/esb/policy/correlation/impl/CorrelationIdSoapCodec.java#L57-L75
|
160,323 |
Talend/tesb-rt-se
|
policies/correlationid-policy/src/main/java/org/talend/esb/policy/correlation/impl/CorrelationIdSoapCodec.java
|
CorrelationIdSoapCodec.writeCorrelationId
|
public static void writeCorrelationId(Message message, String correlationId) {
if (!(message instanceof SoapMessage)) {
return;
}
SoapMessage soapMessage = (SoapMessage) message;
Header hdCorrelationId = soapMessage.getHeader(CORRELATION_ID_QNAME);
if (hdCorrelationId != null) {
LOG.warning("CorrelationId already existing in soap header, need not to write CorrelationId header.");
return;
}
if ((soapMessage.getContent(javax.xml.stream.XMLStreamWriter.class) != null)
&& (soapMessage.getContent(javax.xml.stream.XMLStreamWriter.class) instanceof SAAJStreamWriter)
&& (((SAAJStreamWriter) soapMessage.getContent(javax.xml.stream.XMLStreamWriter.class))
.getDocument()
.getElementsByTagNameNS("http://www.talend.com/esb/sam/correlationId/v1",
"correlationId").getLength() > 0)) {
LOG.warning("CorrelationId already existing in soap header, need not to write CorrelationId header.");
return;
}
try {
soapMessage.getHeaders().add(
new Header(CORRELATION_ID_QNAME, correlationId, new JAXBDataBinding(String.class)));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Stored correlationId '" + correlationId + "' in soap header: "
+ CORRELATION_ID_QNAME);
}
} catch (JAXBException e) {
LOG.log(Level.SEVERE, "Couldn't create correlationId header.", e);
}
}
|
java
|
public static void writeCorrelationId(Message message, String correlationId) {
if (!(message instanceof SoapMessage)) {
return;
}
SoapMessage soapMessage = (SoapMessage) message;
Header hdCorrelationId = soapMessage.getHeader(CORRELATION_ID_QNAME);
if (hdCorrelationId != null) {
LOG.warning("CorrelationId already existing in soap header, need not to write CorrelationId header.");
return;
}
if ((soapMessage.getContent(javax.xml.stream.XMLStreamWriter.class) != null)
&& (soapMessage.getContent(javax.xml.stream.XMLStreamWriter.class) instanceof SAAJStreamWriter)
&& (((SAAJStreamWriter) soapMessage.getContent(javax.xml.stream.XMLStreamWriter.class))
.getDocument()
.getElementsByTagNameNS("http://www.talend.com/esb/sam/correlationId/v1",
"correlationId").getLength() > 0)) {
LOG.warning("CorrelationId already existing in soap header, need not to write CorrelationId header.");
return;
}
try {
soapMessage.getHeaders().add(
new Header(CORRELATION_ID_QNAME, correlationId, new JAXBDataBinding(String.class)));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Stored correlationId '" + correlationId + "' in soap header: "
+ CORRELATION_ID_QNAME);
}
} catch (JAXBException e) {
LOG.log(Level.SEVERE, "Couldn't create correlationId header.", e);
}
}
|
[
"public",
"static",
"void",
"writeCorrelationId",
"(",
"Message",
"message",
",",
"String",
"correlationId",
")",
"{",
"if",
"(",
"!",
"(",
"message",
"instanceof",
"SoapMessage",
")",
")",
"{",
"return",
";",
"}",
"SoapMessage",
"soapMessage",
"=",
"(",
"SoapMessage",
")",
"message",
";",
"Header",
"hdCorrelationId",
"=",
"soapMessage",
".",
"getHeader",
"(",
"CORRELATION_ID_QNAME",
")",
";",
"if",
"(",
"hdCorrelationId",
"!=",
"null",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"CorrelationId already existing in soap header, need not to write CorrelationId header.\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"(",
"soapMessage",
".",
"getContent",
"(",
"javax",
".",
"xml",
".",
"stream",
".",
"XMLStreamWriter",
".",
"class",
")",
"!=",
"null",
")",
"&&",
"(",
"soapMessage",
".",
"getContent",
"(",
"javax",
".",
"xml",
".",
"stream",
".",
"XMLStreamWriter",
".",
"class",
")",
"instanceof",
"SAAJStreamWriter",
")",
"&&",
"(",
"(",
"(",
"SAAJStreamWriter",
")",
"soapMessage",
".",
"getContent",
"(",
"javax",
".",
"xml",
".",
"stream",
".",
"XMLStreamWriter",
".",
"class",
")",
")",
".",
"getDocument",
"(",
")",
".",
"getElementsByTagNameNS",
"(",
"\"http://www.talend.com/esb/sam/correlationId/v1\"",
",",
"\"correlationId\"",
")",
".",
"getLength",
"(",
")",
">",
"0",
")",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"CorrelationId already existing in soap header, need not to write CorrelationId header.\"",
")",
";",
"return",
";",
"}",
"try",
"{",
"soapMessage",
".",
"getHeaders",
"(",
")",
".",
"add",
"(",
"new",
"Header",
"(",
"CORRELATION_ID_QNAME",
",",
"correlationId",
",",
"new",
"JAXBDataBinding",
"(",
"String",
".",
"class",
")",
")",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"Stored correlationId '\"",
"+",
"correlationId",
"+",
"\"' in soap header: \"",
"+",
"CORRELATION_ID_QNAME",
")",
";",
"}",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Couldn't create correlationId header.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Write correlation id to message.
@param message the message
@param correlationId the correlation id
|
[
"Write",
"correlation",
"id",
"to",
"message",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/policies/correlationid-policy/src/main/java/org/talend/esb/policy/correlation/impl/CorrelationIdSoapCodec.java#L83-L114
|
160,324 |
Talend/tesb-rt-se
|
sam/sam-common/src/main/java/org/talend/esb/sam/common/handler/impl/ContentLengthHandler.java
|
ContentLengthHandler.handleEvent
|
public void handleEvent(Event event) {
LOG.fine("ContentLengthHandler called");
//if maximum length is shorter then <cut><![CDATA[ ]]></cut> it's not possible to cut the content
if(CUT_START_TAG.length() + CUT_END_TAG.length() > length) {
LOG.warning("Trying to cut content. But length is shorter then needed for "
+ CUT_START_TAG + CUT_END_TAG + ". So content is skipped.");
event.setContent("");
return;
}
int currentLength = length - CUT_START_TAG.length() - CUT_END_TAG.length();
if (event.getContent() != null && event.getContent().length() > length) {
LOG.fine("cutting content to " + currentLength
+ " characters. Original length was "
+ event.getContent().length());
LOG.fine("Content before cutting: " + event.getContent());
event.setContent(CUT_START_TAG
+ event.getContent().substring(0, currentLength) + CUT_END_TAG);
LOG.fine("Content after cutting: " + event.getContent());
}
}
|
java
|
public void handleEvent(Event event) {
LOG.fine("ContentLengthHandler called");
//if maximum length is shorter then <cut><![CDATA[ ]]></cut> it's not possible to cut the content
if(CUT_START_TAG.length() + CUT_END_TAG.length() > length) {
LOG.warning("Trying to cut content. But length is shorter then needed for "
+ CUT_START_TAG + CUT_END_TAG + ". So content is skipped.");
event.setContent("");
return;
}
int currentLength = length - CUT_START_TAG.length() - CUT_END_TAG.length();
if (event.getContent() != null && event.getContent().length() > length) {
LOG.fine("cutting content to " + currentLength
+ " characters. Original length was "
+ event.getContent().length());
LOG.fine("Content before cutting: " + event.getContent());
event.setContent(CUT_START_TAG
+ event.getContent().substring(0, currentLength) + CUT_END_TAG);
LOG.fine("Content after cutting: " + event.getContent());
}
}
|
[
"public",
"void",
"handleEvent",
"(",
"Event",
"event",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"ContentLengthHandler called\"",
")",
";",
"//if maximum length is shorter then <cut><![CDATA[ ]]></cut> it's not possible to cut the content",
"if",
"(",
"CUT_START_TAG",
".",
"length",
"(",
")",
"+",
"CUT_END_TAG",
".",
"length",
"(",
")",
">",
"length",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"Trying to cut content. But length is shorter then needed for \"",
"+",
"CUT_START_TAG",
"+",
"CUT_END_TAG",
"+",
"\". So content is skipped.\"",
")",
";",
"event",
".",
"setContent",
"(",
"\"\"",
")",
";",
"return",
";",
"}",
"int",
"currentLength",
"=",
"length",
"-",
"CUT_START_TAG",
".",
"length",
"(",
")",
"-",
"CUT_END_TAG",
".",
"length",
"(",
")",
";",
"if",
"(",
"event",
".",
"getContent",
"(",
")",
"!=",
"null",
"&&",
"event",
".",
"getContent",
"(",
")",
".",
"length",
"(",
")",
">",
"length",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"cutting content to \"",
"+",
"currentLength",
"+",
"\" characters. Original length was \"",
"+",
"event",
".",
"getContent",
"(",
")",
".",
"length",
"(",
")",
")",
";",
"LOG",
".",
"fine",
"(",
"\"Content before cutting: \"",
"+",
"event",
".",
"getContent",
"(",
")",
")",
";",
"event",
".",
"setContent",
"(",
"CUT_START_TAG",
"+",
"event",
".",
"getContent",
"(",
")",
".",
"substring",
"(",
"0",
",",
"currentLength",
")",
"+",
"CUT_END_TAG",
")",
";",
"LOG",
".",
"fine",
"(",
"\"Content after cutting: \"",
"+",
"event",
".",
"getContent",
"(",
")",
")",
";",
"}",
"}"
] |
Cut the message content to the configured length.
@param event the event
|
[
"Cut",
"the",
"message",
"content",
"to",
"the",
"configured",
"length",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-common/src/main/java/org/talend/esb/sam/common/handler/impl/ContentLengthHandler.java#L74-L96
|
160,325 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/util/Converter.java
|
Converter.convertDate
|
public static XMLGregorianCalendar convertDate(Date date) {
if (date == null) {
return null;
}
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(date.getTime());
try {
return getDatatypeFactory().newXMLGregorianCalendar(gc);
} catch (DatatypeConfigurationException ex) {
return null;
}
}
|
java
|
public static XMLGregorianCalendar convertDate(Date date) {
if (date == null) {
return null;
}
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(date.getTime());
try {
return getDatatypeFactory().newXMLGregorianCalendar(gc);
} catch (DatatypeConfigurationException ex) {
return null;
}
}
|
[
"public",
"static",
"XMLGregorianCalendar",
"convertDate",
"(",
"Date",
"date",
")",
"{",
"if",
"(",
"date",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"GregorianCalendar",
"gc",
"=",
"new",
"GregorianCalendar",
"(",
")",
";",
"gc",
".",
"setTimeInMillis",
"(",
"date",
".",
"getTime",
"(",
")",
")",
";",
"try",
"{",
"return",
"getDatatypeFactory",
"(",
")",
".",
"newXMLGregorianCalendar",
"(",
"gc",
")",
";",
"}",
"catch",
"(",
"DatatypeConfigurationException",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
convert Date to XMLGregorianCalendar.
@param date the date
@return the xML gregorian calendar
|
[
"convert",
"Date",
"to",
"XMLGregorianCalendar",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/util/Converter.java#L56-L69
|
160,326 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/message/CustomInfo.java
|
CustomInfo.getOrCreateCustomInfo
|
public static CustomInfo getOrCreateCustomInfo(Message message) {
CustomInfo customInfo = message.get(CustomInfo.class);
if (customInfo == null) {
customInfo = new CustomInfo();
message.put(CustomInfo.class, customInfo);
}
return customInfo;
}
|
java
|
public static CustomInfo getOrCreateCustomInfo(Message message) {
CustomInfo customInfo = message.get(CustomInfo.class);
if (customInfo == null) {
customInfo = new CustomInfo();
message.put(CustomInfo.class, customInfo);
}
return customInfo;
}
|
[
"public",
"static",
"CustomInfo",
"getOrCreateCustomInfo",
"(",
"Message",
"message",
")",
"{",
"CustomInfo",
"customInfo",
"=",
"message",
".",
"get",
"(",
"CustomInfo",
".",
"class",
")",
";",
"if",
"(",
"customInfo",
"==",
"null",
")",
"{",
"customInfo",
"=",
"new",
"CustomInfo",
"(",
")",
";",
"message",
".",
"put",
"(",
"CustomInfo",
".",
"class",
",",
"customInfo",
")",
";",
"}",
"return",
"customInfo",
";",
"}"
] |
Access the customInfo of a message using this accessor. The CustomInfo
map will be automatically created and stored in the event if it is not yet present
@param message
@return
|
[
"Access",
"the",
"customInfo",
"of",
"a",
"message",
"using",
"this",
"accessor",
".",
"The",
"CustomInfo",
"map",
"will",
"be",
"automatically",
"created",
"and",
"stored",
"in",
"the",
"event",
"if",
"it",
"is",
"not",
"yet",
"present"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/message/CustomInfo.java#L44-L51
|
160,327 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/wiretap/WireTapHelper.java
|
WireTapHelper.isMessageContentToBeLogged
|
public static boolean isMessageContentToBeLogged(final Message message, final boolean logMessageContent,
boolean logMessageContentOverride) {
/*
* If controlling of logging behavior is not allowed externally
* then log according to global property value
*/
if (!logMessageContentOverride) {
return logMessageContent;
}
Object logMessageContentExtObj = message.getContextualProperty(EXTERNAL_PROPERTY_NAME);
if (null == logMessageContentExtObj) {
return logMessageContent;
} else if (logMessageContentExtObj instanceof Boolean) {
return ((Boolean) logMessageContentExtObj).booleanValue();
} else if (logMessageContentExtObj instanceof String) {
String logMessageContentExtVal = (String) logMessageContentExtObj;
if (logMessageContentExtVal.equalsIgnoreCase("true")) {
return true;
} else if (logMessageContentExtVal.equalsIgnoreCase("false")) {
return false;
} else {
return logMessageContent;
}
} else {
return logMessageContent;
}
}
|
java
|
public static boolean isMessageContentToBeLogged(final Message message, final boolean logMessageContent,
boolean logMessageContentOverride) {
/*
* If controlling of logging behavior is not allowed externally
* then log according to global property value
*/
if (!logMessageContentOverride) {
return logMessageContent;
}
Object logMessageContentExtObj = message.getContextualProperty(EXTERNAL_PROPERTY_NAME);
if (null == logMessageContentExtObj) {
return logMessageContent;
} else if (logMessageContentExtObj instanceof Boolean) {
return ((Boolean) logMessageContentExtObj).booleanValue();
} else if (logMessageContentExtObj instanceof String) {
String logMessageContentExtVal = (String) logMessageContentExtObj;
if (logMessageContentExtVal.equalsIgnoreCase("true")) {
return true;
} else if (logMessageContentExtVal.equalsIgnoreCase("false")) {
return false;
} else {
return logMessageContent;
}
} else {
return logMessageContent;
}
}
|
[
"public",
"static",
"boolean",
"isMessageContentToBeLogged",
"(",
"final",
"Message",
"message",
",",
"final",
"boolean",
"logMessageContent",
",",
"boolean",
"logMessageContentOverride",
")",
"{",
"/*\n * If controlling of logging behavior is not allowed externally\n * then log according to global property value\n */",
"if",
"(",
"!",
"logMessageContentOverride",
")",
"{",
"return",
"logMessageContent",
";",
"}",
"Object",
"logMessageContentExtObj",
"=",
"message",
".",
"getContextualProperty",
"(",
"EXTERNAL_PROPERTY_NAME",
")",
";",
"if",
"(",
"null",
"==",
"logMessageContentExtObj",
")",
"{",
"return",
"logMessageContent",
";",
"}",
"else",
"if",
"(",
"logMessageContentExtObj",
"instanceof",
"Boolean",
")",
"{",
"return",
"(",
"(",
"Boolean",
")",
"logMessageContentExtObj",
")",
".",
"booleanValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"logMessageContentExtObj",
"instanceof",
"String",
")",
"{",
"String",
"logMessageContentExtVal",
"=",
"(",
"String",
")",
"logMessageContentExtObj",
";",
"if",
"(",
"logMessageContentExtVal",
".",
"equalsIgnoreCase",
"(",
"\"true\"",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"logMessageContentExtVal",
".",
"equalsIgnoreCase",
"(",
"\"false\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"logMessageContent",
";",
"}",
"}",
"else",
"{",
"return",
"logMessageContent",
";",
"}",
"}"
] |
If the "org.talend.esb.sam.agent.log.messageContent" property value is "true" then log the message content
If it is "false" then skip the message content logging
Else fall back to global property "log.messageContent"
@param message
@param logMessageContent
@param logMessageContentOverride
@return
|
[
"If",
"the",
"org",
".",
"talend",
".",
"esb",
".",
"sam",
".",
"agent",
".",
"log",
".",
"messageContent",
"property",
"value",
"is",
"true",
"then",
"log",
"the",
"message",
"content",
"If",
"it",
"is",
"false",
"then",
"skip",
"the",
"message",
"content",
"logging",
"Else",
"fall",
"back",
"to",
"global",
"property",
"log",
".",
"messageContent"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/wiretap/WireTapHelper.java#L43-L84
|
160,328 |
Talend/tesb-rt-se
|
locator-service/locator-soap-service/src/main/java/org/talend/esb/locator/service/LocatorSoapServiceImpl.java
|
LocatorSoapServiceImpl.initLocator
|
public void initLocator() throws InterruptedException,
ServiceLocatorException {
if (locatorClient == null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Instantiate locatorClient client for Locator Server "
+ locatorEndpoints + "...");
}
ServiceLocatorImpl client = new ServiceLocatorImpl();
client.setLocatorEndpoints(locatorEndpoints);
client.setConnectionTimeout(connectionTimeout);
client.setSessionTimeout(sessionTimeout);
if (null != authenticationName)
client.setName(authenticationName);
if (null != authenticationPassword)
client.setPassword(authenticationPassword);
locatorClient = client;
locatorClient.connect();
}
}
|
java
|
public void initLocator() throws InterruptedException,
ServiceLocatorException {
if (locatorClient == null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Instantiate locatorClient client for Locator Server "
+ locatorEndpoints + "...");
}
ServiceLocatorImpl client = new ServiceLocatorImpl();
client.setLocatorEndpoints(locatorEndpoints);
client.setConnectionTimeout(connectionTimeout);
client.setSessionTimeout(sessionTimeout);
if (null != authenticationName)
client.setName(authenticationName);
if (null != authenticationPassword)
client.setPassword(authenticationPassword);
locatorClient = client;
locatorClient.connect();
}
}
|
[
"public",
"void",
"initLocator",
"(",
")",
"throws",
"InterruptedException",
",",
"ServiceLocatorException",
"{",
"if",
"(",
"locatorClient",
"==",
"null",
")",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"Instantiate locatorClient client for Locator Server \"",
"+",
"locatorEndpoints",
"+",
"\"...\"",
")",
";",
"}",
"ServiceLocatorImpl",
"client",
"=",
"new",
"ServiceLocatorImpl",
"(",
")",
";",
"client",
".",
"setLocatorEndpoints",
"(",
"locatorEndpoints",
")",
";",
"client",
".",
"setConnectionTimeout",
"(",
"connectionTimeout",
")",
";",
"client",
".",
"setSessionTimeout",
"(",
"sessionTimeout",
")",
";",
"if",
"(",
"null",
"!=",
"authenticationName",
")",
"client",
".",
"setName",
"(",
"authenticationName",
")",
";",
"if",
"(",
"null",
"!=",
"authenticationPassword",
")",
"client",
".",
"setPassword",
"(",
"authenticationPassword",
")",
";",
"locatorClient",
"=",
"client",
";",
"locatorClient",
".",
"connect",
"(",
")",
";",
"}",
"}"
] |
Instantiate Service Locator client. After successful instantiation
establish a connection to the Service Locator server. This method will be
called if property locatorClient is null. For this purpose was defined
additional properties to instantiate ServiceLocatorImpl.
@throws InterruptedException
@throws ServiceLocatorException
|
[
"Instantiate",
"Service",
"Locator",
"client",
".",
"After",
"successful",
"instantiation",
"establish",
"a",
"connection",
"to",
"the",
"Service",
"Locator",
"server",
".",
"This",
"method",
"will",
"be",
"called",
"if",
"property",
"locatorClient",
"is",
"null",
".",
"For",
"this",
"purpose",
"was",
"defined",
"additional",
"properties",
"to",
"instantiate",
"ServiceLocatorImpl",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator-service/locator-soap-service/src/main/java/org/talend/esb/locator/service/LocatorSoapServiceImpl.java#L131-L149
|
160,329 |
Talend/tesb-rt-se
|
locator-service/locator-soap-service/src/main/java/org/talend/esb/locator/service/LocatorSoapServiceImpl.java
|
LocatorSoapServiceImpl.disconnectLocator
|
@PreDestroy
public void disconnectLocator() throws InterruptedException,
ServiceLocatorException {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Destroy Locator client");
}
if (endpointCollector != null) {
endpointCollector.stopScheduledCollection();
}
if (locatorClient != null) {
locatorClient.disconnect();
locatorClient = null;
}
}
|
java
|
@PreDestroy
public void disconnectLocator() throws InterruptedException,
ServiceLocatorException {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Destroy Locator client");
}
if (endpointCollector != null) {
endpointCollector.stopScheduledCollection();
}
if (locatorClient != null) {
locatorClient.disconnect();
locatorClient = null;
}
}
|
[
"@",
"PreDestroy",
"public",
"void",
"disconnectLocator",
"(",
")",
"throws",
"InterruptedException",
",",
"ServiceLocatorException",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"Destroy Locator client\"",
")",
";",
"}",
"if",
"(",
"endpointCollector",
"!=",
"null",
")",
"{",
"endpointCollector",
".",
"stopScheduledCollection",
"(",
")",
";",
"}",
"if",
"(",
"locatorClient",
"!=",
"null",
")",
"{",
"locatorClient",
".",
"disconnect",
"(",
")",
";",
"locatorClient",
"=",
"null",
";",
"}",
"}"
] |
Should use as destroy method. Disconnects from a Service Locator server.
All endpoints that were registered before are removed from the server.
Set property locatorClient to null.
@throws InterruptedException
@throws ServiceLocatorException
|
[
"Should",
"use",
"as",
"destroy",
"method",
".",
"Disconnects",
"from",
"a",
"Service",
"Locator",
"server",
".",
"All",
"endpoints",
"that",
"were",
"registered",
"before",
"are",
"removed",
"from",
"the",
"server",
".",
"Set",
"property",
"locatorClient",
"to",
"null",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator-service/locator-soap-service/src/main/java/org/talend/esb/locator/service/LocatorSoapServiceImpl.java#L159-L174
|
160,330 |
Talend/tesb-rt-se
|
locator-service/locator-soap-service/src/main/java/org/talend/esb/locator/service/LocatorSoapServiceImpl.java
|
LocatorSoapServiceImpl.lookupEndpoints
|
List<W3CEndpointReference> lookupEndpoints(QName serviceName,
MatcherDataType matcherData) throws ServiceLocatorFault,
InterruptedExceptionFault {
SLPropertiesMatcher matcher = createMatcher(matcherData);
List<String> names = null;
List<W3CEndpointReference> result = new ArrayList<W3CEndpointReference>();
String adress;
try {
initLocator();
if (matcher == null) {
names = locatorClient.lookup(serviceName);
} else {
names = locatorClient.lookup(serviceName, matcher);
}
} catch (ServiceLocatorException e) {
ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
serviceFaultDetail.setLocatorFaultDetail(serviceName.toString()
+ "throws ServiceLocatorFault");
throw new ServiceLocatorFault(e.getMessage(), serviceFaultDetail);
} catch (InterruptedException e) {
InterruptionFaultDetail interruptionFaultDetail = new InterruptionFaultDetail();
interruptionFaultDetail.setInterruptionDetail(serviceName
.toString() + "throws InterruptionFault");
throw new InterruptedExceptionFault(e.getMessage(),
interruptionFaultDetail);
}
if (names != null && !names.isEmpty()) {
for (int i = 0; i < names.size(); i++) {
adress = names.get(i);
result.add(buildEndpoint(serviceName, adress));
}
} else {
if (LOG.isLoggable(Level.WARNING)) {
LOG.log(Level.WARNING, "lookup Endpoints for " + serviceName
+ " failed, service is not known.");
}
ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
serviceFaultDetail.setLocatorFaultDetail("lookup Endpoint for "
+ serviceName + " failed, service is not known.");
throw new ServiceLocatorFault("Can not find Endpoint",
serviceFaultDetail);
}
return result;
}
|
java
|
List<W3CEndpointReference> lookupEndpoints(QName serviceName,
MatcherDataType matcherData) throws ServiceLocatorFault,
InterruptedExceptionFault {
SLPropertiesMatcher matcher = createMatcher(matcherData);
List<String> names = null;
List<W3CEndpointReference> result = new ArrayList<W3CEndpointReference>();
String adress;
try {
initLocator();
if (matcher == null) {
names = locatorClient.lookup(serviceName);
} else {
names = locatorClient.lookup(serviceName, matcher);
}
} catch (ServiceLocatorException e) {
ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
serviceFaultDetail.setLocatorFaultDetail(serviceName.toString()
+ "throws ServiceLocatorFault");
throw new ServiceLocatorFault(e.getMessage(), serviceFaultDetail);
} catch (InterruptedException e) {
InterruptionFaultDetail interruptionFaultDetail = new InterruptionFaultDetail();
interruptionFaultDetail.setInterruptionDetail(serviceName
.toString() + "throws InterruptionFault");
throw new InterruptedExceptionFault(e.getMessage(),
interruptionFaultDetail);
}
if (names != null && !names.isEmpty()) {
for (int i = 0; i < names.size(); i++) {
adress = names.get(i);
result.add(buildEndpoint(serviceName, adress));
}
} else {
if (LOG.isLoggable(Level.WARNING)) {
LOG.log(Level.WARNING, "lookup Endpoints for " + serviceName
+ " failed, service is not known.");
}
ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
serviceFaultDetail.setLocatorFaultDetail("lookup Endpoint for "
+ serviceName + " failed, service is not known.");
throw new ServiceLocatorFault("Can not find Endpoint",
serviceFaultDetail);
}
return result;
}
|
[
"List",
"<",
"W3CEndpointReference",
">",
"lookupEndpoints",
"(",
"QName",
"serviceName",
",",
"MatcherDataType",
"matcherData",
")",
"throws",
"ServiceLocatorFault",
",",
"InterruptedExceptionFault",
"{",
"SLPropertiesMatcher",
"matcher",
"=",
"createMatcher",
"(",
"matcherData",
")",
";",
"List",
"<",
"String",
">",
"names",
"=",
"null",
";",
"List",
"<",
"W3CEndpointReference",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"W3CEndpointReference",
">",
"(",
")",
";",
"String",
"adress",
";",
"try",
"{",
"initLocator",
"(",
")",
";",
"if",
"(",
"matcher",
"==",
"null",
")",
"{",
"names",
"=",
"locatorClient",
".",
"lookup",
"(",
"serviceName",
")",
";",
"}",
"else",
"{",
"names",
"=",
"locatorClient",
".",
"lookup",
"(",
"serviceName",
",",
"matcher",
")",
";",
"}",
"}",
"catch",
"(",
"ServiceLocatorException",
"e",
")",
"{",
"ServiceLocatorFaultDetail",
"serviceFaultDetail",
"=",
"new",
"ServiceLocatorFaultDetail",
"(",
")",
";",
"serviceFaultDetail",
".",
"setLocatorFaultDetail",
"(",
"serviceName",
".",
"toString",
"(",
")",
"+",
"\"throws ServiceLocatorFault\"",
")",
";",
"throw",
"new",
"ServiceLocatorFault",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"serviceFaultDetail",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"InterruptionFaultDetail",
"interruptionFaultDetail",
"=",
"new",
"InterruptionFaultDetail",
"(",
")",
";",
"interruptionFaultDetail",
".",
"setInterruptionDetail",
"(",
"serviceName",
".",
"toString",
"(",
")",
"+",
"\"throws InterruptionFault\"",
")",
";",
"throw",
"new",
"InterruptedExceptionFault",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"interruptionFaultDetail",
")",
";",
"}",
"if",
"(",
"names",
"!=",
"null",
"&&",
"!",
"names",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"names",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"adress",
"=",
"names",
".",
"get",
"(",
"i",
")",
";",
"result",
".",
"add",
"(",
"buildEndpoint",
"(",
"serviceName",
",",
"adress",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"WARNING",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"lookup Endpoints for \"",
"+",
"serviceName",
"+",
"\" failed, service is not known.\"",
")",
";",
"}",
"ServiceLocatorFaultDetail",
"serviceFaultDetail",
"=",
"new",
"ServiceLocatorFaultDetail",
"(",
")",
";",
"serviceFaultDetail",
".",
"setLocatorFaultDetail",
"(",
"\"lookup Endpoint for \"",
"+",
"serviceName",
"+",
"\" failed, service is not known.\"",
")",
";",
"throw",
"new",
"ServiceLocatorFault",
"(",
"\"Can not find Endpoint\"",
",",
"serviceFaultDetail",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
For the given service name return list of endpoint references currently
registered at the service locator server endpoints.
@param serviceName
the name of the service for which to get the endpoints, must
not be <code>null</code>
@return EndpointReferenceListType encapsulate list of endpoint references
or <code>null</code>
|
[
"For",
"the",
"given",
"service",
"name",
"return",
"list",
"of",
"endpoint",
"references",
"currently",
"registered",
"at",
"the",
"service",
"locator",
"server",
"endpoints",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator-service/locator-soap-service/src/main/java/org/talend/esb/locator/service/LocatorSoapServiceImpl.java#L365-L408
|
160,331 |
Talend/tesb-rt-se
|
locator-service/locator-soap-service/src/main/java/org/talend/esb/locator/service/LocatorSoapServiceImpl.java
|
LocatorSoapServiceImpl.getRotatedList
|
private List<String> getRotatedList(List<String> strings) {
int index = RANDOM.nextInt(strings.size());
List<String> rotated = new ArrayList<String>();
for (int i = 0; i < strings.size(); i++) {
rotated.add(strings.get(index));
index = (index + 1) % strings.size();
}
return rotated;
}
|
java
|
private List<String> getRotatedList(List<String> strings) {
int index = RANDOM.nextInt(strings.size());
List<String> rotated = new ArrayList<String>();
for (int i = 0; i < strings.size(); i++) {
rotated.add(strings.get(index));
index = (index + 1) % strings.size();
}
return rotated;
}
|
[
"private",
"List",
"<",
"String",
">",
"getRotatedList",
"(",
"List",
"<",
"String",
">",
"strings",
")",
"{",
"int",
"index",
"=",
"RANDOM",
".",
"nextInt",
"(",
"strings",
".",
"size",
"(",
")",
")",
";",
"List",
"<",
"String",
">",
"rotated",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"strings",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"rotated",
".",
"add",
"(",
"strings",
".",
"get",
"(",
"index",
")",
")",
";",
"index",
"=",
"(",
"index",
"+",
"1",
")",
"%",
"strings",
".",
"size",
"(",
")",
";",
"}",
"return",
"rotated",
";",
"}"
] |
Rotate list of String. Used for randomize selection of received endpoints
@param strings
list of Strings
@return the same list in random order
|
[
"Rotate",
"list",
"of",
"String",
".",
"Used",
"for",
"randomize",
"selection",
"of",
"received",
"endpoints"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/locator-service/locator-soap-service/src/main/java/org/talend/esb/locator/service/LocatorSoapServiceImpl.java#L429-L437
|
160,332 |
Talend/tesb-rt-se
|
job/controller/src/main/java/org/talend/esb/job/controller/internal/MultiThreadedOperation.java
|
MultiThreadedOperation.start
|
@Override
public void start(String[] arguments) {
boolean notStarted = !started.getAndSet(true);
if (notStarted) {
start(new MultiInstanceWorkloadStrategy(factory, name, arguments, endpointRegistry, execService));
}
}
|
java
|
@Override
public void start(String[] arguments) {
boolean notStarted = !started.getAndSet(true);
if (notStarted) {
start(new MultiInstanceWorkloadStrategy(factory, name, arguments, endpointRegistry, execService));
}
}
|
[
"@",
"Override",
"public",
"void",
"start",
"(",
"String",
"[",
"]",
"arguments",
")",
"{",
"boolean",
"notStarted",
"=",
"!",
"started",
".",
"getAndSet",
"(",
"true",
")",
";",
"if",
"(",
"notStarted",
")",
"{",
"start",
"(",
"new",
"MultiInstanceWorkloadStrategy",
"(",
"factory",
",",
"name",
",",
"arguments",
",",
"endpointRegistry",
",",
"execService",
")",
")",
";",
"}",
"}"
] |
Start the operation by instantiating the first job instance in a separate Thread.
@param arguments {@inheritDoc}
|
[
"Start",
"the",
"operation",
"by",
"instantiating",
"the",
"first",
"job",
"instance",
"in",
"a",
"separate",
"Thread",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/job/controller/src/main/java/org/talend/esb/job/controller/internal/MultiThreadedOperation.java#L70-L76
|
160,333 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/lifecycle/AbstractListenerImpl.java
|
AbstractListenerImpl.processStart
|
protected void processStart(Endpoint endpoint, EventTypeEnum eventType) {
if (!sendLifecycleEvent) {
return;
}
Event event = createEvent(endpoint, eventType);
queue.add(event);
}
|
java
|
protected void processStart(Endpoint endpoint, EventTypeEnum eventType) {
if (!sendLifecycleEvent) {
return;
}
Event event = createEvent(endpoint, eventType);
queue.add(event);
}
|
[
"protected",
"void",
"processStart",
"(",
"Endpoint",
"endpoint",
",",
"EventTypeEnum",
"eventType",
")",
"{",
"if",
"(",
"!",
"sendLifecycleEvent",
")",
"{",
"return",
";",
"}",
"Event",
"event",
"=",
"createEvent",
"(",
"endpoint",
",",
"eventType",
")",
";",
"queue",
".",
"add",
"(",
"event",
")",
";",
"}"
] |
Process start.
@param endpoint the endpoint
@param eventType the event type
|
[
"Process",
"start",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/lifecycle/AbstractListenerImpl.java#L92-L99
|
160,334 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/lifecycle/AbstractListenerImpl.java
|
AbstractListenerImpl.processStop
|
protected void processStop(Endpoint endpoint, EventTypeEnum eventType) {
if (!sendLifecycleEvent) {
return;
}
Event event = createEvent(endpoint, eventType);
monitoringServiceClient.putEvents(Collections.singletonList(event));
if (LOG.isLoggable(Level.INFO)) {
LOG.info("Send " + eventType + " event to SAM Server successful!");
}
}
|
java
|
protected void processStop(Endpoint endpoint, EventTypeEnum eventType) {
if (!sendLifecycleEvent) {
return;
}
Event event = createEvent(endpoint, eventType);
monitoringServiceClient.putEvents(Collections.singletonList(event));
if (LOG.isLoggable(Level.INFO)) {
LOG.info("Send " + eventType + " event to SAM Server successful!");
}
}
|
[
"protected",
"void",
"processStop",
"(",
"Endpoint",
"endpoint",
",",
"EventTypeEnum",
"eventType",
")",
"{",
"if",
"(",
"!",
"sendLifecycleEvent",
")",
"{",
"return",
";",
"}",
"Event",
"event",
"=",
"createEvent",
"(",
"endpoint",
",",
"eventType",
")",
";",
"monitoringServiceClient",
".",
"putEvents",
"(",
"Collections",
".",
"singletonList",
"(",
"event",
")",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"INFO",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Send \"",
"+",
"eventType",
"+",
"\" event to SAM Server successful!\"",
")",
";",
"}",
"}"
] |
Process stop.
@param endpoint the endpoint
@param eventType the event type
|
[
"Process",
"stop",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/lifecycle/AbstractListenerImpl.java#L107-L117
|
160,335 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/lifecycle/AbstractListenerImpl.java
|
AbstractListenerImpl.createEvent
|
private Event createEvent(Endpoint endpoint, EventTypeEnum type) {
Event event = new Event();
MessageInfo messageInfo = new MessageInfo();
Originator originator = new Originator();
event.setMessageInfo(messageInfo);
event.setOriginator(originator);
Date date = new Date();
event.setTimestamp(date);
event.setEventType(type);
messageInfo.setPortType(
endpoint.getBinding().getBindingInfo().getService().getInterface().getName().toString());
String transportType = null;
if (endpoint.getBinding() instanceof SoapBinding) {
SoapBinding soapBinding = (SoapBinding)endpoint.getBinding();
if (soapBinding.getBindingInfo() instanceof SoapBindingInfo) {
SoapBindingInfo soapBindingInfo = (SoapBindingInfo)soapBinding.getBindingInfo();
transportType = soapBindingInfo.getTransportURI();
}
}
messageInfo.setTransportType((transportType != null) ? transportType : "Unknown transport type");
originator.setProcessId(Converter.getPID());
try {
InetAddress inetAddress = InetAddress.getLocalHost();
originator.setIp(inetAddress.getHostAddress());
originator.setHostname(inetAddress.getHostName());
} catch (UnknownHostException e) {
originator.setHostname("Unknown hostname");
originator.setIp("Unknown ip address");
}
String address = endpoint.getEndpointInfo().getAddress();
event.getCustomInfo().put("address", address);
return event;
}
|
java
|
private Event createEvent(Endpoint endpoint, EventTypeEnum type) {
Event event = new Event();
MessageInfo messageInfo = new MessageInfo();
Originator originator = new Originator();
event.setMessageInfo(messageInfo);
event.setOriginator(originator);
Date date = new Date();
event.setTimestamp(date);
event.setEventType(type);
messageInfo.setPortType(
endpoint.getBinding().getBindingInfo().getService().getInterface().getName().toString());
String transportType = null;
if (endpoint.getBinding() instanceof SoapBinding) {
SoapBinding soapBinding = (SoapBinding)endpoint.getBinding();
if (soapBinding.getBindingInfo() instanceof SoapBindingInfo) {
SoapBindingInfo soapBindingInfo = (SoapBindingInfo)soapBinding.getBindingInfo();
transportType = soapBindingInfo.getTransportURI();
}
}
messageInfo.setTransportType((transportType != null) ? transportType : "Unknown transport type");
originator.setProcessId(Converter.getPID());
try {
InetAddress inetAddress = InetAddress.getLocalHost();
originator.setIp(inetAddress.getHostAddress());
originator.setHostname(inetAddress.getHostName());
} catch (UnknownHostException e) {
originator.setHostname("Unknown hostname");
originator.setIp("Unknown ip address");
}
String address = endpoint.getEndpointInfo().getAddress();
event.getCustomInfo().put("address", address);
return event;
}
|
[
"private",
"Event",
"createEvent",
"(",
"Endpoint",
"endpoint",
",",
"EventTypeEnum",
"type",
")",
"{",
"Event",
"event",
"=",
"new",
"Event",
"(",
")",
";",
"MessageInfo",
"messageInfo",
"=",
"new",
"MessageInfo",
"(",
")",
";",
"Originator",
"originator",
"=",
"new",
"Originator",
"(",
")",
";",
"event",
".",
"setMessageInfo",
"(",
"messageInfo",
")",
";",
"event",
".",
"setOriginator",
"(",
"originator",
")",
";",
"Date",
"date",
"=",
"new",
"Date",
"(",
")",
";",
"event",
".",
"setTimestamp",
"(",
"date",
")",
";",
"event",
".",
"setEventType",
"(",
"type",
")",
";",
"messageInfo",
".",
"setPortType",
"(",
"endpoint",
".",
"getBinding",
"(",
")",
".",
"getBindingInfo",
"(",
")",
".",
"getService",
"(",
")",
".",
"getInterface",
"(",
")",
".",
"getName",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"String",
"transportType",
"=",
"null",
";",
"if",
"(",
"endpoint",
".",
"getBinding",
"(",
")",
"instanceof",
"SoapBinding",
")",
"{",
"SoapBinding",
"soapBinding",
"=",
"(",
"SoapBinding",
")",
"endpoint",
".",
"getBinding",
"(",
")",
";",
"if",
"(",
"soapBinding",
".",
"getBindingInfo",
"(",
")",
"instanceof",
"SoapBindingInfo",
")",
"{",
"SoapBindingInfo",
"soapBindingInfo",
"=",
"(",
"SoapBindingInfo",
")",
"soapBinding",
".",
"getBindingInfo",
"(",
")",
";",
"transportType",
"=",
"soapBindingInfo",
".",
"getTransportURI",
"(",
")",
";",
"}",
"}",
"messageInfo",
".",
"setTransportType",
"(",
"(",
"transportType",
"!=",
"null",
")",
"?",
"transportType",
":",
"\"Unknown transport type\"",
")",
";",
"originator",
".",
"setProcessId",
"(",
"Converter",
".",
"getPID",
"(",
")",
")",
";",
"try",
"{",
"InetAddress",
"inetAddress",
"=",
"InetAddress",
".",
"getLocalHost",
"(",
")",
";",
"originator",
".",
"setIp",
"(",
"inetAddress",
".",
"getHostAddress",
"(",
")",
")",
";",
"originator",
".",
"setHostname",
"(",
"inetAddress",
".",
"getHostName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"originator",
".",
"setHostname",
"(",
"\"Unknown hostname\"",
")",
";",
"originator",
".",
"setIp",
"(",
"\"Unknown ip address\"",
")",
";",
"}",
"String",
"address",
"=",
"endpoint",
".",
"getEndpointInfo",
"(",
")",
".",
"getAddress",
"(",
")",
";",
"event",
".",
"getCustomInfo",
"(",
")",
".",
"put",
"(",
"\"address\"",
",",
"address",
")",
";",
"return",
"event",
";",
"}"
] |
Creates the event for endpoint with specific type.
@param endpoint the endpoint
@param type the type
@return the event
|
[
"Creates",
"the",
"event",
"for",
"endpoint",
"with",
"specific",
"type",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/lifecycle/AbstractListenerImpl.java#L126-L165
|
160,336 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/RESTClient.java
|
RESTClient.useOldRESTService
|
public void useOldRESTService() throws Exception {
List<Object> providers = createJAXRSProviders();
com.example.customerservice.CustomerService customerService = JAXRSClientFactory
.createFromModel("http://localhost:" + port + "/examples/direct/rest",
com.example.customerservice.CustomerService.class,
"classpath:/model/CustomerService-jaxrs.xml",
providers,
null);
System.out.println("Using old RESTful CustomerService with old client");
customer.v1.Customer customer = createOldCustomer("Smith Old REST");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Smith Old REST");
printOldCustomerDetails(customer);
}
|
java
|
public void useOldRESTService() throws Exception {
List<Object> providers = createJAXRSProviders();
com.example.customerservice.CustomerService customerService = JAXRSClientFactory
.createFromModel("http://localhost:" + port + "/examples/direct/rest",
com.example.customerservice.CustomerService.class,
"classpath:/model/CustomerService-jaxrs.xml",
providers,
null);
System.out.println("Using old RESTful CustomerService with old client");
customer.v1.Customer customer = createOldCustomer("Smith Old REST");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Smith Old REST");
printOldCustomerDetails(customer);
}
|
[
"public",
"void",
"useOldRESTService",
"(",
")",
"throws",
"Exception",
"{",
"List",
"<",
"Object",
">",
"providers",
"=",
"createJAXRSProviders",
"(",
")",
";",
"com",
".",
"example",
".",
"customerservice",
".",
"CustomerService",
"customerService",
"=",
"JAXRSClientFactory",
".",
"createFromModel",
"(",
"\"http://localhost:\"",
"+",
"port",
"+",
"\"/examples/direct/rest\"",
",",
"com",
".",
"example",
".",
"customerservice",
".",
"CustomerService",
".",
"class",
",",
"\"classpath:/model/CustomerService-jaxrs.xml\"",
",",
"providers",
",",
"null",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Using old RESTful CustomerService with old client\"",
")",
";",
"customer",
".",
"v1",
".",
"Customer",
"customer",
"=",
"createOldCustomer",
"(",
"\"Smith Old REST\"",
")",
";",
"customerService",
".",
"updateCustomer",
"(",
"customer",
")",
";",
"customer",
"=",
"customerService",
".",
"getCustomerByName",
"(",
"\"Smith Old REST\"",
")",
";",
"printOldCustomerDetails",
"(",
"customer",
")",
";",
"}"
] |
Old REST client uses old REST service
|
[
"Old",
"REST",
"client",
"uses",
"old",
"REST",
"service"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/RESTClient.java#L56-L73
|
160,337 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/RESTClient.java
|
RESTClient.useNewRESTService
|
public void useNewRESTService(String address) throws Exception {
List<Object> providers = createJAXRSProviders();
org.customer.service.CustomerService customerService = JAXRSClientFactory
.createFromModel(address,
org.customer.service.CustomerService.class,
"classpath:/model/CustomerService-jaxrs.xml",
providers,
null);
System.out.println("Using new RESTful CustomerService with new client");
customer.v2.Customer customer = createNewCustomer("Smith New REST");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Smith New REST");
printNewCustomerDetails(customer);
}
|
java
|
public void useNewRESTService(String address) throws Exception {
List<Object> providers = createJAXRSProviders();
org.customer.service.CustomerService customerService = JAXRSClientFactory
.createFromModel(address,
org.customer.service.CustomerService.class,
"classpath:/model/CustomerService-jaxrs.xml",
providers,
null);
System.out.println("Using new RESTful CustomerService with new client");
customer.v2.Customer customer = createNewCustomer("Smith New REST");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Smith New REST");
printNewCustomerDetails(customer);
}
|
[
"public",
"void",
"useNewRESTService",
"(",
"String",
"address",
")",
"throws",
"Exception",
"{",
"List",
"<",
"Object",
">",
"providers",
"=",
"createJAXRSProviders",
"(",
")",
";",
"org",
".",
"customer",
".",
"service",
".",
"CustomerService",
"customerService",
"=",
"JAXRSClientFactory",
".",
"createFromModel",
"(",
"address",
",",
"org",
".",
"customer",
".",
"service",
".",
"CustomerService",
".",
"class",
",",
"\"classpath:/model/CustomerService-jaxrs.xml\"",
",",
"providers",
",",
"null",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Using new RESTful CustomerService with new client\"",
")",
";",
"customer",
".",
"v2",
".",
"Customer",
"customer",
"=",
"createNewCustomer",
"(",
"\"Smith New REST\"",
")",
";",
"customerService",
".",
"updateCustomer",
"(",
"customer",
")",
";",
"customer",
"=",
"customerService",
".",
"getCustomerByName",
"(",
"\"Smith New REST\"",
")",
";",
"printNewCustomerDetails",
"(",
"customer",
")",
";",
"}"
] |
New REST client uses new REST service
|
[
"New",
"REST",
"client",
"uses",
"new",
"REST",
"service"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/RESTClient.java#L78-L95
|
160,338 |
Talend/tesb-rt-se
|
examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/RESTClient.java
|
RESTClient.useNewRESTServiceWithOldClient
|
public void useNewRESTServiceWithOldClient() throws Exception {
List<Object> providers = createJAXRSProviders();
com.example.customerservice.CustomerService customerService = JAXRSClientFactory
.createFromModel("http://localhost:" + port + "/examples/direct/new-rest",
com.example.customerservice.CustomerService.class,
"classpath:/model/CustomerService-jaxrs.xml",
providers,
null);
// The outgoing old Customer data needs to be transformed for
// the new service to understand it and the response from the new service
// needs to be transformed for this old client to understand it.
ClientConfiguration config = WebClient.getConfig(customerService);
addTransformInterceptors(config.getInInterceptors(),
config.getOutInterceptors(),
false);
System.out.println("Using new RESTful CustomerService with old Client");
customer.v1.Customer customer = createOldCustomer("Smith Old to New REST");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Smith Old to New REST");
printOldCustomerDetails(customer);
}
|
java
|
public void useNewRESTServiceWithOldClient() throws Exception {
List<Object> providers = createJAXRSProviders();
com.example.customerservice.CustomerService customerService = JAXRSClientFactory
.createFromModel("http://localhost:" + port + "/examples/direct/new-rest",
com.example.customerservice.CustomerService.class,
"classpath:/model/CustomerService-jaxrs.xml",
providers,
null);
// The outgoing old Customer data needs to be transformed for
// the new service to understand it and the response from the new service
// needs to be transformed for this old client to understand it.
ClientConfiguration config = WebClient.getConfig(customerService);
addTransformInterceptors(config.getInInterceptors(),
config.getOutInterceptors(),
false);
System.out.println("Using new RESTful CustomerService with old Client");
customer.v1.Customer customer = createOldCustomer("Smith Old to New REST");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Smith Old to New REST");
printOldCustomerDetails(customer);
}
|
[
"public",
"void",
"useNewRESTServiceWithOldClient",
"(",
")",
"throws",
"Exception",
"{",
"List",
"<",
"Object",
">",
"providers",
"=",
"createJAXRSProviders",
"(",
")",
";",
"com",
".",
"example",
".",
"customerservice",
".",
"CustomerService",
"customerService",
"=",
"JAXRSClientFactory",
".",
"createFromModel",
"(",
"\"http://localhost:\"",
"+",
"port",
"+",
"\"/examples/direct/new-rest\"",
",",
"com",
".",
"example",
".",
"customerservice",
".",
"CustomerService",
".",
"class",
",",
"\"classpath:/model/CustomerService-jaxrs.xml\"",
",",
"providers",
",",
"null",
")",
";",
"// The outgoing old Customer data needs to be transformed for ",
"// the new service to understand it and the response from the new service",
"// needs to be transformed for this old client to understand it.",
"ClientConfiguration",
"config",
"=",
"WebClient",
".",
"getConfig",
"(",
"customerService",
")",
";",
"addTransformInterceptors",
"(",
"config",
".",
"getInInterceptors",
"(",
")",
",",
"config",
".",
"getOutInterceptors",
"(",
")",
",",
"false",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Using new RESTful CustomerService with old Client\"",
")",
";",
"customer",
".",
"v1",
".",
"Customer",
"customer",
"=",
"createOldCustomer",
"(",
"\"Smith Old to New REST\"",
")",
";",
"customerService",
".",
"updateCustomer",
"(",
"customer",
")",
";",
"customer",
"=",
"customerService",
".",
"getCustomerByName",
"(",
"\"Smith Old to New REST\"",
")",
";",
"printOldCustomerDetails",
"(",
"customer",
")",
";",
"}"
] |
Old REST client uses new REST service
|
[
"Old",
"REST",
"client",
"uses",
"new",
"REST",
"service"
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/jaxrs-jaxws-transformations/client/src/main/java/client/RESTClient.java#L164-L190
|
160,339 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/collector/EventCollector.java
|
EventCollector.init
|
@PostConstruct
public void init() {
//init Bus and LifeCycle listeners
if (bus != null && sendLifecycleEvent ) {
ServerLifeCycleManager slcm = bus.getExtension(ServerLifeCycleManager.class);
if (null != slcm) {
ServiceListenerImpl svrListener = new ServiceListenerImpl();
svrListener.setSendLifecycleEvent(sendLifecycleEvent);
svrListener.setQueue(queue);
svrListener.setMonitoringServiceClient(monitoringServiceClient);
slcm.registerListener(svrListener);
}
ClientLifeCycleManager clcm = bus.getExtension(ClientLifeCycleManager.class);
if (null != clcm) {
ClientListenerImpl cltListener = new ClientListenerImpl();
cltListener.setSendLifecycleEvent(sendLifecycleEvent);
cltListener.setQueue(queue);
cltListener.setMonitoringServiceClient(monitoringServiceClient);
clcm.registerListener(cltListener);
}
}
if(executorQueueSize == 0) {
executor = Executors.newFixedThreadPool(this.executorPoolSize);
}else{
executor = new ThreadPoolExecutor(executorPoolSize, executorPoolSize, 0, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(executorQueueSize), Executors.defaultThreadFactory(),
new RejectedExecutionHandlerImpl());
}
scheduler = new Timer();
scheduler.scheduleAtFixedRate(new TimerTask() {
public void run() {
sendEventsFromQueue();
}
}, 0, getDefaultInterval());
}
|
java
|
@PostConstruct
public void init() {
//init Bus and LifeCycle listeners
if (bus != null && sendLifecycleEvent ) {
ServerLifeCycleManager slcm = bus.getExtension(ServerLifeCycleManager.class);
if (null != slcm) {
ServiceListenerImpl svrListener = new ServiceListenerImpl();
svrListener.setSendLifecycleEvent(sendLifecycleEvent);
svrListener.setQueue(queue);
svrListener.setMonitoringServiceClient(monitoringServiceClient);
slcm.registerListener(svrListener);
}
ClientLifeCycleManager clcm = bus.getExtension(ClientLifeCycleManager.class);
if (null != clcm) {
ClientListenerImpl cltListener = new ClientListenerImpl();
cltListener.setSendLifecycleEvent(sendLifecycleEvent);
cltListener.setQueue(queue);
cltListener.setMonitoringServiceClient(monitoringServiceClient);
clcm.registerListener(cltListener);
}
}
if(executorQueueSize == 0) {
executor = Executors.newFixedThreadPool(this.executorPoolSize);
}else{
executor = new ThreadPoolExecutor(executorPoolSize, executorPoolSize, 0, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(executorQueueSize), Executors.defaultThreadFactory(),
new RejectedExecutionHandlerImpl());
}
scheduler = new Timer();
scheduler.scheduleAtFixedRate(new TimerTask() {
public void run() {
sendEventsFromQueue();
}
}, 0, getDefaultInterval());
}
|
[
"@",
"PostConstruct",
"public",
"void",
"init",
"(",
")",
"{",
"//init Bus and LifeCycle listeners",
"if",
"(",
"bus",
"!=",
"null",
"&&",
"sendLifecycleEvent",
")",
"{",
"ServerLifeCycleManager",
"slcm",
"=",
"bus",
".",
"getExtension",
"(",
"ServerLifeCycleManager",
".",
"class",
")",
";",
"if",
"(",
"null",
"!=",
"slcm",
")",
"{",
"ServiceListenerImpl",
"svrListener",
"=",
"new",
"ServiceListenerImpl",
"(",
")",
";",
"svrListener",
".",
"setSendLifecycleEvent",
"(",
"sendLifecycleEvent",
")",
";",
"svrListener",
".",
"setQueue",
"(",
"queue",
")",
";",
"svrListener",
".",
"setMonitoringServiceClient",
"(",
"monitoringServiceClient",
")",
";",
"slcm",
".",
"registerListener",
"(",
"svrListener",
")",
";",
"}",
"ClientLifeCycleManager",
"clcm",
"=",
"bus",
".",
"getExtension",
"(",
"ClientLifeCycleManager",
".",
"class",
")",
";",
"if",
"(",
"null",
"!=",
"clcm",
")",
"{",
"ClientListenerImpl",
"cltListener",
"=",
"new",
"ClientListenerImpl",
"(",
")",
";",
"cltListener",
".",
"setSendLifecycleEvent",
"(",
"sendLifecycleEvent",
")",
";",
"cltListener",
".",
"setQueue",
"(",
"queue",
")",
";",
"cltListener",
".",
"setMonitoringServiceClient",
"(",
"monitoringServiceClient",
")",
";",
"clcm",
".",
"registerListener",
"(",
"cltListener",
")",
";",
"}",
"}",
"if",
"(",
"executorQueueSize",
"==",
"0",
")",
"{",
"executor",
"=",
"Executors",
".",
"newFixedThreadPool",
"(",
"this",
".",
"executorPoolSize",
")",
";",
"}",
"else",
"{",
"executor",
"=",
"new",
"ThreadPoolExecutor",
"(",
"executorPoolSize",
",",
"executorPoolSize",
",",
"0",
",",
"TimeUnit",
".",
"SECONDS",
",",
"new",
"LinkedBlockingQueue",
"<",
"Runnable",
">",
"(",
"executorQueueSize",
")",
",",
"Executors",
".",
"defaultThreadFactory",
"(",
")",
",",
"new",
"RejectedExecutionHandlerImpl",
"(",
")",
")",
";",
"}",
"scheduler",
"=",
"new",
"Timer",
"(",
")",
";",
"scheduler",
".",
"scheduleAtFixedRate",
"(",
"new",
"TimerTask",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"sendEventsFromQueue",
"(",
")",
";",
"}",
"}",
",",
"0",
",",
"getDefaultInterval",
"(",
")",
")",
";",
"}"
] |
Instantiates a new event collector.
|
[
"Instantiates",
"a",
"new",
"event",
"collector",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/collector/EventCollector.java#L107-L144
|
160,340 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/collector/EventCollector.java
|
EventCollector.setDefaultInterval
|
public void setDefaultInterval(long defaultInterval) {
if(defaultInterval <= 0) {
LOG.severe("collector.scheduler.interval must be greater than 0. Recommended value is 500-1000. Current value is " + defaultInterval);
throw new IllegalArgumentException("collector.scheduler.interval must be greater than 0. Recommended value is 500-1000. Current value is " + defaultInterval);
}
this.defaultInterval = defaultInterval;
}
|
java
|
public void setDefaultInterval(long defaultInterval) {
if(defaultInterval <= 0) {
LOG.severe("collector.scheduler.interval must be greater than 0. Recommended value is 500-1000. Current value is " + defaultInterval);
throw new IllegalArgumentException("collector.scheduler.interval must be greater than 0. Recommended value is 500-1000. Current value is " + defaultInterval);
}
this.defaultInterval = defaultInterval;
}
|
[
"public",
"void",
"setDefaultInterval",
"(",
"long",
"defaultInterval",
")",
"{",
"if",
"(",
"defaultInterval",
"<=",
"0",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"collector.scheduler.interval must be greater than 0. Recommended value is 500-1000. Current value is \"",
"+",
"defaultInterval",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"collector.scheduler.interval must be greater than 0. Recommended value is 500-1000. Current value is \"",
"+",
"defaultInterval",
")",
";",
"}",
"this",
".",
"defaultInterval",
"=",
"defaultInterval",
";",
"}"
] |
Set default interval for sending events to monitoring service. DefaultInterval will be used by
scheduler.
@param defaultInterval the new default interval
|
[
"Set",
"default",
"interval",
"for",
"sending",
"events",
"to",
"monitoring",
"service",
".",
"DefaultInterval",
"will",
"be",
"used",
"by",
"scheduler",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/collector/EventCollector.java#L192-L198
|
160,341 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/collector/EventCollector.java
|
EventCollector.sendEventsFromQueue
|
public void sendEventsFromQueue() {
if (null == queue || stopSending) {
return;
}
LOG.fine("Scheduler called for sending events");
int packageSize = getEventsPerMessageCall();
while (!queue.isEmpty()) {
final List<Event> list = new ArrayList<Event>();
int i = 0;
while (i < packageSize && !queue.isEmpty()) {
Event event = queue.remove();
if (event != null && !filter(event)) {
list.add(event);
i++;
}
}
if (list.size() > 0) {
executor.execute(new Runnable() {
public void run() {
try {
sendEvents(list);
} catch (MonitoringException e) {
e.logException(Level.SEVERE);
}
}
});
}
}
}
|
java
|
public void sendEventsFromQueue() {
if (null == queue || stopSending) {
return;
}
LOG.fine("Scheduler called for sending events");
int packageSize = getEventsPerMessageCall();
while (!queue.isEmpty()) {
final List<Event> list = new ArrayList<Event>();
int i = 0;
while (i < packageSize && !queue.isEmpty()) {
Event event = queue.remove();
if (event != null && !filter(event)) {
list.add(event);
i++;
}
}
if (list.size() > 0) {
executor.execute(new Runnable() {
public void run() {
try {
sendEvents(list);
} catch (MonitoringException e) {
e.logException(Level.SEVERE);
}
}
});
}
}
}
|
[
"public",
"void",
"sendEventsFromQueue",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"queue",
"||",
"stopSending",
")",
"{",
"return",
";",
"}",
"LOG",
".",
"fine",
"(",
"\"Scheduler called for sending events\"",
")",
";",
"int",
"packageSize",
"=",
"getEventsPerMessageCall",
"(",
")",
";",
"while",
"(",
"!",
"queue",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"List",
"<",
"Event",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"Event",
">",
"(",
")",
";",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"packageSize",
"&&",
"!",
"queue",
".",
"isEmpty",
"(",
")",
")",
"{",
"Event",
"event",
"=",
"queue",
".",
"remove",
"(",
")",
";",
"if",
"(",
"event",
"!=",
"null",
"&&",
"!",
"filter",
"(",
"event",
")",
")",
"{",
"list",
".",
"add",
"(",
"event",
")",
";",
"i",
"++",
";",
"}",
"}",
"if",
"(",
"list",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"executor",
".",
"execute",
"(",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"sendEvents",
"(",
"list",
")",
";",
"}",
"catch",
"(",
"MonitoringException",
"e",
")",
"{",
"e",
".",
"logException",
"(",
"Level",
".",
"SEVERE",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"}",
"}"
] |
Method will be executed asynchronously.
|
[
"Method",
"will",
"be",
"executed",
"asynchronously",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/collector/EventCollector.java#L293-L325
|
160,342 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/collector/EventCollector.java
|
EventCollector.sendEvents
|
private void sendEvents(final List<Event> events) {
if (null != handlers) {
for (EventHandler current : handlers) {
for (Event event : events) {
current.handleEvent(event);
}
}
}
LOG.info("Put events(" + events.size() + ") to Monitoring Server.");
try {
if (sendToEventadmin) {
EventAdminPublisher.publish(events);
} else {
monitoringServiceClient.putEvents(events);
}
} catch (MonitoringException e) {
throw e;
} catch (Exception e) {
throw new MonitoringException("002",
"Unknown error while execute put events to Monitoring Server", e);
}
}
|
java
|
private void sendEvents(final List<Event> events) {
if (null != handlers) {
for (EventHandler current : handlers) {
for (Event event : events) {
current.handleEvent(event);
}
}
}
LOG.info("Put events(" + events.size() + ") to Monitoring Server.");
try {
if (sendToEventadmin) {
EventAdminPublisher.publish(events);
} else {
monitoringServiceClient.putEvents(events);
}
} catch (MonitoringException e) {
throw e;
} catch (Exception e) {
throw new MonitoringException("002",
"Unknown error while execute put events to Monitoring Server", e);
}
}
|
[
"private",
"void",
"sendEvents",
"(",
"final",
"List",
"<",
"Event",
">",
"events",
")",
"{",
"if",
"(",
"null",
"!=",
"handlers",
")",
"{",
"for",
"(",
"EventHandler",
"current",
":",
"handlers",
")",
"{",
"for",
"(",
"Event",
"event",
":",
"events",
")",
"{",
"current",
".",
"handleEvent",
"(",
"event",
")",
";",
"}",
"}",
"}",
"LOG",
".",
"info",
"(",
"\"Put events(\"",
"+",
"events",
".",
"size",
"(",
")",
"+",
"\") to Monitoring Server.\"",
")",
";",
"try",
"{",
"if",
"(",
"sendToEventadmin",
")",
"{",
"EventAdminPublisher",
".",
"publish",
"(",
"events",
")",
";",
"}",
"else",
"{",
"monitoringServiceClient",
".",
"putEvents",
"(",
"events",
")",
";",
"}",
"}",
"catch",
"(",
"MonitoringException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"MonitoringException",
"(",
"\"002\"",
",",
"\"Unknown error while execute put events to Monitoring Server\"",
",",
"e",
")",
";",
"}",
"}"
] |
Sends the events to monitoring service client.
@param events the events
|
[
"Sends",
"the",
"events",
"to",
"monitoring",
"service",
"client",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/collector/EventCollector.java#L349-L373
|
160,343 |
Talend/tesb-rt-se
|
job/controller/src/main/java/org/talend/esb/job/controller/internal/SingleThreadedOperation.java
|
SingleThreadedOperation.start
|
@Override
public void start(String[] arguments) {
boolean notStarted = !started.getAndSet(true);
if (notStarted) {
start(new SingleInstanceWorkloadStrategy(job, name, arguments, endpointRegistry, execService));
}
}
|
java
|
@Override
public void start(String[] arguments) {
boolean notStarted = !started.getAndSet(true);
if (notStarted) {
start(new SingleInstanceWorkloadStrategy(job, name, arguments, endpointRegistry, execService));
}
}
|
[
"@",
"Override",
"public",
"void",
"start",
"(",
"String",
"[",
"]",
"arguments",
")",
"{",
"boolean",
"notStarted",
"=",
"!",
"started",
".",
"getAndSet",
"(",
"true",
")",
";",
"if",
"(",
"notStarted",
")",
"{",
"start",
"(",
"new",
"SingleInstanceWorkloadStrategy",
"(",
"job",
",",
"name",
",",
"arguments",
",",
"endpointRegistry",
",",
"execService",
")",
")",
";",
"}",
"}"
] |
Starts the one and only job instance in a separate Thread. Should be called exactly one time before
the operation is stopped.
@param arguments {@inheritDoc}
|
[
"Starts",
"the",
"one",
"and",
"only",
"job",
"instance",
"in",
"a",
"separate",
"Thread",
".",
"Should",
"be",
"called",
"exactly",
"one",
"time",
"before",
"the",
"operation",
"is",
"stopped",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/job/controller/src/main/java/org/talend/esb/job/controller/internal/SingleThreadedOperation.java#L69-L75
|
160,344 |
Talend/tesb-rt-se
|
policies/correlationid-policy/src/main/java/org/talend/esb/policy/correlation/impl/CorrelationIdProtocolHeaderCodec.java
|
CorrelationIdProtocolHeaderCodec.writeCorrelationId
|
public static void writeCorrelationId(Message message, String correlationId) {
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
headers.put(CORRELATIONID_HTTP_HEADER_NAME, Collections.singletonList(correlationId));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + CORRELATIONID_HTTP_HEADER_NAME + "' set to: " + correlationId);
}
}
|
java
|
public static void writeCorrelationId(Message message, String correlationId) {
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
headers.put(CORRELATIONID_HTTP_HEADER_NAME, Collections.singletonList(correlationId));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + CORRELATIONID_HTTP_HEADER_NAME + "' set to: " + correlationId);
}
}
|
[
"public",
"static",
"void",
"writeCorrelationId",
"(",
"Message",
"message",
",",
"String",
"correlationId",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
"=",
"getOrCreateProtocolHeader",
"(",
"message",
")",
";",
"headers",
".",
"put",
"(",
"CORRELATIONID_HTTP_HEADER_NAME",
",",
"Collections",
".",
"singletonList",
"(",
"correlationId",
")",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"HTTP header '\"",
"+",
"CORRELATIONID_HTTP_HEADER_NAME",
"+",
"\"' set to: \"",
"+",
"correlationId",
")",
";",
"}",
"}"
] |
Write correlation id.
@param message the message
@param correlationId the correlation id
|
[
"Write",
"correlation",
"id",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/policies/correlationid-policy/src/main/java/org/talend/esb/policy/correlation/impl/CorrelationIdProtocolHeaderCodec.java#L77-L83
|
160,345 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProtocolHeaderCodec.java
|
FlowIdProtocolHeaderCodec.readFlowId
|
public static String readFlowId(Message message) {
String flowId = null;
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
List<String> flowIds = headers.get(FLOWID_HTTP_HEADER_NAME);
if (flowIds != null && flowIds.size() > 0) {
flowId = flowIds.get(0);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + FLOWID_HTTP_HEADER_NAME + "' found: " + flowId);
}
} else {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("No HTTP header '" + FLOWID_HTTP_HEADER_NAME + "' found");
}
}
return flowId;
}
|
java
|
public static String readFlowId(Message message) {
String flowId = null;
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
List<String> flowIds = headers.get(FLOWID_HTTP_HEADER_NAME);
if (flowIds != null && flowIds.size() > 0) {
flowId = flowIds.get(0);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + FLOWID_HTTP_HEADER_NAME + "' found: " + flowId);
}
} else {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("No HTTP header '" + FLOWID_HTTP_HEADER_NAME + "' found");
}
}
return flowId;
}
|
[
"public",
"static",
"String",
"readFlowId",
"(",
"Message",
"message",
")",
"{",
"String",
"flowId",
"=",
"null",
";",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
"=",
"getOrCreateProtocolHeader",
"(",
"message",
")",
";",
"List",
"<",
"String",
">",
"flowIds",
"=",
"headers",
".",
"get",
"(",
"FLOWID_HTTP_HEADER_NAME",
")",
";",
"if",
"(",
"flowIds",
"!=",
"null",
"&&",
"flowIds",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"flowId",
"=",
"flowIds",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"HTTP header '\"",
"+",
"FLOWID_HTTP_HEADER_NAME",
"+",
"\"' found: \"",
"+",
"flowId",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"No HTTP header '\"",
"+",
"FLOWID_HTTP_HEADER_NAME",
"+",
"\"' found\"",
")",
";",
"}",
"}",
"return",
"flowId",
";",
"}"
] |
Read flow id from message.
@param message the message
@return the FlowId as string
|
[
"Read",
"flow",
"id",
"from",
"message",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProtocolHeaderCodec.java#L53-L69
|
160,346 |
Talend/tesb-rt-se
|
sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProtocolHeaderCodec.java
|
FlowIdProtocolHeaderCodec.writeFlowId
|
public static void writeFlowId(Message message, String flowId) {
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
headers.put(FLOWID_HTTP_HEADER_NAME, Collections.singletonList(flowId));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + FLOWID_HTTP_HEADER_NAME + "' set to: " + flowId);
}
}
|
java
|
public static void writeFlowId(Message message, String flowId) {
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
headers.put(FLOWID_HTTP_HEADER_NAME, Collections.singletonList(flowId));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + FLOWID_HTTP_HEADER_NAME + "' set to: " + flowId);
}
}
|
[
"public",
"static",
"void",
"writeFlowId",
"(",
"Message",
"message",
",",
"String",
"flowId",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
"=",
"getOrCreateProtocolHeader",
"(",
"message",
")",
";",
"headers",
".",
"put",
"(",
"FLOWID_HTTP_HEADER_NAME",
",",
"Collections",
".",
"singletonList",
"(",
"flowId",
")",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"HTTP header '\"",
"+",
"FLOWID_HTTP_HEADER_NAME",
"+",
"\"' set to: \"",
"+",
"flowId",
")",
";",
"}",
"}"
] |
Write flow id.
@param message the message
@param flowId the flow id
|
[
"Write",
"flow",
"id",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProtocolHeaderCodec.java#L77-L83
|
160,347 |
Talend/tesb-rt-se
|
examples/cxf/interceptors/common/src/main/java/demo/interceptors/interceptor/DemoInterceptor.java
|
DemoInterceptor.addInterceptors
|
public static void addInterceptors(InterceptorProvider provider) {
PhaseManager phases = BusFactory.getDefaultBus().getExtension(PhaseManager.class);
for (Phase p : phases.getInPhases()) {
provider.getInInterceptors().add(new DemoInterceptor(p.getName()));
provider.getInFaultInterceptors().add(new DemoInterceptor(p.getName()));
}
for (Phase p : phases.getOutPhases()) {
provider.getOutInterceptors().add(new DemoInterceptor(p.getName()));
provider.getOutFaultInterceptors().add(new DemoInterceptor(p.getName()));
}
}
|
java
|
public static void addInterceptors(InterceptorProvider provider) {
PhaseManager phases = BusFactory.getDefaultBus().getExtension(PhaseManager.class);
for (Phase p : phases.getInPhases()) {
provider.getInInterceptors().add(new DemoInterceptor(p.getName()));
provider.getInFaultInterceptors().add(new DemoInterceptor(p.getName()));
}
for (Phase p : phases.getOutPhases()) {
provider.getOutInterceptors().add(new DemoInterceptor(p.getName()));
provider.getOutFaultInterceptors().add(new DemoInterceptor(p.getName()));
}
}
|
[
"public",
"static",
"void",
"addInterceptors",
"(",
"InterceptorProvider",
"provider",
")",
"{",
"PhaseManager",
"phases",
"=",
"BusFactory",
".",
"getDefaultBus",
"(",
")",
".",
"getExtension",
"(",
"PhaseManager",
".",
"class",
")",
";",
"for",
"(",
"Phase",
"p",
":",
"phases",
".",
"getInPhases",
"(",
")",
")",
"{",
"provider",
".",
"getInInterceptors",
"(",
")",
".",
"add",
"(",
"new",
"DemoInterceptor",
"(",
"p",
".",
"getName",
"(",
")",
")",
")",
";",
"provider",
".",
"getInFaultInterceptors",
"(",
")",
".",
"add",
"(",
"new",
"DemoInterceptor",
"(",
"p",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"for",
"(",
"Phase",
"p",
":",
"phases",
".",
"getOutPhases",
"(",
")",
")",
"{",
"provider",
".",
"getOutInterceptors",
"(",
")",
".",
"add",
"(",
"new",
"DemoInterceptor",
"(",
"p",
".",
"getName",
"(",
")",
")",
")",
";",
"provider",
".",
"getOutFaultInterceptors",
"(",
")",
".",
"add",
"(",
"new",
"DemoInterceptor",
"(",
"p",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"}"
] |
This method will add a DemoInterceptor into every in and every out phase
of the interceptor chains.
@param provider
|
[
"This",
"method",
"will",
"add",
"a",
"DemoInterceptor",
"into",
"every",
"in",
"and",
"every",
"out",
"phase",
"of",
"the",
"interceptor",
"chains",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/interceptors/common/src/main/java/demo/interceptors/interceptor/DemoInterceptor.java#L46-L56
|
160,348 |
Talend/tesb-rt-se
|
examples/cxf/interceptors/common/src/main/java/demo/interceptors/interceptor/DemoInterceptor.java
|
DemoInterceptor.somethingMayHaveChanged
|
private boolean somethingMayHaveChanged(PhaseInterceptorChain pic) {
Iterator<Interceptor<? extends Message>> it = pic.iterator();
Interceptor<? extends Message> last = null;
while (it.hasNext()) {
Interceptor<? extends Message> cur = it.next();
if (cur == this) {
if (last instanceof DemoInterceptor) {
return false;
}
return true;
}
last = cur;
}
return true;
}
|
java
|
private boolean somethingMayHaveChanged(PhaseInterceptorChain pic) {
Iterator<Interceptor<? extends Message>> it = pic.iterator();
Interceptor<? extends Message> last = null;
while (it.hasNext()) {
Interceptor<? extends Message> cur = it.next();
if (cur == this) {
if (last instanceof DemoInterceptor) {
return false;
}
return true;
}
last = cur;
}
return true;
}
|
[
"private",
"boolean",
"somethingMayHaveChanged",
"(",
"PhaseInterceptorChain",
"pic",
")",
"{",
"Iterator",
"<",
"Interceptor",
"<",
"?",
"extends",
"Message",
">",
">",
"it",
"=",
"pic",
".",
"iterator",
"(",
")",
";",
"Interceptor",
"<",
"?",
"extends",
"Message",
">",
"last",
"=",
"null",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Interceptor",
"<",
"?",
"extends",
"Message",
">",
"cur",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"cur",
"==",
"this",
")",
"{",
"if",
"(",
"last",
"instanceof",
"DemoInterceptor",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"last",
"=",
"cur",
";",
"}",
"return",
"true",
";",
"}"
] |
as we know nothing has changed.
|
[
"as",
"we",
"know",
"nothing",
"has",
"changed",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/interceptors/common/src/main/java/demo/interceptors/interceptor/DemoInterceptor.java#L94-L108
|
160,349 |
Talend/tesb-rt-se
|
examples/cxf/interceptors/common/src/main/java/demo/interceptors/interceptor/DemoInterceptor.java
|
DemoInterceptor.printInterceptorChain
|
public void printInterceptorChain(InterceptorChain chain) {
Iterator<Interceptor<? extends Message>> it = chain.iterator();
String phase = "";
StringBuilder builder = null;
while (it.hasNext()) {
Interceptor<? extends Message> interceptor = it.next();
if (interceptor instanceof DemoInterceptor) {
continue;
}
if (interceptor instanceof PhaseInterceptor) {
PhaseInterceptor pi = (PhaseInterceptor)interceptor;
if (!phase.equals(pi.getPhase())) {
if (builder != null) {
System.out.println(builder.toString());
} else {
builder = new StringBuilder(100);
}
builder.setLength(0);
builder.append(" ");
builder.append(pi.getPhase());
builder.append(": ");
phase = pi.getPhase();
}
String id = pi.getId();
int idx = id.lastIndexOf('.');
if (idx != -1) {
id = id.substring(idx + 1);
}
builder.append(id);
builder.append(' ');
}
}
}
|
java
|
public void printInterceptorChain(InterceptorChain chain) {
Iterator<Interceptor<? extends Message>> it = chain.iterator();
String phase = "";
StringBuilder builder = null;
while (it.hasNext()) {
Interceptor<? extends Message> interceptor = it.next();
if (interceptor instanceof DemoInterceptor) {
continue;
}
if (interceptor instanceof PhaseInterceptor) {
PhaseInterceptor pi = (PhaseInterceptor)interceptor;
if (!phase.equals(pi.getPhase())) {
if (builder != null) {
System.out.println(builder.toString());
} else {
builder = new StringBuilder(100);
}
builder.setLength(0);
builder.append(" ");
builder.append(pi.getPhase());
builder.append(": ");
phase = pi.getPhase();
}
String id = pi.getId();
int idx = id.lastIndexOf('.');
if (idx != -1) {
id = id.substring(idx + 1);
}
builder.append(id);
builder.append(' ');
}
}
}
|
[
"public",
"void",
"printInterceptorChain",
"(",
"InterceptorChain",
"chain",
")",
"{",
"Iterator",
"<",
"Interceptor",
"<",
"?",
"extends",
"Message",
">",
">",
"it",
"=",
"chain",
".",
"iterator",
"(",
")",
";",
"String",
"phase",
"=",
"\"\"",
";",
"StringBuilder",
"builder",
"=",
"null",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Interceptor",
"<",
"?",
"extends",
"Message",
">",
"interceptor",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"interceptor",
"instanceof",
"DemoInterceptor",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"interceptor",
"instanceof",
"PhaseInterceptor",
")",
"{",
"PhaseInterceptor",
"pi",
"=",
"(",
"PhaseInterceptor",
")",
"interceptor",
";",
"if",
"(",
"!",
"phase",
".",
"equals",
"(",
"pi",
".",
"getPhase",
"(",
")",
")",
")",
"{",
"if",
"(",
"builder",
"!=",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"builder",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"{",
"builder",
"=",
"new",
"StringBuilder",
"(",
"100",
")",
";",
"}",
"builder",
".",
"setLength",
"(",
"0",
")",
";",
"builder",
".",
"append",
"(",
"\" \"",
")",
";",
"builder",
".",
"append",
"(",
"pi",
".",
"getPhase",
"(",
")",
")",
";",
"builder",
".",
"append",
"(",
"\": \"",
")",
";",
"phase",
"=",
"pi",
".",
"getPhase",
"(",
")",
";",
"}",
"String",
"id",
"=",
"pi",
".",
"getId",
"(",
")",
";",
"int",
"idx",
"=",
"id",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"idx",
"!=",
"-",
"1",
")",
"{",
"id",
"=",
"id",
".",
"substring",
"(",
"idx",
"+",
"1",
")",
";",
"}",
"builder",
".",
"append",
"(",
"id",
")",
";",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"}"
] |
Prints out the interceptor chain in a format that is easy to read. It
also filters out instances of the DemoInterceptor so you can see what the
chain would look like in a normal invokation.
@param chain
|
[
"Prints",
"out",
"the",
"interceptor",
"chain",
"in",
"a",
"format",
"that",
"is",
"easy",
"to",
"read",
".",
"It",
"also",
"filters",
"out",
"instances",
"of",
"the",
"DemoInterceptor",
"so",
"you",
"can",
"see",
"what",
"the",
"chain",
"would",
"look",
"like",
"in",
"a",
"normal",
"invokation",
"."
] |
0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/examples/cxf/interceptors/common/src/main/java/demo/interceptors/interceptor/DemoInterceptor.java#L117-L150
|
160,350 |
burberius/eve-esi
|
src/main/java/net/troja/eve/esi/api/LocationApi.java
|
LocationApi.getCharactersCharacterIdShipCall
|
public com.squareup.okhttp.Call getCharactersCharacterIdShipCall(Integer characterId, String datasource,
String ifNoneMatch, String token, final ApiCallback callback) throws ApiException {
Object localVarPostBody = new Object();
// create path and map variables
String localVarPath = "/v1/characters/{character_id}/ship/".replaceAll("\\{" + "character_id" + "\\}",
apiClient.escapeString(characterId.toString()));
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (datasource != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("datasource", datasource));
}
if (token != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("token", token));
}
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
if (ifNoneMatch != null) {
localVarHeaderParams.put("If-None-Match", apiClient.parameterToString(ifNoneMatch));
}
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { "application/json" };
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
String[] localVarAuthNames = new String[] { "evesso" };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams,
localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, callback);
}
|
java
|
public com.squareup.okhttp.Call getCharactersCharacterIdShipCall(Integer characterId, String datasource,
String ifNoneMatch, String token, final ApiCallback callback) throws ApiException {
Object localVarPostBody = new Object();
// create path and map variables
String localVarPath = "/v1/characters/{character_id}/ship/".replaceAll("\\{" + "character_id" + "\\}",
apiClient.escapeString(characterId.toString()));
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (datasource != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("datasource", datasource));
}
if (token != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("token", token));
}
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
if (ifNoneMatch != null) {
localVarHeaderParams.put("If-None-Match", apiClient.parameterToString(ifNoneMatch));
}
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { "application/json" };
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
String[] localVarAuthNames = new String[] { "evesso" };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams,
localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, callback);
}
|
[
"public",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"getCharactersCharacterIdShipCall",
"(",
"Integer",
"characterId",
",",
"String",
"datasource",
",",
"String",
"ifNoneMatch",
",",
"String",
"token",
",",
"final",
"ApiCallback",
"callback",
")",
"throws",
"ApiException",
"{",
"Object",
"localVarPostBody",
"=",
"new",
"Object",
"(",
")",
";",
"// create path and map variables",
"String",
"localVarPath",
"=",
"\"/v1/characters/{character_id}/ship/\"",
".",
"replaceAll",
"(",
"\"\\\\{\"",
"+",
"\"character_id\"",
"+",
"\"\\\\}\"",
",",
"apiClient",
".",
"escapeString",
"(",
"characterId",
".",
"toString",
"(",
")",
")",
")",
";",
"List",
"<",
"Pair",
">",
"localVarQueryParams",
"=",
"new",
"ArrayList",
"<",
"Pair",
">",
"(",
")",
";",
"List",
"<",
"Pair",
">",
"localVarCollectionQueryParams",
"=",
"new",
"ArrayList",
"<",
"Pair",
">",
"(",
")",
";",
"if",
"(",
"datasource",
"!=",
"null",
")",
"{",
"localVarQueryParams",
".",
"addAll",
"(",
"apiClient",
".",
"parameterToPair",
"(",
"\"datasource\"",
",",
"datasource",
")",
")",
";",
"}",
"if",
"(",
"token",
"!=",
"null",
")",
"{",
"localVarQueryParams",
".",
"addAll",
"(",
"apiClient",
".",
"parameterToPair",
"(",
"\"token\"",
",",
"token",
")",
")",
";",
"}",
"Map",
"<",
"String",
",",
"String",
">",
"localVarHeaderParams",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"ifNoneMatch",
"!=",
"null",
")",
"{",
"localVarHeaderParams",
".",
"put",
"(",
"\"If-None-Match\"",
",",
"apiClient",
".",
"parameterToString",
"(",
"ifNoneMatch",
")",
")",
";",
"}",
"Map",
"<",
"String",
",",
"Object",
">",
"localVarFormParams",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"final",
"String",
"[",
"]",
"localVarAccepts",
"=",
"{",
"\"application/json\"",
"}",
";",
"final",
"String",
"localVarAccept",
"=",
"apiClient",
".",
"selectHeaderAccept",
"(",
"localVarAccepts",
")",
";",
"if",
"(",
"localVarAccept",
"!=",
"null",
")",
"{",
"localVarHeaderParams",
".",
"put",
"(",
"\"Accept\"",
",",
"localVarAccept",
")",
";",
"}",
"final",
"String",
"[",
"]",
"localVarContentTypes",
"=",
"{",
"}",
";",
"final",
"String",
"localVarContentType",
"=",
"apiClient",
".",
"selectHeaderContentType",
"(",
"localVarContentTypes",
")",
";",
"localVarHeaderParams",
".",
"put",
"(",
"\"Content-Type\"",
",",
"localVarContentType",
")",
";",
"String",
"[",
"]",
"localVarAuthNames",
"=",
"new",
"String",
"[",
"]",
"{",
"\"evesso\"",
"}",
";",
"return",
"apiClient",
".",
"buildCall",
"(",
"localVarPath",
",",
"\"GET\"",
",",
"localVarQueryParams",
",",
"localVarCollectionQueryParams",
",",
"localVarPostBody",
",",
"localVarHeaderParams",
",",
"localVarFormParams",
",",
"localVarAuthNames",
",",
"callback",
")",
";",
"}"
] |
Build call for getCharactersCharacterIdShip
@param characterId
An EVE character ID (required)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param ifNoneMatch
ETag from a previous request. A 304 will be returned if this
matches the current ETag (optional)
@param token
Access token to use if unable to set a header (optional)
@param callback
Callback for upload/download progress
@return Call to execute
@throws ApiException
If fail to serialize the request body object
|
[
"Build",
"call",
"for",
"getCharactersCharacterIdShip"
] |
24a941c592cfc15f23471ef849b282fbc582ca13
|
https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/api/LocationApi.java#L409-L448
|
160,351 |
burberius/eve-esi
|
src/main/java/net/troja/eve/esi/auth/OAuth.java
|
OAuth.getAuthorizationUri
|
public String getAuthorizationUri(final String redirectUri, final Set<String> scopes, final String state) {
if (account == null)
throw new IllegalArgumentException("Auth is not set");
if (account.getClientId() == null)
throw new IllegalArgumentException("client_id is not set");
StringBuilder builder = new StringBuilder();
builder.append(URI_AUTHENTICATION);
builder.append("?");
builder.append("response_type=");
builder.append(encode("code"));
builder.append("&redirect_uri=");
builder.append(encode(redirectUri));
builder.append("&client_id=");
builder.append(encode(account.getClientId()));
builder.append("&scope=");
builder.append(encode(getScopesString(scopes)));
builder.append("&state=");
builder.append(encode(state));
builder.append("&code_challenge");
builder.append(getCodeChallenge()); // Already url encoded
builder.append("&code_challenge_method=");
builder.append(encode("S256"));
return builder.toString();
}
|
java
|
public String getAuthorizationUri(final String redirectUri, final Set<String> scopes, final String state) {
if (account == null)
throw new IllegalArgumentException("Auth is not set");
if (account.getClientId() == null)
throw new IllegalArgumentException("client_id is not set");
StringBuilder builder = new StringBuilder();
builder.append(URI_AUTHENTICATION);
builder.append("?");
builder.append("response_type=");
builder.append(encode("code"));
builder.append("&redirect_uri=");
builder.append(encode(redirectUri));
builder.append("&client_id=");
builder.append(encode(account.getClientId()));
builder.append("&scope=");
builder.append(encode(getScopesString(scopes)));
builder.append("&state=");
builder.append(encode(state));
builder.append("&code_challenge");
builder.append(getCodeChallenge()); // Already url encoded
builder.append("&code_challenge_method=");
builder.append(encode("S256"));
return builder.toString();
}
|
[
"public",
"String",
"getAuthorizationUri",
"(",
"final",
"String",
"redirectUri",
",",
"final",
"Set",
"<",
"String",
">",
"scopes",
",",
"final",
"String",
"state",
")",
"{",
"if",
"(",
"account",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Auth is not set\"",
")",
";",
"if",
"(",
"account",
".",
"getClientId",
"(",
")",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"client_id is not set\"",
")",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"URI_AUTHENTICATION",
")",
";",
"builder",
".",
"append",
"(",
"\"?\"",
")",
";",
"builder",
".",
"append",
"(",
"\"response_type=\"",
")",
";",
"builder",
".",
"append",
"(",
"encode",
"(",
"\"code\"",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"&redirect_uri=\"",
")",
";",
"builder",
".",
"append",
"(",
"encode",
"(",
"redirectUri",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"&client_id=\"",
")",
";",
"builder",
".",
"append",
"(",
"encode",
"(",
"account",
".",
"getClientId",
"(",
")",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"&scope=\"",
")",
";",
"builder",
".",
"append",
"(",
"encode",
"(",
"getScopesString",
"(",
"scopes",
")",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"&state=\"",
")",
";",
"builder",
".",
"append",
"(",
"encode",
"(",
"state",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"&code_challenge\"",
")",
";",
"builder",
".",
"append",
"(",
"getCodeChallenge",
"(",
")",
")",
";",
"// Already url encoded",
"builder",
".",
"append",
"(",
"\"&code_challenge_method=\"",
")",
";",
"builder",
".",
"append",
"(",
"encode",
"(",
"\"S256\"",
")",
")",
";",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
Get the authorization uri, where the user logs in.
@param redirectUri
Uri the user is redirected to, after successful authorization.
This must be the same as specified at the Eve Online developer
page.
@param scopes
Scopes of the Eve Online SSO.
@param state
This should be some secret to prevent XRSF, please read:
http://www.thread-safe.com/2014/05/the-correct-use-of-state-
parameter-in.html
@return
|
[
"Get",
"the",
"authorization",
"uri",
"where",
"the",
"user",
"logs",
"in",
"."
] |
24a941c592cfc15f23471ef849b282fbc582ca13
|
https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/auth/OAuth.java#L163-L186
|
160,352 |
burberius/eve-esi
|
src/main/java/net/troja/eve/esi/auth/OAuth.java
|
OAuth.finishFlow
|
public void finishFlow(final String code, final String state) throws ApiException {
if (account == null)
throw new IllegalArgumentException("Auth is not set");
if (codeVerifier == null)
throw new IllegalArgumentException("code_verifier is not set");
if (account.getClientId() == null)
throw new IllegalArgumentException("client_id is not set");
StringBuilder builder = new StringBuilder();
builder.append("grant_type=");
builder.append(encode("authorization_code"));
builder.append("&client_id=");
builder.append(encode(account.getClientId()));
builder.append("&code=");
builder.append(encode(code));
builder.append("&code_verifier=");
builder.append(encode(codeVerifier));
update(account, builder.toString());
}
|
java
|
public void finishFlow(final String code, final String state) throws ApiException {
if (account == null)
throw new IllegalArgumentException("Auth is not set");
if (codeVerifier == null)
throw new IllegalArgumentException("code_verifier is not set");
if (account.getClientId() == null)
throw new IllegalArgumentException("client_id is not set");
StringBuilder builder = new StringBuilder();
builder.append("grant_type=");
builder.append(encode("authorization_code"));
builder.append("&client_id=");
builder.append(encode(account.getClientId()));
builder.append("&code=");
builder.append(encode(code));
builder.append("&code_verifier=");
builder.append(encode(codeVerifier));
update(account, builder.toString());
}
|
[
"public",
"void",
"finishFlow",
"(",
"final",
"String",
"code",
",",
"final",
"String",
"state",
")",
"throws",
"ApiException",
"{",
"if",
"(",
"account",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Auth is not set\"",
")",
";",
"if",
"(",
"codeVerifier",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"code_verifier is not set\"",
")",
";",
"if",
"(",
"account",
".",
"getClientId",
"(",
")",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"client_id is not set\"",
")",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"\"grant_type=\"",
")",
";",
"builder",
".",
"append",
"(",
"encode",
"(",
"\"authorization_code\"",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"&client_id=\"",
")",
";",
"builder",
".",
"append",
"(",
"encode",
"(",
"account",
".",
"getClientId",
"(",
")",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"&code=\"",
")",
";",
"builder",
".",
"append",
"(",
"encode",
"(",
"code",
")",
")",
";",
"builder",
".",
"append",
"(",
"\"&code_verifier=\"",
")",
";",
"builder",
".",
"append",
"(",
"encode",
"(",
"codeVerifier",
")",
")",
";",
"update",
"(",
"account",
",",
"builder",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Finish the oauth flow after the user was redirected back.
@param code
Code returned by the Eve Online SSO
@param state
This should be some secret to prevent XRSF see
getAuthorizationUri
@throws net.troja.eve.esi.ApiException
|
[
"Finish",
"the",
"oauth",
"flow",
"after",
"the",
"user",
"was",
"redirected",
"back",
"."
] |
24a941c592cfc15f23471ef849b282fbc582ca13
|
https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/auth/OAuth.java#L198-L215
|
160,353 |
burberius/eve-esi
|
src/main/java/net/troja/eve/esi/api/MetaApi.java
|
MetaApi.getPingWithHttpInfo
|
public ApiResponse<String> getPingWithHttpInfo() throws ApiException {
com.squareup.okhttp.Call call = getPingValidateBeforeCall(null);
Type localVarReturnType = new TypeToken<String>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
}
|
java
|
public ApiResponse<String> getPingWithHttpInfo() throws ApiException {
com.squareup.okhttp.Call call = getPingValidateBeforeCall(null);
Type localVarReturnType = new TypeToken<String>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
}
|
[
"public",
"ApiResponse",
"<",
"String",
">",
"getPingWithHttpInfo",
"(",
")",
"throws",
"ApiException",
"{",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"getPingValidateBeforeCall",
"(",
"null",
")",
";",
"Type",
"localVarReturnType",
"=",
"new",
"TypeToken",
"<",
"String",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
";",
"return",
"apiClient",
".",
"execute",
"(",
"call",
",",
"localVarReturnType",
")",
";",
"}"
] |
Ping route Ping the ESI routers
@return ApiResponse<String>
@throws ApiException
If fail to call the API, e.g. server error or cannot
deserialize the response body
|
[
"Ping",
"route",
"Ping",
"the",
"ESI",
"routers"
] |
24a941c592cfc15f23471ef849b282fbc582ca13
|
https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/api/MetaApi.java#L218-L223
|
160,354 |
burberius/eve-esi
|
src/main/java/net/troja/eve/esi/ApiClient.java
|
ApiClient.setHttpClient
|
public ApiClient setHttpClient(OkHttpClient newHttpClient) {
if (!httpClient.equals(newHttpClient)) {
newHttpClient.networkInterceptors().addAll(httpClient.networkInterceptors());
httpClient.networkInterceptors().clear();
newHttpClient.interceptors().addAll(httpClient.interceptors());
httpClient.interceptors().clear();
this.httpClient = newHttpClient;
}
return this;
}
|
java
|
public ApiClient setHttpClient(OkHttpClient newHttpClient) {
if (!httpClient.equals(newHttpClient)) {
newHttpClient.networkInterceptors().addAll(httpClient.networkInterceptors());
httpClient.networkInterceptors().clear();
newHttpClient.interceptors().addAll(httpClient.interceptors());
httpClient.interceptors().clear();
this.httpClient = newHttpClient;
}
return this;
}
|
[
"public",
"ApiClient",
"setHttpClient",
"(",
"OkHttpClient",
"newHttpClient",
")",
"{",
"if",
"(",
"!",
"httpClient",
".",
"equals",
"(",
"newHttpClient",
")",
")",
"{",
"newHttpClient",
".",
"networkInterceptors",
"(",
")",
".",
"addAll",
"(",
"httpClient",
".",
"networkInterceptors",
"(",
")",
")",
";",
"httpClient",
".",
"networkInterceptors",
"(",
")",
".",
"clear",
"(",
")",
";",
"newHttpClient",
".",
"interceptors",
"(",
")",
".",
"addAll",
"(",
"httpClient",
".",
"interceptors",
"(",
")",
")",
";",
"httpClient",
".",
"interceptors",
"(",
")",
".",
"clear",
"(",
")",
";",
"this",
".",
"httpClient",
"=",
"newHttpClient",
";",
"}",
"return",
"this",
";",
"}"
] |
Set HTTP client
@param httpClient
An instance of OkHttpClient
@return Api Client
|
[
"Set",
"HTTP",
"client"
] |
24a941c592cfc15f23471ef849b282fbc582ca13
|
https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/ApiClient.java#L174-L183
|
160,355 |
burberius/eve-esi
|
src/main/java/net/troja/eve/esi/ApiClient.java
|
ApiClient.addProgressInterceptor
|
private void addProgressInterceptor() {
httpClient.networkInterceptors().add(new Interceptor() {
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
final Request request = chain.request();
final Response originalResponse = chain.proceed(request);
if (request.tag() instanceof ApiCallback) {
final ApiCallback callback = (ApiCallback) request.tag();
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), callback)).build();
}
return originalResponse;
}
});
}
|
java
|
private void addProgressInterceptor() {
httpClient.networkInterceptors().add(new Interceptor() {
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
final Request request = chain.request();
final Response originalResponse = chain.proceed(request);
if (request.tag() instanceof ApiCallback) {
final ApiCallback callback = (ApiCallback) request.tag();
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), callback)).build();
}
return originalResponse;
}
});
}
|
[
"private",
"void",
"addProgressInterceptor",
"(",
")",
"{",
"httpClient",
".",
"networkInterceptors",
"(",
")",
".",
"add",
"(",
"new",
"Interceptor",
"(",
")",
"{",
"@",
"Override",
"public",
"Response",
"intercept",
"(",
"Interceptor",
".",
"Chain",
"chain",
")",
"throws",
"IOException",
"{",
"final",
"Request",
"request",
"=",
"chain",
".",
"request",
"(",
")",
";",
"final",
"Response",
"originalResponse",
"=",
"chain",
".",
"proceed",
"(",
"request",
")",
";",
"if",
"(",
"request",
".",
"tag",
"(",
")",
"instanceof",
"ApiCallback",
")",
"{",
"final",
"ApiCallback",
"callback",
"=",
"(",
"ApiCallback",
")",
"request",
".",
"tag",
"(",
")",
";",
"return",
"originalResponse",
".",
"newBuilder",
"(",
")",
".",
"body",
"(",
"new",
"ProgressResponseBody",
"(",
"originalResponse",
".",
"body",
"(",
")",
",",
"callback",
")",
")",
".",
"build",
"(",
")",
";",
"}",
"return",
"originalResponse",
";",
"}",
"}",
")",
";",
"}"
] |
Add network interceptor to httpClient to track download progress for
async requests.
|
[
"Add",
"network",
"interceptor",
"to",
"httpClient",
"to",
"track",
"download",
"progress",
"for",
"async",
"requests",
"."
] |
24a941c592cfc15f23471ef849b282fbc582ca13
|
https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/ApiClient.java#L1318-L1332
|
160,356 |
burberius/eve-esi
|
src/main/java/net/troja/eve/esi/api/UserInterfaceApi.java
|
UserInterfaceApi.postUiAutopilotWaypointCall
|
public com.squareup.okhttp.Call postUiAutopilotWaypointCall(Boolean addToBeginning, Boolean clearOtherWaypoints,
Long destinationId, String datasource, String token, final ApiCallback callback) throws ApiException {
Object localVarPostBody = new Object();
// create path and map variables
String localVarPath = "/v2/ui/autopilot/waypoint/";
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (addToBeginning != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("add_to_beginning", addToBeginning));
}
if (clearOtherWaypoints != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("clear_other_waypoints", clearOtherWaypoints));
}
if (datasource != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("datasource", datasource));
}
if (destinationId != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("destination_id", destinationId));
}
if (token != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("token", token));
}
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
String[] localVarAuthNames = new String[] { "evesso" };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams,
localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, callback);
}
|
java
|
public com.squareup.okhttp.Call postUiAutopilotWaypointCall(Boolean addToBeginning, Boolean clearOtherWaypoints,
Long destinationId, String datasource, String token, final ApiCallback callback) throws ApiException {
Object localVarPostBody = new Object();
// create path and map variables
String localVarPath = "/v2/ui/autopilot/waypoint/";
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (addToBeginning != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("add_to_beginning", addToBeginning));
}
if (clearOtherWaypoints != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("clear_other_waypoints", clearOtherWaypoints));
}
if (datasource != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("datasource", datasource));
}
if (destinationId != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("destination_id", destinationId));
}
if (token != null) {
localVarQueryParams.addAll(apiClient.parameterToPair("token", token));
}
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
String[] localVarAuthNames = new String[] { "evesso" };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams,
localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, callback);
}
|
[
"public",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"postUiAutopilotWaypointCall",
"(",
"Boolean",
"addToBeginning",
",",
"Boolean",
"clearOtherWaypoints",
",",
"Long",
"destinationId",
",",
"String",
"datasource",
",",
"String",
"token",
",",
"final",
"ApiCallback",
"callback",
")",
"throws",
"ApiException",
"{",
"Object",
"localVarPostBody",
"=",
"new",
"Object",
"(",
")",
";",
"// create path and map variables",
"String",
"localVarPath",
"=",
"\"/v2/ui/autopilot/waypoint/\"",
";",
"List",
"<",
"Pair",
">",
"localVarQueryParams",
"=",
"new",
"ArrayList",
"<",
"Pair",
">",
"(",
")",
";",
"List",
"<",
"Pair",
">",
"localVarCollectionQueryParams",
"=",
"new",
"ArrayList",
"<",
"Pair",
">",
"(",
")",
";",
"if",
"(",
"addToBeginning",
"!=",
"null",
")",
"{",
"localVarQueryParams",
".",
"addAll",
"(",
"apiClient",
".",
"parameterToPair",
"(",
"\"add_to_beginning\"",
",",
"addToBeginning",
")",
")",
";",
"}",
"if",
"(",
"clearOtherWaypoints",
"!=",
"null",
")",
"{",
"localVarQueryParams",
".",
"addAll",
"(",
"apiClient",
".",
"parameterToPair",
"(",
"\"clear_other_waypoints\"",
",",
"clearOtherWaypoints",
")",
")",
";",
"}",
"if",
"(",
"datasource",
"!=",
"null",
")",
"{",
"localVarQueryParams",
".",
"addAll",
"(",
"apiClient",
".",
"parameterToPair",
"(",
"\"datasource\"",
",",
"datasource",
")",
")",
";",
"}",
"if",
"(",
"destinationId",
"!=",
"null",
")",
"{",
"localVarQueryParams",
".",
"addAll",
"(",
"apiClient",
".",
"parameterToPair",
"(",
"\"destination_id\"",
",",
"destinationId",
")",
")",
";",
"}",
"if",
"(",
"token",
"!=",
"null",
")",
"{",
"localVarQueryParams",
".",
"addAll",
"(",
"apiClient",
".",
"parameterToPair",
"(",
"\"token\"",
",",
"token",
")",
")",
";",
"}",
"Map",
"<",
"String",
",",
"String",
">",
"localVarHeaderParams",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"localVarFormParams",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"final",
"String",
"[",
"]",
"localVarAccepts",
"=",
"{",
"}",
";",
"final",
"String",
"localVarAccept",
"=",
"apiClient",
".",
"selectHeaderAccept",
"(",
"localVarAccepts",
")",
";",
"if",
"(",
"localVarAccept",
"!=",
"null",
")",
"{",
"localVarHeaderParams",
".",
"put",
"(",
"\"Accept\"",
",",
"localVarAccept",
")",
";",
"}",
"final",
"String",
"[",
"]",
"localVarContentTypes",
"=",
"{",
"}",
";",
"final",
"String",
"localVarContentType",
"=",
"apiClient",
".",
"selectHeaderContentType",
"(",
"localVarContentTypes",
")",
";",
"localVarHeaderParams",
".",
"put",
"(",
"\"Content-Type\"",
",",
"localVarContentType",
")",
";",
"String",
"[",
"]",
"localVarAuthNames",
"=",
"new",
"String",
"[",
"]",
"{",
"\"evesso\"",
"}",
";",
"return",
"apiClient",
".",
"buildCall",
"(",
"localVarPath",
",",
"\"POST\"",
",",
"localVarQueryParams",
",",
"localVarCollectionQueryParams",
",",
"localVarPostBody",
",",
"localVarHeaderParams",
",",
"localVarFormParams",
",",
"localVarAuthNames",
",",
"callback",
")",
";",
"}"
] |
Build call for postUiAutopilotWaypoint
@param addToBeginning
Whether this solar system should be added to the beginning of
all waypoints (required)
@param clearOtherWaypoints
Whether clean other waypoints beforing adding this one
(required)
@param destinationId
The destination to travel to, can be solar system, station or
structure's id (required)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param token
Access token to use if unable to set a header (optional)
@param callback
Callback for upload/download progress
@return Call to execute
@throws ApiException
If fail to serialize the request body object
|
[
"Build",
"call",
"for",
"postUiAutopilotWaypoint"
] |
24a941c592cfc15f23471ef849b282fbc582ca13
|
https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/api/UserInterfaceApi.java#L77-L125
|
160,357 |
lsjwzh/MaterialLoadingProgressBar
|
materialloadingprogressbar/src/main/java/com/lsjwzh/widget/materialloadingprogressbar/CircleProgressBar.java
|
CircleProgressBar.setColorSchemeResources
|
public void setColorSchemeResources(int... colorResIds) {
final Resources res = getResources();
int[] colorRes = new int[colorResIds.length];
for (int i = 0; i < colorResIds.length; i++) {
colorRes[i] = res.getColor(colorResIds[i]);
}
setColorSchemeColors(colorRes);
}
|
java
|
public void setColorSchemeResources(int... colorResIds) {
final Resources res = getResources();
int[] colorRes = new int[colorResIds.length];
for (int i = 0; i < colorResIds.length; i++) {
colorRes[i] = res.getColor(colorResIds[i]);
}
setColorSchemeColors(colorRes);
}
|
[
"public",
"void",
"setColorSchemeResources",
"(",
"int",
"...",
"colorResIds",
")",
"{",
"final",
"Resources",
"res",
"=",
"getResources",
"(",
")",
";",
"int",
"[",
"]",
"colorRes",
"=",
"new",
"int",
"[",
"colorResIds",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"colorResIds",
".",
"length",
";",
"i",
"++",
")",
"{",
"colorRes",
"[",
"i",
"]",
"=",
"res",
".",
"getColor",
"(",
"colorResIds",
"[",
"i",
"]",
")",
";",
"}",
"setColorSchemeColors",
"(",
"colorRes",
")",
";",
"}"
] |
Set the color resources used in the progress animation from color resources.
The first color will also be the color of the bar that grows in response
to a user swipe gesture.
@param colorResIds
|
[
"Set",
"the",
"color",
"resources",
"used",
"in",
"the",
"progress",
"animation",
"from",
"color",
"resources",
".",
"The",
"first",
"color",
"will",
"also",
"be",
"the",
"color",
"of",
"the",
"bar",
"that",
"grows",
"in",
"response",
"to",
"a",
"user",
"swipe",
"gesture",
"."
] |
170ae71d5d4f31fdd0a46a1dba9a60cb1361c656
|
https://github.com/lsjwzh/MaterialLoadingProgressBar/blob/170ae71d5d4f31fdd0a46a1dba9a60cb1361c656/materialloadingprogressbar/src/main/java/com/lsjwzh/widget/materialloadingprogressbar/CircleProgressBar.java#L288-L295
|
160,358 |
lsjwzh/MaterialLoadingProgressBar
|
materialloadingprogressbar/src/main/java/com/lsjwzh/widget/materialloadingprogressbar/CircleProgressBar.java
|
CircleProgressBar.setBackgroundColor
|
public void setBackgroundColor(int colorRes) {
if (getBackground() instanceof ShapeDrawable) {
final Resources res = getResources();
((ShapeDrawable) getBackground()).getPaint().setColor(res.getColor(colorRes));
}
}
|
java
|
public void setBackgroundColor(int colorRes) {
if (getBackground() instanceof ShapeDrawable) {
final Resources res = getResources();
((ShapeDrawable) getBackground()).getPaint().setColor(res.getColor(colorRes));
}
}
|
[
"public",
"void",
"setBackgroundColor",
"(",
"int",
"colorRes",
")",
"{",
"if",
"(",
"getBackground",
"(",
")",
"instanceof",
"ShapeDrawable",
")",
"{",
"final",
"Resources",
"res",
"=",
"getResources",
"(",
")",
";",
"(",
"(",
"ShapeDrawable",
")",
"getBackground",
"(",
")",
")",
".",
"getPaint",
"(",
")",
".",
"setColor",
"(",
"res",
".",
"getColor",
"(",
"colorRes",
")",
")",
";",
"}",
"}"
] |
Update the background color of the mBgCircle image view.
|
[
"Update",
"the",
"background",
"color",
"of",
"the",
"mBgCircle",
"image",
"view",
"."
] |
170ae71d5d4f31fdd0a46a1dba9a60cb1361c656
|
https://github.com/lsjwzh/MaterialLoadingProgressBar/blob/170ae71d5d4f31fdd0a46a1dba9a60cb1361c656/materialloadingprogressbar/src/main/java/com/lsjwzh/widget/materialloadingprogressbar/CircleProgressBar.java#L314-L319
|
160,359 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/DataBarExpanded.java
|
DataBarExpanded.logBinaryStringInfo
|
private void logBinaryStringInfo(StringBuilder binaryString) {
encodeInfo += "Binary Length: " + binaryString.length() + "\n";
encodeInfo += "Binary String: ";
int nibble = 0;
for (int i = 0; i < binaryString.length(); i++) {
switch (i % 4) {
case 0:
if (binaryString.charAt(i) == '1') {
nibble += 8;
}
break;
case 1:
if (binaryString.charAt(i) == '1') {
nibble += 4;
}
break;
case 2:
if (binaryString.charAt(i) == '1') {
nibble += 2;
}
break;
case 3:
if (binaryString.charAt(i) == '1') {
nibble += 1;
}
encodeInfo += Integer.toHexString(nibble);
nibble = 0;
break;
}
}
if ((binaryString.length() % 4) != 0) {
encodeInfo += Integer.toHexString(nibble);
}
encodeInfo += "\n";
}
|
java
|
private void logBinaryStringInfo(StringBuilder binaryString) {
encodeInfo += "Binary Length: " + binaryString.length() + "\n";
encodeInfo += "Binary String: ";
int nibble = 0;
for (int i = 0; i < binaryString.length(); i++) {
switch (i % 4) {
case 0:
if (binaryString.charAt(i) == '1') {
nibble += 8;
}
break;
case 1:
if (binaryString.charAt(i) == '1') {
nibble += 4;
}
break;
case 2:
if (binaryString.charAt(i) == '1') {
nibble += 2;
}
break;
case 3:
if (binaryString.charAt(i) == '1') {
nibble += 1;
}
encodeInfo += Integer.toHexString(nibble);
nibble = 0;
break;
}
}
if ((binaryString.length() % 4) != 0) {
encodeInfo += Integer.toHexString(nibble);
}
encodeInfo += "\n";
}
|
[
"private",
"void",
"logBinaryStringInfo",
"(",
"StringBuilder",
"binaryString",
")",
"{",
"encodeInfo",
"+=",
"\"Binary Length: \"",
"+",
"binaryString",
".",
"length",
"(",
")",
"+",
"\"\\n\"",
";",
"encodeInfo",
"+=",
"\"Binary String: \"",
";",
"int",
"nibble",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"binaryString",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"switch",
"(",
"i",
"%",
"4",
")",
"{",
"case",
"0",
":",
"if",
"(",
"binaryString",
".",
"charAt",
"(",
"i",
")",
"==",
"'",
"'",
")",
"{",
"nibble",
"+=",
"8",
";",
"}",
"break",
";",
"case",
"1",
":",
"if",
"(",
"binaryString",
".",
"charAt",
"(",
"i",
")",
"==",
"'",
"'",
")",
"{",
"nibble",
"+=",
"4",
";",
"}",
"break",
";",
"case",
"2",
":",
"if",
"(",
"binaryString",
".",
"charAt",
"(",
"i",
")",
"==",
"'",
"'",
")",
"{",
"nibble",
"+=",
"2",
";",
"}",
"break",
";",
"case",
"3",
":",
"if",
"(",
"binaryString",
".",
"charAt",
"(",
"i",
")",
"==",
"'",
"'",
")",
"{",
"nibble",
"+=",
"1",
";",
"}",
"encodeInfo",
"+=",
"Integer",
".",
"toHexString",
"(",
"nibble",
")",
";",
"nibble",
"=",
"0",
";",
"break",
";",
"}",
"}",
"if",
"(",
"(",
"binaryString",
".",
"length",
"(",
")",
"%",
"4",
")",
"!=",
"0",
")",
"{",
"encodeInfo",
"+=",
"Integer",
".",
"toHexString",
"(",
"nibble",
")",
";",
"}",
"encodeInfo",
"+=",
"\"\\n\"",
";",
"}"
] |
Logs binary string as hexadecimal
|
[
"Logs",
"binary",
"string",
"as",
"hexadecimal"
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/DataBarExpanded.java#L1330-L1368
|
160,360 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/Code128.java
|
Code128.combineSubsetBlocks
|
private int combineSubsetBlocks(Mode[] mode_type, int[] mode_length, int index_point) {
/* bring together same type blocks */
if (index_point > 1) {
for (int i = 1; i < index_point; i++) {
if (mode_type[i - 1] == mode_type[i]) {
/* bring together */
mode_length[i - 1] = mode_length[i - 1] + mode_length[i];
/* decrease the list */
for (int j = i + 1; j < index_point; j++) {
mode_length[j - 1] = mode_length[j];
mode_type[j - 1] = mode_type[j];
}
index_point--;
i--;
}
}
}
return index_point;
}
|
java
|
private int combineSubsetBlocks(Mode[] mode_type, int[] mode_length, int index_point) {
/* bring together same type blocks */
if (index_point > 1) {
for (int i = 1; i < index_point; i++) {
if (mode_type[i - 1] == mode_type[i]) {
/* bring together */
mode_length[i - 1] = mode_length[i - 1] + mode_length[i];
/* decrease the list */
for (int j = i + 1; j < index_point; j++) {
mode_length[j - 1] = mode_length[j];
mode_type[j - 1] = mode_type[j];
}
index_point--;
i--;
}
}
}
return index_point;
}
|
[
"private",
"int",
"combineSubsetBlocks",
"(",
"Mode",
"[",
"]",
"mode_type",
",",
"int",
"[",
"]",
"mode_length",
",",
"int",
"index_point",
")",
"{",
"/* bring together same type blocks */",
"if",
"(",
"index_point",
">",
"1",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"index_point",
";",
"i",
"++",
")",
"{",
"if",
"(",
"mode_type",
"[",
"i",
"-",
"1",
"]",
"==",
"mode_type",
"[",
"i",
"]",
")",
"{",
"/* bring together */",
"mode_length",
"[",
"i",
"-",
"1",
"]",
"=",
"mode_length",
"[",
"i",
"-",
"1",
"]",
"+",
"mode_length",
"[",
"i",
"]",
";",
"/* decrease the list */",
"for",
"(",
"int",
"j",
"=",
"i",
"+",
"1",
";",
"j",
"<",
"index_point",
";",
"j",
"++",
")",
"{",
"mode_length",
"[",
"j",
"-",
"1",
"]",
"=",
"mode_length",
"[",
"j",
"]",
";",
"mode_type",
"[",
"j",
"-",
"1",
"]",
"=",
"mode_type",
"[",
"j",
"]",
";",
"}",
"index_point",
"--",
";",
"i",
"--",
";",
"}",
"}",
"}",
"return",
"index_point",
";",
"}"
] |
Modifies the specified mode and length arrays to combine adjacent modes of the same type, returning the updated index point.
|
[
"Modifies",
"the",
"specified",
"mode",
"and",
"length",
"arrays",
"to",
"combine",
"adjacent",
"modes",
"of",
"the",
"same",
"type",
"returning",
"the",
"updated",
"index",
"point",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/Code128.java#L818-L836
|
160,361 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/OkapiBarcode.java
|
OkapiBarcode.main
|
public static void main(String[] args) {
Settings settings = new Settings();
new JCommander(settings, args);
if (!settings.isGuiSupressed()) {
OkapiUI okapiUi = new OkapiUI();
okapiUi.setVisible(true);
} else {
int returnValue;
returnValue = commandLine(settings);
if (returnValue != 0) {
System.out.println("An error occurred");
}
}
}
|
java
|
public static void main(String[] args) {
Settings settings = new Settings();
new JCommander(settings, args);
if (!settings.isGuiSupressed()) {
OkapiUI okapiUi = new OkapiUI();
okapiUi.setVisible(true);
} else {
int returnValue;
returnValue = commandLine(settings);
if (returnValue != 0) {
System.out.println("An error occurred");
}
}
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"Settings",
"settings",
"=",
"new",
"Settings",
"(",
")",
";",
"new",
"JCommander",
"(",
"settings",
",",
"args",
")",
";",
"if",
"(",
"!",
"settings",
".",
"isGuiSupressed",
"(",
")",
")",
"{",
"OkapiUI",
"okapiUi",
"=",
"new",
"OkapiUI",
"(",
")",
";",
"okapiUi",
".",
"setVisible",
"(",
"true",
")",
";",
"}",
"else",
"{",
"int",
"returnValue",
";",
"returnValue",
"=",
"commandLine",
"(",
"settings",
")",
";",
"if",
"(",
"returnValue",
"!=",
"0",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"An error occurred\"",
")",
";",
"}",
"}",
"}"
] |
Starts the Okapi Barcode UI.
@param args the command line arguments
|
[
"Starts",
"the",
"Okapi",
"Barcode",
"UI",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/OkapiBarcode.java#L41-L57
|
160,362 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/MaxiCode.java
|
MaxiCode.getPrimaryCodewords
|
private int[] getPrimaryCodewords() {
assert mode == 2 || mode == 3;
if (primaryData.length() != 15) {
throw new OkapiException("Invalid Primary String");
}
for (int i = 9; i < 15; i++) { /* check that country code and service are numeric */
if (primaryData.charAt(i) < '0' || primaryData.charAt(i) > '9') {
throw new OkapiException("Invalid Primary String");
}
}
String postcode;
if (mode == 2) {
postcode = primaryData.substring(0, 9);
int index = postcode.indexOf(' ');
if (index != -1) {
postcode = postcode.substring(0, index);
}
} else {
// if (mode == 3)
postcode = primaryData.substring(0, 6);
}
int country = Integer.parseInt(primaryData.substring(9, 12));
int service = Integer.parseInt(primaryData.substring(12, 15));
if (debug) {
System.out.println("Using mode " + mode);
System.out.println(" Postcode: " + postcode);
System.out.println(" Country Code: " + country);
System.out.println(" Service: " + service);
}
if (mode == 2) {
return getMode2PrimaryCodewords(postcode, country, service);
} else { // mode == 3
return getMode3PrimaryCodewords(postcode, country, service);
}
}
|
java
|
private int[] getPrimaryCodewords() {
assert mode == 2 || mode == 3;
if (primaryData.length() != 15) {
throw new OkapiException("Invalid Primary String");
}
for (int i = 9; i < 15; i++) { /* check that country code and service are numeric */
if (primaryData.charAt(i) < '0' || primaryData.charAt(i) > '9') {
throw new OkapiException("Invalid Primary String");
}
}
String postcode;
if (mode == 2) {
postcode = primaryData.substring(0, 9);
int index = postcode.indexOf(' ');
if (index != -1) {
postcode = postcode.substring(0, index);
}
} else {
// if (mode == 3)
postcode = primaryData.substring(0, 6);
}
int country = Integer.parseInt(primaryData.substring(9, 12));
int service = Integer.parseInt(primaryData.substring(12, 15));
if (debug) {
System.out.println("Using mode " + mode);
System.out.println(" Postcode: " + postcode);
System.out.println(" Country Code: " + country);
System.out.println(" Service: " + service);
}
if (mode == 2) {
return getMode2PrimaryCodewords(postcode, country, service);
} else { // mode == 3
return getMode3PrimaryCodewords(postcode, country, service);
}
}
|
[
"private",
"int",
"[",
"]",
"getPrimaryCodewords",
"(",
")",
"{",
"assert",
"mode",
"==",
"2",
"||",
"mode",
"==",
"3",
";",
"if",
"(",
"primaryData",
".",
"length",
"(",
")",
"!=",
"15",
")",
"{",
"throw",
"new",
"OkapiException",
"(",
"\"Invalid Primary String\"",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"9",
";",
"i",
"<",
"15",
";",
"i",
"++",
")",
"{",
"/* check that country code and service are numeric */",
"if",
"(",
"primaryData",
".",
"charAt",
"(",
"i",
")",
"<",
"'",
"'",
"||",
"primaryData",
".",
"charAt",
"(",
"i",
")",
">",
"'",
"'",
")",
"{",
"throw",
"new",
"OkapiException",
"(",
"\"Invalid Primary String\"",
")",
";",
"}",
"}",
"String",
"postcode",
";",
"if",
"(",
"mode",
"==",
"2",
")",
"{",
"postcode",
"=",
"primaryData",
".",
"substring",
"(",
"0",
",",
"9",
")",
";",
"int",
"index",
"=",
"postcode",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"postcode",
"=",
"postcode",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"}",
"}",
"else",
"{",
"// if (mode == 3)\r",
"postcode",
"=",
"primaryData",
".",
"substring",
"(",
"0",
",",
"6",
")",
";",
"}",
"int",
"country",
"=",
"Integer",
".",
"parseInt",
"(",
"primaryData",
".",
"substring",
"(",
"9",
",",
"12",
")",
")",
";",
"int",
"service",
"=",
"Integer",
".",
"parseInt",
"(",
"primaryData",
".",
"substring",
"(",
"12",
",",
"15",
")",
")",
";",
"if",
"(",
"debug",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Using mode \"",
"+",
"mode",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\" Postcode: \"",
"+",
"postcode",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\" Country Code: \"",
"+",
"country",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\" Service: \"",
"+",
"service",
")",
";",
"}",
"if",
"(",
"mode",
"==",
"2",
")",
"{",
"return",
"getMode2PrimaryCodewords",
"(",
"postcode",
",",
"country",
",",
"service",
")",
";",
"}",
"else",
"{",
"// mode == 3\r",
"return",
"getMode3PrimaryCodewords",
"(",
"postcode",
",",
"country",
",",
"service",
")",
";",
"}",
"}"
] |
Extracts the postal code, country code and service code from the primary data and returns the corresponding primary message
codewords.
@return the primary message codewords
|
[
"Extracts",
"the",
"postal",
"code",
"country",
"code",
"and",
"service",
"code",
"from",
"the",
"primary",
"data",
"and",
"returns",
"the",
"corresponding",
"primary",
"message",
"codewords",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/MaxiCode.java#L389-L430
|
160,363 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/MaxiCode.java
|
MaxiCode.getMode2PrimaryCodewords
|
private static int[] getMode2PrimaryCodewords(String postcode, int country, int service) {
for (int i = 0; i < postcode.length(); i++) {
if (postcode.charAt(i) < '0' || postcode.charAt(i) > '9') {
postcode = postcode.substring(0, i);
break;
}
}
int postcodeNum = Integer.parseInt(postcode);
int[] primary = new int[10];
primary[0] = ((postcodeNum & 0x03) << 4) | 2;
primary[1] = ((postcodeNum & 0xfc) >> 2);
primary[2] = ((postcodeNum & 0x3f00) >> 8);
primary[3] = ((postcodeNum & 0xfc000) >> 14);
primary[4] = ((postcodeNum & 0x3f00000) >> 20);
primary[5] = ((postcodeNum & 0x3c000000) >> 26) | ((postcode.length() & 0x3) << 4);
primary[6] = ((postcode.length() & 0x3c) >> 2) | ((country & 0x3) << 4);
primary[7] = (country & 0xfc) >> 2;
primary[8] = ((country & 0x300) >> 8) | ((service & 0xf) << 2);
primary[9] = ((service & 0x3f0) >> 4);
return primary;
}
|
java
|
private static int[] getMode2PrimaryCodewords(String postcode, int country, int service) {
for (int i = 0; i < postcode.length(); i++) {
if (postcode.charAt(i) < '0' || postcode.charAt(i) > '9') {
postcode = postcode.substring(0, i);
break;
}
}
int postcodeNum = Integer.parseInt(postcode);
int[] primary = new int[10];
primary[0] = ((postcodeNum & 0x03) << 4) | 2;
primary[1] = ((postcodeNum & 0xfc) >> 2);
primary[2] = ((postcodeNum & 0x3f00) >> 8);
primary[3] = ((postcodeNum & 0xfc000) >> 14);
primary[4] = ((postcodeNum & 0x3f00000) >> 20);
primary[5] = ((postcodeNum & 0x3c000000) >> 26) | ((postcode.length() & 0x3) << 4);
primary[6] = ((postcode.length() & 0x3c) >> 2) | ((country & 0x3) << 4);
primary[7] = (country & 0xfc) >> 2;
primary[8] = ((country & 0x300) >> 8) | ((service & 0xf) << 2);
primary[9] = ((service & 0x3f0) >> 4);
return primary;
}
|
[
"private",
"static",
"int",
"[",
"]",
"getMode2PrimaryCodewords",
"(",
"String",
"postcode",
",",
"int",
"country",
",",
"int",
"service",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"postcode",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"postcode",
".",
"charAt",
"(",
"i",
")",
"<",
"'",
"'",
"||",
"postcode",
".",
"charAt",
"(",
"i",
")",
">",
"'",
"'",
")",
"{",
"postcode",
"=",
"postcode",
".",
"substring",
"(",
"0",
",",
"i",
")",
";",
"break",
";",
"}",
"}",
"int",
"postcodeNum",
"=",
"Integer",
".",
"parseInt",
"(",
"postcode",
")",
";",
"int",
"[",
"]",
"primary",
"=",
"new",
"int",
"[",
"10",
"]",
";",
"primary",
"[",
"0",
"]",
"=",
"(",
"(",
"postcodeNum",
"&",
"0x03",
")",
"<<",
"4",
")",
"|",
"2",
";",
"primary",
"[",
"1",
"]",
"=",
"(",
"(",
"postcodeNum",
"&",
"0xfc",
")",
">>",
"2",
")",
";",
"primary",
"[",
"2",
"]",
"=",
"(",
"(",
"postcodeNum",
"&",
"0x3f00",
")",
">>",
"8",
")",
";",
"primary",
"[",
"3",
"]",
"=",
"(",
"(",
"postcodeNum",
"&",
"0xfc000",
")",
">>",
"14",
")",
";",
"primary",
"[",
"4",
"]",
"=",
"(",
"(",
"postcodeNum",
"&",
"0x3f00000",
")",
">>",
"20",
")",
";",
"primary",
"[",
"5",
"]",
"=",
"(",
"(",
"postcodeNum",
"&",
"0x3c000000",
")",
">>",
"26",
")",
"|",
"(",
"(",
"postcode",
".",
"length",
"(",
")",
"&",
"0x3",
")",
"<<",
"4",
")",
";",
"primary",
"[",
"6",
"]",
"=",
"(",
"(",
"postcode",
".",
"length",
"(",
")",
"&",
"0x3c",
")",
">>",
"2",
")",
"|",
"(",
"(",
"country",
"&",
"0x3",
")",
"<<",
"4",
")",
";",
"primary",
"[",
"7",
"]",
"=",
"(",
"country",
"&",
"0xfc",
")",
">>",
"2",
";",
"primary",
"[",
"8",
"]",
"=",
"(",
"(",
"country",
"&",
"0x300",
")",
">>",
"8",
")",
"|",
"(",
"(",
"service",
"&",
"0xf",
")",
"<<",
"2",
")",
";",
"primary",
"[",
"9",
"]",
"=",
"(",
"(",
"service",
"&",
"0x3f0",
")",
">>",
"4",
")",
";",
"return",
"primary",
";",
"}"
] |
Returns the primary message codewords for mode 2.
@param postcode the postal code
@param country the country code
@param service the service code
@return the primary message, as codewords
|
[
"Returns",
"the",
"primary",
"message",
"codewords",
"for",
"mode",
"2",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/MaxiCode.java#L440-L464
|
160,364 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/MaxiCode.java
|
MaxiCode.getMode3PrimaryCodewords
|
private static int[] getMode3PrimaryCodewords(String postcode, int country, int service) {
int[] postcodeNums = new int[postcode.length()];
postcode = postcode.toUpperCase();
for (int i = 0; i < postcodeNums.length; i++) {
postcodeNums[i] = postcode.charAt(i);
if (postcode.charAt(i) >= 'A' && postcode.charAt(i) <= 'Z') {
// (Capital) letters shifted to Code Set A values
postcodeNums[i] -= 64;
}
if (postcodeNums[i] == 27 || postcodeNums[i] == 31 || postcodeNums[i] == 33 || postcodeNums[i] >= 59) {
// Not a valid postal code character, use space instead
postcodeNums[i] = 32;
}
// Input characters lower than 27 (NUL - SUB) in postal code are interpreted as capital
// letters in Code Set A (e.g. LF becomes 'J')
}
int[] primary = new int[10];
primary[0] = ((postcodeNums[5] & 0x03) << 4) | 3;
primary[1] = ((postcodeNums[4] & 0x03) << 4) | ((postcodeNums[5] & 0x3c) >> 2);
primary[2] = ((postcodeNums[3] & 0x03) << 4) | ((postcodeNums[4] & 0x3c) >> 2);
primary[3] = ((postcodeNums[2] & 0x03) << 4) | ((postcodeNums[3] & 0x3c) >> 2);
primary[4] = ((postcodeNums[1] & 0x03) << 4) | ((postcodeNums[2] & 0x3c) >> 2);
primary[5] = ((postcodeNums[0] & 0x03) << 4) | ((postcodeNums[1] & 0x3c) >> 2);
primary[6] = ((postcodeNums[0] & 0x3c) >> 2) | ((country & 0x3) << 4);
primary[7] = (country & 0xfc) >> 2;
primary[8] = ((country & 0x300) >> 8) | ((service & 0xf) << 2);
primary[9] = ((service & 0x3f0) >> 4);
return primary;
}
|
java
|
private static int[] getMode3PrimaryCodewords(String postcode, int country, int service) {
int[] postcodeNums = new int[postcode.length()];
postcode = postcode.toUpperCase();
for (int i = 0; i < postcodeNums.length; i++) {
postcodeNums[i] = postcode.charAt(i);
if (postcode.charAt(i) >= 'A' && postcode.charAt(i) <= 'Z') {
// (Capital) letters shifted to Code Set A values
postcodeNums[i] -= 64;
}
if (postcodeNums[i] == 27 || postcodeNums[i] == 31 || postcodeNums[i] == 33 || postcodeNums[i] >= 59) {
// Not a valid postal code character, use space instead
postcodeNums[i] = 32;
}
// Input characters lower than 27 (NUL - SUB) in postal code are interpreted as capital
// letters in Code Set A (e.g. LF becomes 'J')
}
int[] primary = new int[10];
primary[0] = ((postcodeNums[5] & 0x03) << 4) | 3;
primary[1] = ((postcodeNums[4] & 0x03) << 4) | ((postcodeNums[5] & 0x3c) >> 2);
primary[2] = ((postcodeNums[3] & 0x03) << 4) | ((postcodeNums[4] & 0x3c) >> 2);
primary[3] = ((postcodeNums[2] & 0x03) << 4) | ((postcodeNums[3] & 0x3c) >> 2);
primary[4] = ((postcodeNums[1] & 0x03) << 4) | ((postcodeNums[2] & 0x3c) >> 2);
primary[5] = ((postcodeNums[0] & 0x03) << 4) | ((postcodeNums[1] & 0x3c) >> 2);
primary[6] = ((postcodeNums[0] & 0x3c) >> 2) | ((country & 0x3) << 4);
primary[7] = (country & 0xfc) >> 2;
primary[8] = ((country & 0x300) >> 8) | ((service & 0xf) << 2);
primary[9] = ((service & 0x3f0) >> 4);
return primary;
}
|
[
"private",
"static",
"int",
"[",
"]",
"getMode3PrimaryCodewords",
"(",
"String",
"postcode",
",",
"int",
"country",
",",
"int",
"service",
")",
"{",
"int",
"[",
"]",
"postcodeNums",
"=",
"new",
"int",
"[",
"postcode",
".",
"length",
"(",
")",
"]",
";",
"postcode",
"=",
"postcode",
".",
"toUpperCase",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"postcodeNums",
".",
"length",
";",
"i",
"++",
")",
"{",
"postcodeNums",
"[",
"i",
"]",
"=",
"postcode",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"postcode",
".",
"charAt",
"(",
"i",
")",
">=",
"'",
"'",
"&&",
"postcode",
".",
"charAt",
"(",
"i",
")",
"<=",
"'",
"'",
")",
"{",
"// (Capital) letters shifted to Code Set A values\r",
"postcodeNums",
"[",
"i",
"]",
"-=",
"64",
";",
"}",
"if",
"(",
"postcodeNums",
"[",
"i",
"]",
"==",
"27",
"||",
"postcodeNums",
"[",
"i",
"]",
"==",
"31",
"||",
"postcodeNums",
"[",
"i",
"]",
"==",
"33",
"||",
"postcodeNums",
"[",
"i",
"]",
">=",
"59",
")",
"{",
"// Not a valid postal code character, use space instead\r",
"postcodeNums",
"[",
"i",
"]",
"=",
"32",
";",
"}",
"// Input characters lower than 27 (NUL - SUB) in postal code are interpreted as capital\r",
"// letters in Code Set A (e.g. LF becomes 'J')\r",
"}",
"int",
"[",
"]",
"primary",
"=",
"new",
"int",
"[",
"10",
"]",
";",
"primary",
"[",
"0",
"]",
"=",
"(",
"(",
"postcodeNums",
"[",
"5",
"]",
"&",
"0x03",
")",
"<<",
"4",
")",
"|",
"3",
";",
"primary",
"[",
"1",
"]",
"=",
"(",
"(",
"postcodeNums",
"[",
"4",
"]",
"&",
"0x03",
")",
"<<",
"4",
")",
"|",
"(",
"(",
"postcodeNums",
"[",
"5",
"]",
"&",
"0x3c",
")",
">>",
"2",
")",
";",
"primary",
"[",
"2",
"]",
"=",
"(",
"(",
"postcodeNums",
"[",
"3",
"]",
"&",
"0x03",
")",
"<<",
"4",
")",
"|",
"(",
"(",
"postcodeNums",
"[",
"4",
"]",
"&",
"0x3c",
")",
">>",
"2",
")",
";",
"primary",
"[",
"3",
"]",
"=",
"(",
"(",
"postcodeNums",
"[",
"2",
"]",
"&",
"0x03",
")",
"<<",
"4",
")",
"|",
"(",
"(",
"postcodeNums",
"[",
"3",
"]",
"&",
"0x3c",
")",
">>",
"2",
")",
";",
"primary",
"[",
"4",
"]",
"=",
"(",
"(",
"postcodeNums",
"[",
"1",
"]",
"&",
"0x03",
")",
"<<",
"4",
")",
"|",
"(",
"(",
"postcodeNums",
"[",
"2",
"]",
"&",
"0x3c",
")",
">>",
"2",
")",
";",
"primary",
"[",
"5",
"]",
"=",
"(",
"(",
"postcodeNums",
"[",
"0",
"]",
"&",
"0x03",
")",
"<<",
"4",
")",
"|",
"(",
"(",
"postcodeNums",
"[",
"1",
"]",
"&",
"0x3c",
")",
">>",
"2",
")",
";",
"primary",
"[",
"6",
"]",
"=",
"(",
"(",
"postcodeNums",
"[",
"0",
"]",
"&",
"0x3c",
")",
">>",
"2",
")",
"|",
"(",
"(",
"country",
"&",
"0x3",
")",
"<<",
"4",
")",
";",
"primary",
"[",
"7",
"]",
"=",
"(",
"country",
"&",
"0xfc",
")",
">>",
"2",
";",
"primary",
"[",
"8",
"]",
"=",
"(",
"(",
"country",
"&",
"0x300",
")",
">>",
"8",
")",
"|",
"(",
"(",
"service",
"&",
"0xf",
")",
"<<",
"2",
")",
";",
"primary",
"[",
"9",
"]",
"=",
"(",
"(",
"service",
"&",
"0x3f0",
")",
">>",
"4",
")",
";",
"return",
"primary",
";",
"}"
] |
Returns the primary message codewords for mode 3.
@param postcode the postal code
@param country the country code
@param service the service code
@return the primary message, as codewords
|
[
"Returns",
"the",
"primary",
"message",
"codewords",
"for",
"mode",
"3",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/MaxiCode.java#L474-L506
|
160,365 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/MaxiCode.java
|
MaxiCode.bestSurroundingSet
|
private int bestSurroundingSet(int index, int length, int... valid) {
int option1 = set[index - 1];
if (index + 1 < length) {
// we have two options to check
int option2 = set[index + 1];
if (contains(valid, option1) && contains(valid, option2)) {
return Math.min(option1, option2);
} else if (contains(valid, option1)) {
return option1;
} else if (contains(valid, option2)) {
return option2;
} else {
return valid[0];
}
} else {
// we only have one option to check
if (contains(valid, option1)) {
return option1;
} else {
return valid[0];
}
}
}
|
java
|
private int bestSurroundingSet(int index, int length, int... valid) {
int option1 = set[index - 1];
if (index + 1 < length) {
// we have two options to check
int option2 = set[index + 1];
if (contains(valid, option1) && contains(valid, option2)) {
return Math.min(option1, option2);
} else if (contains(valid, option1)) {
return option1;
} else if (contains(valid, option2)) {
return option2;
} else {
return valid[0];
}
} else {
// we only have one option to check
if (contains(valid, option1)) {
return option1;
} else {
return valid[0];
}
}
}
|
[
"private",
"int",
"bestSurroundingSet",
"(",
"int",
"index",
",",
"int",
"length",
",",
"int",
"...",
"valid",
")",
"{",
"int",
"option1",
"=",
"set",
"[",
"index",
"-",
"1",
"]",
";",
"if",
"(",
"index",
"+",
"1",
"<",
"length",
")",
"{",
"// we have two options to check\r",
"int",
"option2",
"=",
"set",
"[",
"index",
"+",
"1",
"]",
";",
"if",
"(",
"contains",
"(",
"valid",
",",
"option1",
")",
"&&",
"contains",
"(",
"valid",
",",
"option2",
")",
")",
"{",
"return",
"Math",
".",
"min",
"(",
"option1",
",",
"option2",
")",
";",
"}",
"else",
"if",
"(",
"contains",
"(",
"valid",
",",
"option1",
")",
")",
"{",
"return",
"option1",
";",
"}",
"else",
"if",
"(",
"contains",
"(",
"valid",
",",
"option2",
")",
")",
"{",
"return",
"option2",
";",
"}",
"else",
"{",
"return",
"valid",
"[",
"0",
"]",
";",
"}",
"}",
"else",
"{",
"// we only have one option to check\r",
"if",
"(",
"contains",
"(",
"valid",
",",
"option1",
")",
")",
"{",
"return",
"option1",
";",
"}",
"else",
"{",
"return",
"valid",
"[",
"0",
"]",
";",
"}",
"}",
"}"
] |
Guesses the best set to use at the specified index by looking at the surrounding sets. In general, characters in
lower-numbered sets are more common, so we choose them if we can. If no good surrounding sets can be found, the default
value returned is the first value from the valid set.
@param index the current index
@param length the maximum length to look at
@param valid the valid sets for this index
@return the best set to use at the specified index
|
[
"Guesses",
"the",
"best",
"set",
"to",
"use",
"at",
"the",
"specified",
"index",
"by",
"looking",
"at",
"the",
"surrounding",
"sets",
".",
"In",
"general",
"characters",
"in",
"lower",
"-",
"numbered",
"sets",
"are",
"more",
"common",
"so",
"we",
"choose",
"them",
"if",
"we",
"can",
".",
"If",
"no",
"good",
"surrounding",
"sets",
"can",
"be",
"found",
"the",
"default",
"value",
"returned",
"is",
"the",
"first",
"value",
"from",
"the",
"valid",
"set",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/MaxiCode.java#L828-L850
|
160,366 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/MaxiCode.java
|
MaxiCode.insert
|
private void insert(int position, int c) {
for (int i = 143; i > position; i--) {
set[i] = set[i - 1];
character[i] = character[i - 1];
}
character[position] = c;
}
|
java
|
private void insert(int position, int c) {
for (int i = 143; i > position; i--) {
set[i] = set[i - 1];
character[i] = character[i - 1];
}
character[position] = c;
}
|
[
"private",
"void",
"insert",
"(",
"int",
"position",
",",
"int",
"c",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"143",
";",
"i",
">",
"position",
";",
"i",
"--",
")",
"{",
"set",
"[",
"i",
"]",
"=",
"set",
"[",
"i",
"-",
"1",
"]",
";",
"character",
"[",
"i",
"]",
"=",
"character",
"[",
"i",
"-",
"1",
"]",
";",
"}",
"character",
"[",
"position",
"]",
"=",
"c",
";",
"}"
] |
Moves everything up so that the specified shift or latch character can be inserted.
@param position the position beyond which everything needs to be shifted
@param c the latch or shift character to insert at the specified position, after everything has been shifted
|
[
"Moves",
"everything",
"up",
"so",
"that",
"the",
"specified",
"shift",
"or",
"latch",
"character",
"can",
"be",
"inserted",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/MaxiCode.java#L858-L864
|
160,367 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/MaxiCode.java
|
MaxiCode.getErrorCorrection
|
private static int[] getErrorCorrection(int[] codewords, int ecclen) {
ReedSolomon rs = new ReedSolomon();
rs.init_gf(0x43);
rs.init_code(ecclen, 1);
rs.encode(codewords.length, codewords);
int[] results = new int[ecclen];
for (int i = 0; i < ecclen; i++) {
results[i] = rs.getResult(results.length - 1 - i);
}
return results;
}
|
java
|
private static int[] getErrorCorrection(int[] codewords, int ecclen) {
ReedSolomon rs = new ReedSolomon();
rs.init_gf(0x43);
rs.init_code(ecclen, 1);
rs.encode(codewords.length, codewords);
int[] results = new int[ecclen];
for (int i = 0; i < ecclen; i++) {
results[i] = rs.getResult(results.length - 1 - i);
}
return results;
}
|
[
"private",
"static",
"int",
"[",
"]",
"getErrorCorrection",
"(",
"int",
"[",
"]",
"codewords",
",",
"int",
"ecclen",
")",
"{",
"ReedSolomon",
"rs",
"=",
"new",
"ReedSolomon",
"(",
")",
";",
"rs",
".",
"init_gf",
"(",
"0x43",
")",
";",
"rs",
".",
"init_code",
"(",
"ecclen",
",",
"1",
")",
";",
"rs",
".",
"encode",
"(",
"codewords",
".",
"length",
",",
"codewords",
")",
";",
"int",
"[",
"]",
"results",
"=",
"new",
"int",
"[",
"ecclen",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ecclen",
";",
"i",
"++",
")",
"{",
"results",
"[",
"i",
"]",
"=",
"rs",
".",
"getResult",
"(",
"results",
".",
"length",
"-",
"1",
"-",
"i",
")",
";",
"}",
"return",
"results",
";",
"}"
] |
Returns the error correction codewords for the specified data codewords.
@param codewords the codewords that we need error correction codewords for
@param ecclen the number of error correction codewords needed
@return the error correction codewords for the specified data codewords
|
[
"Returns",
"the",
"error",
"correction",
"codewords",
"for",
"the",
"specified",
"data",
"codewords",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/MaxiCode.java#L873-L886
|
160,368 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/AztecCode.java
|
AztecCode.setStructuredAppendMessageId
|
public void setStructuredAppendMessageId(String messageId) {
if (messageId != null && !messageId.matches("^[\\x21-\\x7F]+$")) {
throw new IllegalArgumentException("Invalid Aztec Code structured append message ID: " + messageId);
}
this.structuredAppendMessageId = messageId;
}
|
java
|
public void setStructuredAppendMessageId(String messageId) {
if (messageId != null && !messageId.matches("^[\\x21-\\x7F]+$")) {
throw new IllegalArgumentException("Invalid Aztec Code structured append message ID: " + messageId);
}
this.structuredAppendMessageId = messageId;
}
|
[
"public",
"void",
"setStructuredAppendMessageId",
"(",
"String",
"messageId",
")",
"{",
"if",
"(",
"messageId",
"!=",
"null",
"&&",
"!",
"messageId",
".",
"matches",
"(",
"\"^[\\\\x21-\\\\x7F]+$\"",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid Aztec Code structured append message ID: \"",
"+",
"messageId",
")",
";",
"}",
"this",
".",
"structuredAppendMessageId",
"=",
"messageId",
";",
"}"
] |
If this Aztec Code symbol is part of a series of Aztec Code symbols appended in a structured format,
this method sets the unique message ID for the series. Values may not contain spaces and must contain
only printable ASCII characters. Message IDs are optional.
@param messageId the unique message ID for the series that this symbol is part of
|
[
"If",
"this",
"Aztec",
"Code",
"symbol",
"is",
"part",
"of",
"a",
"series",
"of",
"Aztec",
"Code",
"symbols",
"appended",
"in",
"a",
"structured",
"format",
"this",
"method",
"sets",
"the",
"unique",
"message",
"ID",
"for",
"the",
"series",
".",
"Values",
"may",
"not",
"contain",
"spaces",
"and",
"must",
"contain",
"only",
"printable",
"ASCII",
"characters",
".",
"Message",
"IDs",
"are",
"optional",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/AztecCode.java#L472-L477
|
160,369 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/AztecCode.java
|
AztecCode.addErrorCorrection
|
private void addErrorCorrection(StringBuilder adjustedString, int codewordSize, int dataBlocks, int eccBlocks) {
int x, poly, startWeight;
/* Split into codewords and calculate Reed-Solomon error correction codes */
switch (codewordSize) {
case 6:
x = 32;
poly = 0x43;
startWeight = 0x20;
break;
case 8:
x = 128;
poly = 0x12d;
startWeight = 0x80;
break;
case 10:
x = 512;
poly = 0x409;
startWeight = 0x200;
break;
case 12:
x = 2048;
poly = 0x1069;
startWeight = 0x800;
break;
default:
throw new OkapiException("Unrecognized codeword size: " + codewordSize);
}
ReedSolomon rs = new ReedSolomon();
int[] data = new int[dataBlocks + 3];
int[] ecc = new int[eccBlocks + 3];
for (int i = 0; i < dataBlocks; i++) {
for (int weight = 0; weight < codewordSize; weight++) {
if (adjustedString.charAt((i * codewordSize) + weight) == '1') {
data[i] += (x >> weight);
}
}
}
rs.init_gf(poly);
rs.init_code(eccBlocks, 1);
rs.encode(dataBlocks, data);
for (int i = 0; i < eccBlocks; i++) {
ecc[i] = rs.getResult(i);
}
for (int i = (eccBlocks - 1); i >= 0; i--) {
for (int weight = startWeight; weight > 0; weight = weight >> 1) {
if ((ecc[i] & weight) != 0) {
adjustedString.append('1');
} else {
adjustedString.append('0');
}
}
}
}
|
java
|
private void addErrorCorrection(StringBuilder adjustedString, int codewordSize, int dataBlocks, int eccBlocks) {
int x, poly, startWeight;
/* Split into codewords and calculate Reed-Solomon error correction codes */
switch (codewordSize) {
case 6:
x = 32;
poly = 0x43;
startWeight = 0x20;
break;
case 8:
x = 128;
poly = 0x12d;
startWeight = 0x80;
break;
case 10:
x = 512;
poly = 0x409;
startWeight = 0x200;
break;
case 12:
x = 2048;
poly = 0x1069;
startWeight = 0x800;
break;
default:
throw new OkapiException("Unrecognized codeword size: " + codewordSize);
}
ReedSolomon rs = new ReedSolomon();
int[] data = new int[dataBlocks + 3];
int[] ecc = new int[eccBlocks + 3];
for (int i = 0; i < dataBlocks; i++) {
for (int weight = 0; weight < codewordSize; weight++) {
if (adjustedString.charAt((i * codewordSize) + weight) == '1') {
data[i] += (x >> weight);
}
}
}
rs.init_gf(poly);
rs.init_code(eccBlocks, 1);
rs.encode(dataBlocks, data);
for (int i = 0; i < eccBlocks; i++) {
ecc[i] = rs.getResult(i);
}
for (int i = (eccBlocks - 1); i >= 0; i--) {
for (int weight = startWeight; weight > 0; weight = weight >> 1) {
if ((ecc[i] & weight) != 0) {
adjustedString.append('1');
} else {
adjustedString.append('0');
}
}
}
}
|
[
"private",
"void",
"addErrorCorrection",
"(",
"StringBuilder",
"adjustedString",
",",
"int",
"codewordSize",
",",
"int",
"dataBlocks",
",",
"int",
"eccBlocks",
")",
"{",
"int",
"x",
",",
"poly",
",",
"startWeight",
";",
"/* Split into codewords and calculate Reed-Solomon error correction codes */",
"switch",
"(",
"codewordSize",
")",
"{",
"case",
"6",
":",
"x",
"=",
"32",
";",
"poly",
"=",
"0x43",
";",
"startWeight",
"=",
"0x20",
";",
"break",
";",
"case",
"8",
":",
"x",
"=",
"128",
";",
"poly",
"=",
"0x12d",
";",
"startWeight",
"=",
"0x80",
";",
"break",
";",
"case",
"10",
":",
"x",
"=",
"512",
";",
"poly",
"=",
"0x409",
";",
"startWeight",
"=",
"0x200",
";",
"break",
";",
"case",
"12",
":",
"x",
"=",
"2048",
";",
"poly",
"=",
"0x1069",
";",
"startWeight",
"=",
"0x800",
";",
"break",
";",
"default",
":",
"throw",
"new",
"OkapiException",
"(",
"\"Unrecognized codeword size: \"",
"+",
"codewordSize",
")",
";",
"}",
"ReedSolomon",
"rs",
"=",
"new",
"ReedSolomon",
"(",
")",
";",
"int",
"[",
"]",
"data",
"=",
"new",
"int",
"[",
"dataBlocks",
"+",
"3",
"]",
";",
"int",
"[",
"]",
"ecc",
"=",
"new",
"int",
"[",
"eccBlocks",
"+",
"3",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"dataBlocks",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"weight",
"=",
"0",
";",
"weight",
"<",
"codewordSize",
";",
"weight",
"++",
")",
"{",
"if",
"(",
"adjustedString",
".",
"charAt",
"(",
"(",
"i",
"*",
"codewordSize",
")",
"+",
"weight",
")",
"==",
"'",
"'",
")",
"{",
"data",
"[",
"i",
"]",
"+=",
"(",
"x",
">>",
"weight",
")",
";",
"}",
"}",
"}",
"rs",
".",
"init_gf",
"(",
"poly",
")",
";",
"rs",
".",
"init_code",
"(",
"eccBlocks",
",",
"1",
")",
";",
"rs",
".",
"encode",
"(",
"dataBlocks",
",",
"data",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"eccBlocks",
";",
"i",
"++",
")",
"{",
"ecc",
"[",
"i",
"]",
"=",
"rs",
".",
"getResult",
"(",
"i",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"(",
"eccBlocks",
"-",
"1",
")",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"for",
"(",
"int",
"weight",
"=",
"startWeight",
";",
"weight",
">",
"0",
";",
"weight",
"=",
"weight",
">>",
"1",
")",
"{",
"if",
"(",
"(",
"ecc",
"[",
"i",
"]",
"&",
"weight",
")",
"!=",
"0",
")",
"{",
"adjustedString",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"adjustedString",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"}",
"}"
] |
Adds error correction data to the specified binary string, which already contains the primary data
|
[
"Adds",
"error",
"correction",
"data",
"to",
"the",
"specified",
"binary",
"string",
"which",
"already",
"contains",
"the",
"primary",
"data"
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/AztecCode.java#L1698-L1757
|
160,370 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/output/ExtendedOutputStreamWriter.java
|
ExtendedOutputStreamWriter.append
|
public ExtendedOutputStreamWriter append(double d) throws IOException {
super.append(String.format(Locale.ROOT, doubleFormat, d));
return this;
}
|
java
|
public ExtendedOutputStreamWriter append(double d) throws IOException {
super.append(String.format(Locale.ROOT, doubleFormat, d));
return this;
}
|
[
"public",
"ExtendedOutputStreamWriter",
"append",
"(",
"double",
"d",
")",
"throws",
"IOException",
"{",
"super",
".",
"append",
"(",
"String",
".",
"format",
"(",
"Locale",
".",
"ROOT",
",",
"doubleFormat",
",",
"d",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Writes the specified double to the stream, formatted according to the format specified in the constructor.
@param d the double to write to the stream
@return this writer
@throws IOException if an I/O error occurs
|
[
"Writes",
"the",
"specified",
"double",
"to",
"the",
"stream",
"formatted",
"according",
"to",
"the",
"format",
"specified",
"in",
"the",
"constructor",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/output/ExtendedOutputStreamWriter.java#L65-L68
|
160,371 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/util/Arrays.java
|
Arrays.positionOf
|
public static int positionOf(char value, char[] array) {
for (int i = 0; i < array.length; i++) {
if (value == array[i]) {
return i;
}
}
throw new OkapiException("Unable to find character '" + value + "' in character array.");
}
|
java
|
public static int positionOf(char value, char[] array) {
for (int i = 0; i < array.length; i++) {
if (value == array[i]) {
return i;
}
}
throw new OkapiException("Unable to find character '" + value + "' in character array.");
}
|
[
"public",
"static",
"int",
"positionOf",
"(",
"char",
"value",
",",
"char",
"[",
"]",
"array",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"value",
"==",
"array",
"[",
"i",
"]",
")",
"{",
"return",
"i",
";",
"}",
"}",
"throw",
"new",
"OkapiException",
"(",
"\"Unable to find character '\"",
"+",
"value",
"+",
"\"' in character array.\"",
")",
";",
"}"
] |
Returns the position of the specified value in the specified array.
@param value the value to search for
@param array the array to search in
@return the position of the specified value in the specified array
|
[
"Returns",
"the",
"position",
"of",
"the",
"specified",
"value",
"in",
"the",
"specified",
"array",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/util/Arrays.java#L39-L46
|
160,372 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/util/Arrays.java
|
Arrays.insertArray
|
public static int[] insertArray(int[] original, int index, int[] inserted) {
int[] modified = new int[original.length + inserted.length];
System.arraycopy(original, 0, modified, 0, index);
System.arraycopy(inserted, 0, modified, index, inserted.length);
System.arraycopy(original, index, modified, index + inserted.length, modified.length - index - inserted.length);
return modified;
}
|
java
|
public static int[] insertArray(int[] original, int index, int[] inserted) {
int[] modified = new int[original.length + inserted.length];
System.arraycopy(original, 0, modified, 0, index);
System.arraycopy(inserted, 0, modified, index, inserted.length);
System.arraycopy(original, index, modified, index + inserted.length, modified.length - index - inserted.length);
return modified;
}
|
[
"public",
"static",
"int",
"[",
"]",
"insertArray",
"(",
"int",
"[",
"]",
"original",
",",
"int",
"index",
",",
"int",
"[",
"]",
"inserted",
")",
"{",
"int",
"[",
"]",
"modified",
"=",
"new",
"int",
"[",
"original",
".",
"length",
"+",
"inserted",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"original",
",",
"0",
",",
"modified",
",",
"0",
",",
"index",
")",
";",
"System",
".",
"arraycopy",
"(",
"inserted",
",",
"0",
",",
"modified",
",",
"index",
",",
"inserted",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"original",
",",
"index",
",",
"modified",
",",
"index",
"+",
"inserted",
".",
"length",
",",
"modified",
".",
"length",
"-",
"index",
"-",
"inserted",
".",
"length",
")",
";",
"return",
"modified",
";",
"}"
] |
Inserts the specified array into the specified original array at the specified index.
@param original the original array into which we want to insert another array
@param index the index at which we want to insert the array
@param inserted the array that we want to insert
@return the combined array
|
[
"Inserts",
"the",
"specified",
"array",
"into",
"the",
"specified",
"original",
"array",
"at",
"the",
"specified",
"index",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/util/Arrays.java#L105-L111
|
160,373 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/QrCode.java
|
QrCode.getBinaryLength
|
private static int getBinaryLength(int version, QrMode[] inputModeUnoptimized, int[] inputData, boolean gs1, int eciMode) {
int i, j;
QrMode currentMode;
int inputLength = inputModeUnoptimized.length;
int count = 0;
int alphaLength;
int percent = 0;
// ZINT NOTE: in Zint, this call modifies the input mode array directly; here, we leave
// the original array alone so that subsequent binary length checks don't irrevocably
// optimize the mode array for the wrong QR Code version
QrMode[] inputMode = applyOptimisation(version, inputModeUnoptimized);
currentMode = QrMode.NULL;
if (gs1) {
count += 4;
}
if (eciMode != 3) {
count += 12;
}
for (i = 0; i < inputLength; i++) {
if (inputMode[i] != currentMode) {
count += 4;
switch (inputMode[i]) {
case KANJI:
count += tribus(version, 8, 10, 12);
count += (blockLength(i, inputMode) * 13);
break;
case BINARY:
count += tribus(version, 8, 16, 16);
for (j = i; j < (i + blockLength(i, inputMode)); j++) {
if (inputData[j] > 0xff) {
count += 16;
} else {
count += 8;
}
}
break;
case ALPHANUM:
count += tribus(version, 9, 11, 13);
alphaLength = blockLength(i, inputMode);
// In alphanumeric mode % becomes %%
if (gs1) {
for (j = i; j < (i + alphaLength); j++) { // TODO: need to do this only if in GS1 mode? or is the other code wrong? https://sourceforge.net/p/zint/tickets/104/#227b
if (inputData[j] == '%') {
percent++;
}
}
}
alphaLength += percent;
switch (alphaLength % 2) {
case 0:
count += (alphaLength / 2) * 11;
break;
case 1:
count += ((alphaLength - 1) / 2) * 11;
count += 6;
break;
}
break;
case NUMERIC:
count += tribus(version, 10, 12, 14);
switch (blockLength(i, inputMode) % 3) {
case 0:
count += (blockLength(i, inputMode) / 3) * 10;
break;
case 1:
count += ((blockLength(i, inputMode) - 1) / 3) * 10;
count += 4;
break;
case 2:
count += ((blockLength(i, inputMode) - 2) / 3) * 10;
count += 7;
break;
}
break;
}
currentMode = inputMode[i];
}
}
return count;
}
|
java
|
private static int getBinaryLength(int version, QrMode[] inputModeUnoptimized, int[] inputData, boolean gs1, int eciMode) {
int i, j;
QrMode currentMode;
int inputLength = inputModeUnoptimized.length;
int count = 0;
int alphaLength;
int percent = 0;
// ZINT NOTE: in Zint, this call modifies the input mode array directly; here, we leave
// the original array alone so that subsequent binary length checks don't irrevocably
// optimize the mode array for the wrong QR Code version
QrMode[] inputMode = applyOptimisation(version, inputModeUnoptimized);
currentMode = QrMode.NULL;
if (gs1) {
count += 4;
}
if (eciMode != 3) {
count += 12;
}
for (i = 0; i < inputLength; i++) {
if (inputMode[i] != currentMode) {
count += 4;
switch (inputMode[i]) {
case KANJI:
count += tribus(version, 8, 10, 12);
count += (blockLength(i, inputMode) * 13);
break;
case BINARY:
count += tribus(version, 8, 16, 16);
for (j = i; j < (i + blockLength(i, inputMode)); j++) {
if (inputData[j] > 0xff) {
count += 16;
} else {
count += 8;
}
}
break;
case ALPHANUM:
count += tribus(version, 9, 11, 13);
alphaLength = blockLength(i, inputMode);
// In alphanumeric mode % becomes %%
if (gs1) {
for (j = i; j < (i + alphaLength); j++) { // TODO: need to do this only if in GS1 mode? or is the other code wrong? https://sourceforge.net/p/zint/tickets/104/#227b
if (inputData[j] == '%') {
percent++;
}
}
}
alphaLength += percent;
switch (alphaLength % 2) {
case 0:
count += (alphaLength / 2) * 11;
break;
case 1:
count += ((alphaLength - 1) / 2) * 11;
count += 6;
break;
}
break;
case NUMERIC:
count += tribus(version, 10, 12, 14);
switch (blockLength(i, inputMode) % 3) {
case 0:
count += (blockLength(i, inputMode) / 3) * 10;
break;
case 1:
count += ((blockLength(i, inputMode) - 1) / 3) * 10;
count += 4;
break;
case 2:
count += ((blockLength(i, inputMode) - 2) / 3) * 10;
count += 7;
break;
}
break;
}
currentMode = inputMode[i];
}
}
return count;
}
|
[
"private",
"static",
"int",
"getBinaryLength",
"(",
"int",
"version",
",",
"QrMode",
"[",
"]",
"inputModeUnoptimized",
",",
"int",
"[",
"]",
"inputData",
",",
"boolean",
"gs1",
",",
"int",
"eciMode",
")",
"{",
"int",
"i",
",",
"j",
";",
"QrMode",
"currentMode",
";",
"int",
"inputLength",
"=",
"inputModeUnoptimized",
".",
"length",
";",
"int",
"count",
"=",
"0",
";",
"int",
"alphaLength",
";",
"int",
"percent",
"=",
"0",
";",
"// ZINT NOTE: in Zint, this call modifies the input mode array directly; here, we leave",
"// the original array alone so that subsequent binary length checks don't irrevocably",
"// optimize the mode array for the wrong QR Code version",
"QrMode",
"[",
"]",
"inputMode",
"=",
"applyOptimisation",
"(",
"version",
",",
"inputModeUnoptimized",
")",
";",
"currentMode",
"=",
"QrMode",
".",
"NULL",
";",
"if",
"(",
"gs1",
")",
"{",
"count",
"+=",
"4",
";",
"}",
"if",
"(",
"eciMode",
"!=",
"3",
")",
"{",
"count",
"+=",
"12",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"inputLength",
";",
"i",
"++",
")",
"{",
"if",
"(",
"inputMode",
"[",
"i",
"]",
"!=",
"currentMode",
")",
"{",
"count",
"+=",
"4",
";",
"switch",
"(",
"inputMode",
"[",
"i",
"]",
")",
"{",
"case",
"KANJI",
":",
"count",
"+=",
"tribus",
"(",
"version",
",",
"8",
",",
"10",
",",
"12",
")",
";",
"count",
"+=",
"(",
"blockLength",
"(",
"i",
",",
"inputMode",
")",
"*",
"13",
")",
";",
"break",
";",
"case",
"BINARY",
":",
"count",
"+=",
"tribus",
"(",
"version",
",",
"8",
",",
"16",
",",
"16",
")",
";",
"for",
"(",
"j",
"=",
"i",
";",
"j",
"<",
"(",
"i",
"+",
"blockLength",
"(",
"i",
",",
"inputMode",
")",
")",
";",
"j",
"++",
")",
"{",
"if",
"(",
"inputData",
"[",
"j",
"]",
">",
"0xff",
")",
"{",
"count",
"+=",
"16",
";",
"}",
"else",
"{",
"count",
"+=",
"8",
";",
"}",
"}",
"break",
";",
"case",
"ALPHANUM",
":",
"count",
"+=",
"tribus",
"(",
"version",
",",
"9",
",",
"11",
",",
"13",
")",
";",
"alphaLength",
"=",
"blockLength",
"(",
"i",
",",
"inputMode",
")",
";",
"// In alphanumeric mode % becomes %%",
"if",
"(",
"gs1",
")",
"{",
"for",
"(",
"j",
"=",
"i",
";",
"j",
"<",
"(",
"i",
"+",
"alphaLength",
")",
";",
"j",
"++",
")",
"{",
"// TODO: need to do this only if in GS1 mode? or is the other code wrong? https://sourceforge.net/p/zint/tickets/104/#227b",
"if",
"(",
"inputData",
"[",
"j",
"]",
"==",
"'",
"'",
")",
"{",
"percent",
"++",
";",
"}",
"}",
"}",
"alphaLength",
"+=",
"percent",
";",
"switch",
"(",
"alphaLength",
"%",
"2",
")",
"{",
"case",
"0",
":",
"count",
"+=",
"(",
"alphaLength",
"/",
"2",
")",
"*",
"11",
";",
"break",
";",
"case",
"1",
":",
"count",
"+=",
"(",
"(",
"alphaLength",
"-",
"1",
")",
"/",
"2",
")",
"*",
"11",
";",
"count",
"+=",
"6",
";",
"break",
";",
"}",
"break",
";",
"case",
"NUMERIC",
":",
"count",
"+=",
"tribus",
"(",
"version",
",",
"10",
",",
"12",
",",
"14",
")",
";",
"switch",
"(",
"blockLength",
"(",
"i",
",",
"inputMode",
")",
"%",
"3",
")",
"{",
"case",
"0",
":",
"count",
"+=",
"(",
"blockLength",
"(",
"i",
",",
"inputMode",
")",
"/",
"3",
")",
"*",
"10",
";",
"break",
";",
"case",
"1",
":",
"count",
"+=",
"(",
"(",
"blockLength",
"(",
"i",
",",
"inputMode",
")",
"-",
"1",
")",
"/",
"3",
")",
"*",
"10",
";",
"count",
"+=",
"4",
";",
"break",
";",
"case",
"2",
":",
"count",
"+=",
"(",
"(",
"blockLength",
"(",
"i",
",",
"inputMode",
")",
"-",
"2",
")",
"/",
"3",
")",
"*",
"10",
";",
"count",
"+=",
"7",
";",
"break",
";",
"}",
"break",
";",
"}",
"currentMode",
"=",
"inputMode",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"count",
";",
"}"
] |
Calculate the actual bit length of the proposed binary string.
|
[
"Calculate",
"the",
"actual",
"bit",
"length",
"of",
"the",
"proposed",
"binary",
"string",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/QrCode.java#L556-L642
|
160,374 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/QrCode.java
|
QrCode.blockLength
|
private static int blockLength(int start, QrMode[] inputMode) {
QrMode mode = inputMode[start];
int count = 0;
int i = start;
do {
count++;
} while (((i + count) < inputMode.length) && (inputMode[i + count] == mode));
return count;
}
|
java
|
private static int blockLength(int start, QrMode[] inputMode) {
QrMode mode = inputMode[start];
int count = 0;
int i = start;
do {
count++;
} while (((i + count) < inputMode.length) && (inputMode[i + count] == mode));
return count;
}
|
[
"private",
"static",
"int",
"blockLength",
"(",
"int",
"start",
",",
"QrMode",
"[",
"]",
"inputMode",
")",
"{",
"QrMode",
"mode",
"=",
"inputMode",
"[",
"start",
"]",
";",
"int",
"count",
"=",
"0",
";",
"int",
"i",
"=",
"start",
";",
"do",
"{",
"count",
"++",
";",
"}",
"while",
"(",
"(",
"(",
"i",
"+",
"count",
")",
"<",
"inputMode",
".",
"length",
")",
"&&",
"(",
"inputMode",
"[",
"i",
"+",
"count",
"]",
"==",
"mode",
")",
")",
";",
"return",
"count",
";",
"}"
] |
Find the length of the block starting from 'start'.
|
[
"Find",
"the",
"length",
"of",
"the",
"block",
"starting",
"from",
"start",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/QrCode.java#L760-L771
|
160,375 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/QrCode.java
|
QrCode.tribus
|
private static int tribus(int version, int a, int b, int c) {
if (version < 10) {
return a;
} else if (version >= 10 && version <= 26) {
return b;
} else {
return c;
}
}
|
java
|
private static int tribus(int version, int a, int b, int c) {
if (version < 10) {
return a;
} else if (version >= 10 && version <= 26) {
return b;
} else {
return c;
}
}
|
[
"private",
"static",
"int",
"tribus",
"(",
"int",
"version",
",",
"int",
"a",
",",
"int",
"b",
",",
"int",
"c",
")",
"{",
"if",
"(",
"version",
"<",
"10",
")",
"{",
"return",
"a",
";",
"}",
"else",
"if",
"(",
"version",
">=",
"10",
"&&",
"version",
"<=",
"26",
")",
"{",
"return",
"b",
";",
"}",
"else",
"{",
"return",
"c",
";",
"}",
"}"
] |
Choose from three numbers based on version.
|
[
"Choose",
"from",
"three",
"numbers",
"based",
"on",
"version",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/QrCode.java#L774-L782
|
160,376 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/QrCode.java
|
QrCode.addEcc
|
private static void addEcc(int[] fullstream, int[] datastream, int version, int data_cw, int blocks) {
int ecc_cw = QR_TOTAL_CODEWORDS[version - 1] - data_cw;
int short_data_block_length = data_cw / blocks;
int qty_long_blocks = data_cw % blocks;
int qty_short_blocks = blocks - qty_long_blocks;
int ecc_block_length = ecc_cw / blocks;
int i, j, length_this_block, posn;
int[] data_block = new int[short_data_block_length + 2];
int[] ecc_block = new int[ecc_block_length + 2];
int[] interleaved_data = new int[data_cw + 2];
int[] interleaved_ecc = new int[ecc_cw + 2];
posn = 0;
for (i = 0; i < blocks; i++) {
if (i < qty_short_blocks) {
length_this_block = short_data_block_length;
} else {
length_this_block = short_data_block_length + 1;
}
for (j = 0; j < ecc_block_length; j++) {
ecc_block[j] = 0;
}
for (j = 0; j < length_this_block; j++) {
data_block[j] = datastream[posn + j];
}
ReedSolomon rs = new ReedSolomon();
rs.init_gf(0x11d);
rs.init_code(ecc_block_length, 0);
rs.encode(length_this_block, data_block);
for (j = 0; j < ecc_block_length; j++) {
ecc_block[j] = rs.getResult(j);
}
for (j = 0; j < short_data_block_length; j++) {
interleaved_data[(j * blocks) + i] = data_block[j];
}
if (i >= qty_short_blocks) {
interleaved_data[(short_data_block_length * blocks) + (i - qty_short_blocks)] = data_block[short_data_block_length];
}
for (j = 0; j < ecc_block_length; j++) {
interleaved_ecc[(j * blocks) + i] = ecc_block[ecc_block_length - j - 1];
}
posn += length_this_block;
}
for (j = 0; j < data_cw; j++) {
fullstream[j] = interleaved_data[j];
}
for (j = 0; j < ecc_cw; j++) {
fullstream[j + data_cw] = interleaved_ecc[j];
}
}
|
java
|
private static void addEcc(int[] fullstream, int[] datastream, int version, int data_cw, int blocks) {
int ecc_cw = QR_TOTAL_CODEWORDS[version - 1] - data_cw;
int short_data_block_length = data_cw / blocks;
int qty_long_blocks = data_cw % blocks;
int qty_short_blocks = blocks - qty_long_blocks;
int ecc_block_length = ecc_cw / blocks;
int i, j, length_this_block, posn;
int[] data_block = new int[short_data_block_length + 2];
int[] ecc_block = new int[ecc_block_length + 2];
int[] interleaved_data = new int[data_cw + 2];
int[] interleaved_ecc = new int[ecc_cw + 2];
posn = 0;
for (i = 0; i < blocks; i++) {
if (i < qty_short_blocks) {
length_this_block = short_data_block_length;
} else {
length_this_block = short_data_block_length + 1;
}
for (j = 0; j < ecc_block_length; j++) {
ecc_block[j] = 0;
}
for (j = 0; j < length_this_block; j++) {
data_block[j] = datastream[posn + j];
}
ReedSolomon rs = new ReedSolomon();
rs.init_gf(0x11d);
rs.init_code(ecc_block_length, 0);
rs.encode(length_this_block, data_block);
for (j = 0; j < ecc_block_length; j++) {
ecc_block[j] = rs.getResult(j);
}
for (j = 0; j < short_data_block_length; j++) {
interleaved_data[(j * blocks) + i] = data_block[j];
}
if (i >= qty_short_blocks) {
interleaved_data[(short_data_block_length * blocks) + (i - qty_short_blocks)] = data_block[short_data_block_length];
}
for (j = 0; j < ecc_block_length; j++) {
interleaved_ecc[(j * blocks) + i] = ecc_block[ecc_block_length - j - 1];
}
posn += length_this_block;
}
for (j = 0; j < data_cw; j++) {
fullstream[j] = interleaved_data[j];
}
for (j = 0; j < ecc_cw; j++) {
fullstream[j + data_cw] = interleaved_ecc[j];
}
}
|
[
"private",
"static",
"void",
"addEcc",
"(",
"int",
"[",
"]",
"fullstream",
",",
"int",
"[",
"]",
"datastream",
",",
"int",
"version",
",",
"int",
"data_cw",
",",
"int",
"blocks",
")",
"{",
"int",
"ecc_cw",
"=",
"QR_TOTAL_CODEWORDS",
"[",
"version",
"-",
"1",
"]",
"-",
"data_cw",
";",
"int",
"short_data_block_length",
"=",
"data_cw",
"/",
"blocks",
";",
"int",
"qty_long_blocks",
"=",
"data_cw",
"%",
"blocks",
";",
"int",
"qty_short_blocks",
"=",
"blocks",
"-",
"qty_long_blocks",
";",
"int",
"ecc_block_length",
"=",
"ecc_cw",
"/",
"blocks",
";",
"int",
"i",
",",
"j",
",",
"length_this_block",
",",
"posn",
";",
"int",
"[",
"]",
"data_block",
"=",
"new",
"int",
"[",
"short_data_block_length",
"+",
"2",
"]",
";",
"int",
"[",
"]",
"ecc_block",
"=",
"new",
"int",
"[",
"ecc_block_length",
"+",
"2",
"]",
";",
"int",
"[",
"]",
"interleaved_data",
"=",
"new",
"int",
"[",
"data_cw",
"+",
"2",
"]",
";",
"int",
"[",
"]",
"interleaved_ecc",
"=",
"new",
"int",
"[",
"ecc_cw",
"+",
"2",
"]",
";",
"posn",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"blocks",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"<",
"qty_short_blocks",
")",
"{",
"length_this_block",
"=",
"short_data_block_length",
";",
"}",
"else",
"{",
"length_this_block",
"=",
"short_data_block_length",
"+",
"1",
";",
"}",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"ecc_block_length",
";",
"j",
"++",
")",
"{",
"ecc_block",
"[",
"j",
"]",
"=",
"0",
";",
"}",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"length_this_block",
";",
"j",
"++",
")",
"{",
"data_block",
"[",
"j",
"]",
"=",
"datastream",
"[",
"posn",
"+",
"j",
"]",
";",
"}",
"ReedSolomon",
"rs",
"=",
"new",
"ReedSolomon",
"(",
")",
";",
"rs",
".",
"init_gf",
"(",
"0x11d",
")",
";",
"rs",
".",
"init_code",
"(",
"ecc_block_length",
",",
"0",
")",
";",
"rs",
".",
"encode",
"(",
"length_this_block",
",",
"data_block",
")",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"ecc_block_length",
";",
"j",
"++",
")",
"{",
"ecc_block",
"[",
"j",
"]",
"=",
"rs",
".",
"getResult",
"(",
"j",
")",
";",
"}",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"short_data_block_length",
";",
"j",
"++",
")",
"{",
"interleaved_data",
"[",
"(",
"j",
"*",
"blocks",
")",
"+",
"i",
"]",
"=",
"data_block",
"[",
"j",
"]",
";",
"}",
"if",
"(",
"i",
">=",
"qty_short_blocks",
")",
"{",
"interleaved_data",
"[",
"(",
"short_data_block_length",
"*",
"blocks",
")",
"+",
"(",
"i",
"-",
"qty_short_blocks",
")",
"]",
"=",
"data_block",
"[",
"short_data_block_length",
"]",
";",
"}",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"ecc_block_length",
";",
"j",
"++",
")",
"{",
"interleaved_ecc",
"[",
"(",
"j",
"*",
"blocks",
")",
"+",
"i",
"]",
"=",
"ecc_block",
"[",
"ecc_block_length",
"-",
"j",
"-",
"1",
"]",
";",
"}",
"posn",
"+=",
"length_this_block",
";",
"}",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"data_cw",
";",
"j",
"++",
")",
"{",
"fullstream",
"[",
"j",
"]",
"=",
"interleaved_data",
"[",
"j",
"]",
";",
"}",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"ecc_cw",
";",
"j",
"++",
")",
"{",
"fullstream",
"[",
"j",
"+",
"data_cw",
"]",
"=",
"interleaved_ecc",
"[",
"j",
"]",
";",
"}",
"}"
] |
Splits data into blocks, adds error correction and then interleaves the blocks and error correction data.
|
[
"Splits",
"data",
"into",
"blocks",
"adds",
"error",
"correction",
"and",
"then",
"interleaves",
"the",
"blocks",
"and",
"error",
"correction",
"data",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/QrCode.java#L1047-L1108
|
160,377 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/QrCode.java
|
QrCode.addFormatInfoEval
|
private static void addFormatInfoEval(byte[] eval, int size, EccLevel ecc_level, int pattern) {
int format = pattern;
int seq;
int i;
switch(ecc_level) {
case L: format += 0x08; break;
case Q: format += 0x18; break;
case H: format += 0x10; break;
}
seq = QR_ANNEX_C[format];
for (i = 0; i < 6; i++) {
eval[(i * size) + 8] = (byte) ((((seq >> i) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
}
for (i = 0; i < 8; i++) {
eval[(8 * size) + (size - i - 1)] = (byte) ((((seq >> i) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
}
for (i = 0; i < 6; i++) {
eval[(8 * size) + (5 - i)] = (byte) ((((seq >> (i + 9)) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
}
for (i = 0; i < 7; i++) {
eval[(((size - 7) + i) * size) + 8] = (byte) ((((seq >> (i + 8)) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
}
eval[(7 * size) + 8] = (byte) ((((seq >> 6) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
eval[(8 * size) + 8] = (byte) ((((seq >> 7) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
eval[(8 * size) + 7] = (byte) ((((seq >> 8) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
}
|
java
|
private static void addFormatInfoEval(byte[] eval, int size, EccLevel ecc_level, int pattern) {
int format = pattern;
int seq;
int i;
switch(ecc_level) {
case L: format += 0x08; break;
case Q: format += 0x18; break;
case H: format += 0x10; break;
}
seq = QR_ANNEX_C[format];
for (i = 0; i < 6; i++) {
eval[(i * size) + 8] = (byte) ((((seq >> i) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
}
for (i = 0; i < 8; i++) {
eval[(8 * size) + (size - i - 1)] = (byte) ((((seq >> i) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
}
for (i = 0; i < 6; i++) {
eval[(8 * size) + (5 - i)] = (byte) ((((seq >> (i + 9)) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
}
for (i = 0; i < 7; i++) {
eval[(((size - 7) + i) * size) + 8] = (byte) ((((seq >> (i + 8)) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
}
eval[(7 * size) + 8] = (byte) ((((seq >> 6) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
eval[(8 * size) + 8] = (byte) ((((seq >> 7) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
eval[(8 * size) + 7] = (byte) ((((seq >> 8) & 0x01) != 0) ? (0x01 >> pattern) : 0x00);
}
|
[
"private",
"static",
"void",
"addFormatInfoEval",
"(",
"byte",
"[",
"]",
"eval",
",",
"int",
"size",
",",
"EccLevel",
"ecc_level",
",",
"int",
"pattern",
")",
"{",
"int",
"format",
"=",
"pattern",
";",
"int",
"seq",
";",
"int",
"i",
";",
"switch",
"(",
"ecc_level",
")",
"{",
"case",
"L",
":",
"format",
"+=",
"0x08",
";",
"break",
";",
"case",
"Q",
":",
"format",
"+=",
"0x18",
";",
"break",
";",
"case",
"H",
":",
"format",
"+=",
"0x10",
";",
"break",
";",
"}",
"seq",
"=",
"QR_ANNEX_C",
"[",
"format",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"6",
";",
"i",
"++",
")",
"{",
"eval",
"[",
"(",
"i",
"*",
"size",
")",
"+",
"8",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"(",
"seq",
">>",
"i",
")",
"&",
"0x01",
")",
"!=",
"0",
")",
"?",
"(",
"0x01",
">>",
"pattern",
")",
":",
"0x00",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"8",
";",
"i",
"++",
")",
"{",
"eval",
"[",
"(",
"8",
"*",
"size",
")",
"+",
"(",
"size",
"-",
"i",
"-",
"1",
")",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"(",
"seq",
">>",
"i",
")",
"&",
"0x01",
")",
"!=",
"0",
")",
"?",
"(",
"0x01",
">>",
"pattern",
")",
":",
"0x00",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"6",
";",
"i",
"++",
")",
"{",
"eval",
"[",
"(",
"8",
"*",
"size",
")",
"+",
"(",
"5",
"-",
"i",
")",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"(",
"seq",
">>",
"(",
"i",
"+",
"9",
")",
")",
"&",
"0x01",
")",
"!=",
"0",
")",
"?",
"(",
"0x01",
">>",
"pattern",
")",
":",
"0x00",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"7",
";",
"i",
"++",
")",
"{",
"eval",
"[",
"(",
"(",
"(",
"size",
"-",
"7",
")",
"+",
"i",
")",
"*",
"size",
")",
"+",
"8",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"(",
"seq",
">>",
"(",
"i",
"+",
"8",
")",
")",
"&",
"0x01",
")",
"!=",
"0",
")",
"?",
"(",
"0x01",
">>",
"pattern",
")",
":",
"0x00",
")",
";",
"}",
"eval",
"[",
"(",
"7",
"*",
"size",
")",
"+",
"8",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"(",
"seq",
">>",
"6",
")",
"&",
"0x01",
")",
"!=",
"0",
")",
"?",
"(",
"0x01",
">>",
"pattern",
")",
":",
"0x00",
")",
";",
"eval",
"[",
"(",
"8",
"*",
"size",
")",
"+",
"8",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"(",
"seq",
">>",
"7",
")",
"&",
"0x01",
")",
"!=",
"0",
")",
"?",
"(",
"0x01",
">>",
"pattern",
")",
":",
"0x00",
")",
";",
"eval",
"[",
"(",
"8",
"*",
"size",
")",
"+",
"7",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"(",
"seq",
">>",
"8",
")",
"&",
"0x01",
")",
"!=",
"0",
")",
"?",
"(",
"0x01",
">>",
"pattern",
")",
":",
"0x00",
")",
";",
"}"
] |
Adds format information to eval.
|
[
"Adds",
"format",
"information",
"to",
"eval",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/QrCode.java#L1379-L1412
|
160,378 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/QrCode.java
|
QrCode.addVersionInfo
|
private static void addVersionInfo(byte[] grid, int size, int version) {
// TODO: Zint masks with 0x41 instead of 0x01; which is correct? https://sourceforge.net/p/zint/tickets/110/
long version_data = QR_ANNEX_D[version - 7];
for (int i = 0; i < 6; i++) {
grid[((size - 11) * size) + i] += (version_data >> (i * 3)) & 0x01;
grid[((size - 10) * size) + i] += (version_data >> ((i * 3) + 1)) & 0x01;
grid[((size - 9) * size) + i] += (version_data >> ((i * 3) + 2)) & 0x01;
grid[(i * size) + (size - 11)] += (version_data >> (i * 3)) & 0x01;
grid[(i * size) + (size - 10)] += (version_data >> ((i * 3) + 1)) & 0x01;
grid[(i * size) + (size - 9)] += (version_data >> ((i * 3) + 2)) & 0x01;
}
}
|
java
|
private static void addVersionInfo(byte[] grid, int size, int version) {
// TODO: Zint masks with 0x41 instead of 0x01; which is correct? https://sourceforge.net/p/zint/tickets/110/
long version_data = QR_ANNEX_D[version - 7];
for (int i = 0; i < 6; i++) {
grid[((size - 11) * size) + i] += (version_data >> (i * 3)) & 0x01;
grid[((size - 10) * size) + i] += (version_data >> ((i * 3) + 1)) & 0x01;
grid[((size - 9) * size) + i] += (version_data >> ((i * 3) + 2)) & 0x01;
grid[(i * size) + (size - 11)] += (version_data >> (i * 3)) & 0x01;
grid[(i * size) + (size - 10)] += (version_data >> ((i * 3) + 1)) & 0x01;
grid[(i * size) + (size - 9)] += (version_data >> ((i * 3) + 2)) & 0x01;
}
}
|
[
"private",
"static",
"void",
"addVersionInfo",
"(",
"byte",
"[",
"]",
"grid",
",",
"int",
"size",
",",
"int",
"version",
")",
"{",
"// TODO: Zint masks with 0x41 instead of 0x01; which is correct? https://sourceforge.net/p/zint/tickets/110/",
"long",
"version_data",
"=",
"QR_ANNEX_D",
"[",
"version",
"-",
"7",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"6",
";",
"i",
"++",
")",
"{",
"grid",
"[",
"(",
"(",
"size",
"-",
"11",
")",
"*",
"size",
")",
"+",
"i",
"]",
"+=",
"(",
"version_data",
">>",
"(",
"i",
"*",
"3",
")",
")",
"&",
"0x01",
";",
"grid",
"[",
"(",
"(",
"size",
"-",
"10",
")",
"*",
"size",
")",
"+",
"i",
"]",
"+=",
"(",
"version_data",
">>",
"(",
"(",
"i",
"*",
"3",
")",
"+",
"1",
")",
")",
"&",
"0x01",
";",
"grid",
"[",
"(",
"(",
"size",
"-",
"9",
")",
"*",
"size",
")",
"+",
"i",
"]",
"+=",
"(",
"version_data",
">>",
"(",
"(",
"i",
"*",
"3",
")",
"+",
"2",
")",
")",
"&",
"0x01",
";",
"grid",
"[",
"(",
"i",
"*",
"size",
")",
"+",
"(",
"size",
"-",
"11",
")",
"]",
"+=",
"(",
"version_data",
">>",
"(",
"i",
"*",
"3",
")",
")",
"&",
"0x01",
";",
"grid",
"[",
"(",
"i",
"*",
"size",
")",
"+",
"(",
"size",
"-",
"10",
")",
"]",
"+=",
"(",
"version_data",
">>",
"(",
"(",
"i",
"*",
"3",
")",
"+",
"1",
")",
")",
"&",
"0x01",
";",
"grid",
"[",
"(",
"i",
"*",
"size",
")",
"+",
"(",
"size",
"-",
"9",
")",
"]",
"+=",
"(",
"version_data",
">>",
"(",
"(",
"i",
"*",
"3",
")",
"+",
"2",
")",
")",
"&",
"0x01",
";",
"}",
"}"
] |
Adds version information.
|
[
"Adds",
"version",
"information",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/QrCode.java#L1645-L1656
|
160,379 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/Pdf417.java
|
Pdf417.createBlocks
|
private static List< Block > createBlocks(int[] data, boolean debug) {
List< Block > blocks = new ArrayList<>();
Block current = null;
for (int i = 0; i < data.length; i++) {
EncodingMode mode = chooseMode(data[i]);
if ((current != null && current.mode == mode) &&
(mode != EncodingMode.NUM || current.length < MAX_NUMERIC_COMPACTION_BLOCK_SIZE)) {
current.length++;
} else {
current = new Block(mode);
blocks.add(current);
}
}
if (debug) {
System.out.println("Initial block pattern: " + blocks);
}
smoothBlocks(blocks);
if (debug) {
System.out.println("Final block pattern: " + blocks);
}
return blocks;
}
|
java
|
private static List< Block > createBlocks(int[] data, boolean debug) {
List< Block > blocks = new ArrayList<>();
Block current = null;
for (int i = 0; i < data.length; i++) {
EncodingMode mode = chooseMode(data[i]);
if ((current != null && current.mode == mode) &&
(mode != EncodingMode.NUM || current.length < MAX_NUMERIC_COMPACTION_BLOCK_SIZE)) {
current.length++;
} else {
current = new Block(mode);
blocks.add(current);
}
}
if (debug) {
System.out.println("Initial block pattern: " + blocks);
}
smoothBlocks(blocks);
if (debug) {
System.out.println("Final block pattern: " + blocks);
}
return blocks;
}
|
[
"private",
"static",
"List",
"<",
"Block",
">",
"createBlocks",
"(",
"int",
"[",
"]",
"data",
",",
"boolean",
"debug",
")",
"{",
"List",
"<",
"Block",
">",
"blocks",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Block",
"current",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"++",
")",
"{",
"EncodingMode",
"mode",
"=",
"chooseMode",
"(",
"data",
"[",
"i",
"]",
")",
";",
"if",
"(",
"(",
"current",
"!=",
"null",
"&&",
"current",
".",
"mode",
"==",
"mode",
")",
"&&",
"(",
"mode",
"!=",
"EncodingMode",
".",
"NUM",
"||",
"current",
".",
"length",
"<",
"MAX_NUMERIC_COMPACTION_BLOCK_SIZE",
")",
")",
"{",
"current",
".",
"length",
"++",
";",
"}",
"else",
"{",
"current",
"=",
"new",
"Block",
"(",
"mode",
")",
";",
"blocks",
".",
"add",
"(",
"current",
")",
";",
"}",
"}",
"if",
"(",
"debug",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Initial block pattern: \"",
"+",
"blocks",
")",
";",
"}",
"smoothBlocks",
"(",
"blocks",
")",
";",
"if",
"(",
"debug",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Final block pattern: \"",
"+",
"blocks",
")",
";",
"}",
"return",
"blocks",
";",
"}"
] |
Determines the encoding block groups for the specified data.
|
[
"Determines",
"the",
"encoding",
"block",
"groups",
"for",
"the",
"specified",
"data",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/Pdf417.java#L1294-L1321
|
160,380 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/Pdf417.java
|
Pdf417.mergeBlocks
|
private static void mergeBlocks(List< Block > blocks) {
for (int i = 1; i < blocks.size(); i++) {
Block b1 = blocks.get(i - 1);
Block b2 = blocks.get(i);
if ((b1.mode == b2.mode) &&
(b1.mode != EncodingMode.NUM || b1.length + b2.length <= MAX_NUMERIC_COMPACTION_BLOCK_SIZE)) {
b1.length += b2.length;
blocks.remove(i);
i--;
}
}
}
|
java
|
private static void mergeBlocks(List< Block > blocks) {
for (int i = 1; i < blocks.size(); i++) {
Block b1 = blocks.get(i - 1);
Block b2 = blocks.get(i);
if ((b1.mode == b2.mode) &&
(b1.mode != EncodingMode.NUM || b1.length + b2.length <= MAX_NUMERIC_COMPACTION_BLOCK_SIZE)) {
b1.length += b2.length;
blocks.remove(i);
i--;
}
}
}
|
[
"private",
"static",
"void",
"mergeBlocks",
"(",
"List",
"<",
"Block",
">",
"blocks",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"blocks",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Block",
"b1",
"=",
"blocks",
".",
"get",
"(",
"i",
"-",
"1",
")",
";",
"Block",
"b2",
"=",
"blocks",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"(",
"b1",
".",
"mode",
"==",
"b2",
".",
"mode",
")",
"&&",
"(",
"b1",
".",
"mode",
"!=",
"EncodingMode",
".",
"NUM",
"||",
"b1",
".",
"length",
"+",
"b2",
".",
"length",
"<=",
"MAX_NUMERIC_COMPACTION_BLOCK_SIZE",
")",
")",
"{",
"b1",
".",
"length",
"+=",
"b2",
".",
"length",
";",
"blocks",
".",
"remove",
"(",
"i",
")",
";",
"i",
"--",
";",
"}",
"}",
"}"
] |
Combines adjacent blocks of the same type.
|
[
"Combines",
"adjacent",
"blocks",
"of",
"the",
"same",
"type",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/Pdf417.java#L1386-L1397
|
160,381 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/Symbol.java
|
Symbol.eciProcess
|
protected void eciProcess() {
EciMode eci = EciMode.of(content, "ISO8859_1", 3)
.or(content, "ISO8859_2", 4)
.or(content, "ISO8859_3", 5)
.or(content, "ISO8859_4", 6)
.or(content, "ISO8859_5", 7)
.or(content, "ISO8859_6", 8)
.or(content, "ISO8859_7", 9)
.or(content, "ISO8859_8", 10)
.or(content, "ISO8859_9", 11)
.or(content, "ISO8859_10", 12)
.or(content, "ISO8859_11", 13)
.or(content, "ISO8859_13", 15)
.or(content, "ISO8859_14", 16)
.or(content, "ISO8859_15", 17)
.or(content, "ISO8859_16", 18)
.or(content, "Windows_1250", 21)
.or(content, "Windows_1251", 22)
.or(content, "Windows_1252", 23)
.or(content, "Windows_1256", 24)
.or(content, "SJIS", 20)
.or(content, "UTF8", 26);
if (EciMode.NONE.equals(eci)) {
throw new OkapiException("Unable to determine ECI mode.");
}
eciMode = eci.mode;
inputData = toBytes(content, eci.charset);
encodeInfo += "ECI Mode: " + eci.mode + "\n";
encodeInfo += "ECI Charset: " + eci.charset.name() + "\n";
}
|
java
|
protected void eciProcess() {
EciMode eci = EciMode.of(content, "ISO8859_1", 3)
.or(content, "ISO8859_2", 4)
.or(content, "ISO8859_3", 5)
.or(content, "ISO8859_4", 6)
.or(content, "ISO8859_5", 7)
.or(content, "ISO8859_6", 8)
.or(content, "ISO8859_7", 9)
.or(content, "ISO8859_8", 10)
.or(content, "ISO8859_9", 11)
.or(content, "ISO8859_10", 12)
.or(content, "ISO8859_11", 13)
.or(content, "ISO8859_13", 15)
.or(content, "ISO8859_14", 16)
.or(content, "ISO8859_15", 17)
.or(content, "ISO8859_16", 18)
.or(content, "Windows_1250", 21)
.or(content, "Windows_1251", 22)
.or(content, "Windows_1252", 23)
.or(content, "Windows_1256", 24)
.or(content, "SJIS", 20)
.or(content, "UTF8", 26);
if (EciMode.NONE.equals(eci)) {
throw new OkapiException("Unable to determine ECI mode.");
}
eciMode = eci.mode;
inputData = toBytes(content, eci.charset);
encodeInfo += "ECI Mode: " + eci.mode + "\n";
encodeInfo += "ECI Charset: " + eci.charset.name() + "\n";
}
|
[
"protected",
"void",
"eciProcess",
"(",
")",
"{",
"EciMode",
"eci",
"=",
"EciMode",
".",
"of",
"(",
"content",
",",
"\"ISO8859_1\"",
",",
"3",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_2\"",
",",
"4",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_3\"",
",",
"5",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_4\"",
",",
"6",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_5\"",
",",
"7",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_6\"",
",",
"8",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_7\"",
",",
"9",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_8\"",
",",
"10",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_9\"",
",",
"11",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_10\"",
",",
"12",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_11\"",
",",
"13",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_13\"",
",",
"15",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_14\"",
",",
"16",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_15\"",
",",
"17",
")",
".",
"or",
"(",
"content",
",",
"\"ISO8859_16\"",
",",
"18",
")",
".",
"or",
"(",
"content",
",",
"\"Windows_1250\"",
",",
"21",
")",
".",
"or",
"(",
"content",
",",
"\"Windows_1251\"",
",",
"22",
")",
".",
"or",
"(",
"content",
",",
"\"Windows_1252\"",
",",
"23",
")",
".",
"or",
"(",
"content",
",",
"\"Windows_1256\"",
",",
"24",
")",
".",
"or",
"(",
"content",
",",
"\"SJIS\"",
",",
"20",
")",
".",
"or",
"(",
"content",
",",
"\"UTF8\"",
",",
"26",
")",
";",
"if",
"(",
"EciMode",
".",
"NONE",
".",
"equals",
"(",
"eci",
")",
")",
"{",
"throw",
"new",
"OkapiException",
"(",
"\"Unable to determine ECI mode.\"",
")",
";",
"}",
"eciMode",
"=",
"eci",
".",
"mode",
";",
"inputData",
"=",
"toBytes",
"(",
"content",
",",
"eci",
".",
"charset",
")",
";",
"encodeInfo",
"+=",
"\"ECI Mode: \"",
"+",
"eci",
".",
"mode",
"+",
"\"\\n\"",
";",
"encodeInfo",
"+=",
"\"ECI Charset: \"",
"+",
"eci",
".",
"charset",
".",
"name",
"(",
")",
"+",
"\"\\n\"",
";",
"}"
] |
Chooses the ECI mode most suitable for the content of this symbol.
|
[
"Chooses",
"the",
"ECI",
"mode",
"most",
"suitable",
"for",
"the",
"content",
"of",
"this",
"symbol",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/Symbol.java#L559-L592
|
160,382 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/Symbol.java
|
Symbol.mergeVerticalBlocks
|
protected void mergeVerticalBlocks() {
for(int i = 0; i < rectangles.size() - 1; i++) {
for(int j = i + 1; j < rectangles.size(); j++) {
Rectangle2D.Double firstRect = rectangles.get(i);
Rectangle2D.Double secondRect = rectangles.get(j);
if (roughlyEqual(firstRect.x, secondRect.x) && roughlyEqual(firstRect.width, secondRect.width)) {
if (roughlyEqual(firstRect.y + firstRect.height, secondRect.y)) {
firstRect.height += secondRect.height;
rectangles.set(i, firstRect);
rectangles.remove(j);
}
}
}
}
}
|
java
|
protected void mergeVerticalBlocks() {
for(int i = 0; i < rectangles.size() - 1; i++) {
for(int j = i + 1; j < rectangles.size(); j++) {
Rectangle2D.Double firstRect = rectangles.get(i);
Rectangle2D.Double secondRect = rectangles.get(j);
if (roughlyEqual(firstRect.x, secondRect.x) && roughlyEqual(firstRect.width, secondRect.width)) {
if (roughlyEqual(firstRect.y + firstRect.height, secondRect.y)) {
firstRect.height += secondRect.height;
rectangles.set(i, firstRect);
rectangles.remove(j);
}
}
}
}
}
|
[
"protected",
"void",
"mergeVerticalBlocks",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rectangles",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"i",
"+",
"1",
";",
"j",
"<",
"rectangles",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"Rectangle2D",
".",
"Double",
"firstRect",
"=",
"rectangles",
".",
"get",
"(",
"i",
")",
";",
"Rectangle2D",
".",
"Double",
"secondRect",
"=",
"rectangles",
".",
"get",
"(",
"j",
")",
";",
"if",
"(",
"roughlyEqual",
"(",
"firstRect",
".",
"x",
",",
"secondRect",
".",
"x",
")",
"&&",
"roughlyEqual",
"(",
"firstRect",
".",
"width",
",",
"secondRect",
".",
"width",
")",
")",
"{",
"if",
"(",
"roughlyEqual",
"(",
"firstRect",
".",
"y",
"+",
"firstRect",
".",
"height",
",",
"secondRect",
".",
"y",
")",
")",
"{",
"firstRect",
".",
"height",
"+=",
"secondRect",
".",
"height",
";",
"rectangles",
".",
"set",
"(",
"i",
",",
"firstRect",
")",
";",
"rectangles",
".",
"remove",
"(",
"j",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Search for rectangles which have the same width and x position, and
which join together vertically and merge them together to reduce the
number of rectangles needed to describe a symbol.
|
[
"Search",
"for",
"rectangles",
"which",
"have",
"the",
"same",
"width",
"and",
"x",
"position",
"and",
"which",
"join",
"together",
"vertically",
"and",
"merge",
"them",
"together",
"to",
"reduce",
"the",
"number",
"of",
"rectangles",
"needed",
"to",
"describe",
"a",
"symbol",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/Symbol.java#L715-L729
|
160,383 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/Symbol.java
|
Symbol.hibcProcess
|
private String hibcProcess(String source) {
// HIBC 2.6 allows up to 110 characters, not including the "+" prefix or the check digit
if (source.length() > 110) {
throw new OkapiException("Data too long for HIBC LIC");
}
source = source.toUpperCase();
if (!source.matches("[A-Z0-9-\\. \\$/+\\%]+?")) {
throw new OkapiException("Invalid characters in input");
}
int counter = 41;
for (int i = 0; i < source.length(); i++) {
counter += positionOf(source.charAt(i), HIBC_CHAR_TABLE);
}
counter = counter % 43;
char checkDigit = HIBC_CHAR_TABLE[counter];
encodeInfo += "HIBC Check Digit Counter: " + counter + "\n";
encodeInfo += "HIBC Check Digit: " + checkDigit + "\n";
return "+" + source + checkDigit;
}
|
java
|
private String hibcProcess(String source) {
// HIBC 2.6 allows up to 110 characters, not including the "+" prefix or the check digit
if (source.length() > 110) {
throw new OkapiException("Data too long for HIBC LIC");
}
source = source.toUpperCase();
if (!source.matches("[A-Z0-9-\\. \\$/+\\%]+?")) {
throw new OkapiException("Invalid characters in input");
}
int counter = 41;
for (int i = 0; i < source.length(); i++) {
counter += positionOf(source.charAt(i), HIBC_CHAR_TABLE);
}
counter = counter % 43;
char checkDigit = HIBC_CHAR_TABLE[counter];
encodeInfo += "HIBC Check Digit Counter: " + counter + "\n";
encodeInfo += "HIBC Check Digit: " + checkDigit + "\n";
return "+" + source + checkDigit;
}
|
[
"private",
"String",
"hibcProcess",
"(",
"String",
"source",
")",
"{",
"// HIBC 2.6 allows up to 110 characters, not including the \"+\" prefix or the check digit",
"if",
"(",
"source",
".",
"length",
"(",
")",
">",
"110",
")",
"{",
"throw",
"new",
"OkapiException",
"(",
"\"Data too long for HIBC LIC\"",
")",
";",
"}",
"source",
"=",
"source",
".",
"toUpperCase",
"(",
")",
";",
"if",
"(",
"!",
"source",
".",
"matches",
"(",
"\"[A-Z0-9-\\\\. \\\\$/+\\\\%]+?\"",
")",
")",
"{",
"throw",
"new",
"OkapiException",
"(",
"\"Invalid characters in input\"",
")",
";",
"}",
"int",
"counter",
"=",
"41",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"source",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"counter",
"+=",
"positionOf",
"(",
"source",
".",
"charAt",
"(",
"i",
")",
",",
"HIBC_CHAR_TABLE",
")",
";",
"}",
"counter",
"=",
"counter",
"%",
"43",
";",
"char",
"checkDigit",
"=",
"HIBC_CHAR_TABLE",
"[",
"counter",
"]",
";",
"encodeInfo",
"+=",
"\"HIBC Check Digit Counter: \"",
"+",
"counter",
"+",
"\"\\n\"",
";",
"encodeInfo",
"+=",
"\"HIBC Check Digit: \"",
"+",
"checkDigit",
"+",
"\"\\n\"",
";",
"return",
"\"+\"",
"+",
"source",
"+",
"checkDigit",
";",
"}"
] |
Adds the HIBC prefix and check digit to the specified data, returning the resultant data string.
@see <a href="https://sourceforge.net/p/zint/code/ci/master/tree/backend/library.c">Corresponding Zint code</a>
|
[
"Adds",
"the",
"HIBC",
"prefix",
"and",
"check",
"digit",
"to",
"the",
"specified",
"data",
"returning",
"the",
"resultant",
"data",
"string",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/Symbol.java#L736-L760
|
160,384 |
woo-j/OkapiBarcode
|
src/main/java/uk/org/okapibarcode/backend/Symbol.java
|
Symbol.getPatternAsCodewords
|
protected int[] getPatternAsCodewords(int size) {
if (size >= 10) {
throw new IllegalArgumentException("Pattern groups of 10 or more digits are likely to be too large to parse as integers.");
}
if (pattern == null || pattern.length == 0) {
return new int[0];
} else {
int count = (int) Math.ceil(pattern[0].length() / (double) size);
int[] codewords = new int[pattern.length * count];
for (int i = 0; i < pattern.length; i++) {
String row = pattern[i];
for (int j = 0; j < count; j++) {
int substringStart = j * size;
int substringEnd = Math.min((j + 1) * size, row.length());
codewords[(i * count) + j] = Integer.parseInt(row.substring(substringStart, substringEnd));
}
}
return codewords;
}
}
|
java
|
protected int[] getPatternAsCodewords(int size) {
if (size >= 10) {
throw new IllegalArgumentException("Pattern groups of 10 or more digits are likely to be too large to parse as integers.");
}
if (pattern == null || pattern.length == 0) {
return new int[0];
} else {
int count = (int) Math.ceil(pattern[0].length() / (double) size);
int[] codewords = new int[pattern.length * count];
for (int i = 0; i < pattern.length; i++) {
String row = pattern[i];
for (int j = 0; j < count; j++) {
int substringStart = j * size;
int substringEnd = Math.min((j + 1) * size, row.length());
codewords[(i * count) + j] = Integer.parseInt(row.substring(substringStart, substringEnd));
}
}
return codewords;
}
}
|
[
"protected",
"int",
"[",
"]",
"getPatternAsCodewords",
"(",
"int",
"size",
")",
"{",
"if",
"(",
"size",
">=",
"10",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Pattern groups of 10 or more digits are likely to be too large to parse as integers.\"",
")",
";",
"}",
"if",
"(",
"pattern",
"==",
"null",
"||",
"pattern",
".",
"length",
"==",
"0",
")",
"{",
"return",
"new",
"int",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"int",
"count",
"=",
"(",
"int",
")",
"Math",
".",
"ceil",
"(",
"pattern",
"[",
"0",
"]",
".",
"length",
"(",
")",
"/",
"(",
"double",
")",
"size",
")",
";",
"int",
"[",
"]",
"codewords",
"=",
"new",
"int",
"[",
"pattern",
".",
"length",
"*",
"count",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pattern",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"row",
"=",
"pattern",
"[",
"i",
"]",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"count",
";",
"j",
"++",
")",
"{",
"int",
"substringStart",
"=",
"j",
"*",
"size",
";",
"int",
"substringEnd",
"=",
"Math",
".",
"min",
"(",
"(",
"j",
"+",
"1",
")",
"*",
"size",
",",
"row",
".",
"length",
"(",
")",
")",
";",
"codewords",
"[",
"(",
"i",
"*",
"count",
")",
"+",
"j",
"]",
"=",
"Integer",
".",
"parseInt",
"(",
"row",
".",
"substring",
"(",
"substringStart",
",",
"substringEnd",
")",
")",
";",
"}",
"}",
"return",
"codewords",
";",
"}",
"}"
] |
Returns this bar code's pattern, converted into a set of corresponding codewords.
Useful for bar codes that encode their content as a pattern.
@param size the number of digits in each codeword
@return this bar code's pattern, converted into a set of corresponding codewords
|
[
"Returns",
"this",
"bar",
"code",
"s",
"pattern",
"converted",
"into",
"a",
"set",
"of",
"corresponding",
"codewords",
".",
"Useful",
"for",
"bar",
"codes",
"that",
"encode",
"their",
"content",
"as",
"a",
"pattern",
"."
] |
d1cb4f4ab64557cd3db64d9a473528a52ce58081
|
https://github.com/woo-j/OkapiBarcode/blob/d1cb4f4ab64557cd3db64d9a473528a52ce58081/src/main/java/uk/org/okapibarcode/backend/Symbol.java#L779-L798
|
160,385 |
linroid/FilterMenu
|
library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java
|
FilterMenuLayout.arcAngle
|
private static double arcAngle(Point center, Point a, Point b, Rect area, int radius) {
double angle = threePointsAngle(center, a, b);
Point innerPoint = findMidnormalPoint(center, a, b, area, radius);
Point midInsectPoint = new Point((a.x + b.x) / 2, (a.y + b.y) / 2);
double distance = pointsDistance(midInsectPoint, innerPoint);
if (distance > radius) {
return 360 - angle;
}
return angle;
}
|
java
|
private static double arcAngle(Point center, Point a, Point b, Rect area, int radius) {
double angle = threePointsAngle(center, a, b);
Point innerPoint = findMidnormalPoint(center, a, b, area, radius);
Point midInsectPoint = new Point((a.x + b.x) / 2, (a.y + b.y) / 2);
double distance = pointsDistance(midInsectPoint, innerPoint);
if (distance > radius) {
return 360 - angle;
}
return angle;
}
|
[
"private",
"static",
"double",
"arcAngle",
"(",
"Point",
"center",
",",
"Point",
"a",
",",
"Point",
"b",
",",
"Rect",
"area",
",",
"int",
"radius",
")",
"{",
"double",
"angle",
"=",
"threePointsAngle",
"(",
"center",
",",
"a",
",",
"b",
")",
";",
"Point",
"innerPoint",
"=",
"findMidnormalPoint",
"(",
"center",
",",
"a",
",",
"b",
",",
"area",
",",
"radius",
")",
";",
"Point",
"midInsectPoint",
"=",
"new",
"Point",
"(",
"(",
"a",
".",
"x",
"+",
"b",
".",
"x",
")",
"/",
"2",
",",
"(",
"a",
".",
"y",
"+",
"b",
".",
"y",
")",
"/",
"2",
")",
";",
"double",
"distance",
"=",
"pointsDistance",
"(",
"midInsectPoint",
",",
"innerPoint",
")",
";",
"if",
"(",
"distance",
">",
"radius",
")",
"{",
"return",
"360",
"-",
"angle",
";",
"}",
"return",
"angle",
";",
"}"
] |
calculate arc angle between point a and point b
@param center
@param a
@param b
@param area
@param radius
@return
|
[
"calculate",
"arc",
"angle",
"between",
"point",
"a",
"and",
"point",
"b"
] |
5a6e5472631c2304b71a51034683f38271962ef5
|
https://github.com/linroid/FilterMenu/blob/5a6e5472631c2304b71a51034683f38271962ef5/library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java#L143-L152
|
160,386 |
linroid/FilterMenu
|
library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java
|
FilterMenuLayout.findMidnormalPoint
|
private static Point findMidnormalPoint(Point center, Point a, Point b, Rect area, int radius) {
if (a.y == b.y) {
//top
if (a.y < center.y) {
return new Point((a.x + b.x) / 2, center.y + radius);
}
//bottom
return new Point((a.x + b.x) / 2, center.y - radius);
}
if (a.x == b.x) {
//left
if (a.x < center.x) {
return new Point(center.x + radius, (a.y + b.y) / 2);
}
//right
return new Point(center.x - radius, (a.y + b.y) / 2);
}
//slope of line ab
double abSlope = (a.y - b.y) / (a.x - b.x * 1.0);
//slope of midnormal
double midnormalSlope = -1.0 / abSlope;
double radian = Math.tan(midnormalSlope);
int dy = (int) (radius * Math.sin(radian));
int dx = (int) (radius * Math.cos(radian));
Point point = new Point(center.x + dx, center.y + dy);
if (!inArea(point, area, 0)) {
point = new Point(center.x - dx, center.y - dy);
}
return point;
}
|
java
|
private static Point findMidnormalPoint(Point center, Point a, Point b, Rect area, int radius) {
if (a.y == b.y) {
//top
if (a.y < center.y) {
return new Point((a.x + b.x) / 2, center.y + radius);
}
//bottom
return new Point((a.x + b.x) / 2, center.y - radius);
}
if (a.x == b.x) {
//left
if (a.x < center.x) {
return new Point(center.x + radius, (a.y + b.y) / 2);
}
//right
return new Point(center.x - radius, (a.y + b.y) / 2);
}
//slope of line ab
double abSlope = (a.y - b.y) / (a.x - b.x * 1.0);
//slope of midnormal
double midnormalSlope = -1.0 / abSlope;
double radian = Math.tan(midnormalSlope);
int dy = (int) (radius * Math.sin(radian));
int dx = (int) (radius * Math.cos(radian));
Point point = new Point(center.x + dx, center.y + dy);
if (!inArea(point, area, 0)) {
point = new Point(center.x - dx, center.y - dy);
}
return point;
}
|
[
"private",
"static",
"Point",
"findMidnormalPoint",
"(",
"Point",
"center",
",",
"Point",
"a",
",",
"Point",
"b",
",",
"Rect",
"area",
",",
"int",
"radius",
")",
"{",
"if",
"(",
"a",
".",
"y",
"==",
"b",
".",
"y",
")",
"{",
"//top",
"if",
"(",
"a",
".",
"y",
"<",
"center",
".",
"y",
")",
"{",
"return",
"new",
"Point",
"(",
"(",
"a",
".",
"x",
"+",
"b",
".",
"x",
")",
"/",
"2",
",",
"center",
".",
"y",
"+",
"radius",
")",
";",
"}",
"//bottom",
"return",
"new",
"Point",
"(",
"(",
"a",
".",
"x",
"+",
"b",
".",
"x",
")",
"/",
"2",
",",
"center",
".",
"y",
"-",
"radius",
")",
";",
"}",
"if",
"(",
"a",
".",
"x",
"==",
"b",
".",
"x",
")",
"{",
"//left",
"if",
"(",
"a",
".",
"x",
"<",
"center",
".",
"x",
")",
"{",
"return",
"new",
"Point",
"(",
"center",
".",
"x",
"+",
"radius",
",",
"(",
"a",
".",
"y",
"+",
"b",
".",
"y",
")",
"/",
"2",
")",
";",
"}",
"//right",
"return",
"new",
"Point",
"(",
"center",
".",
"x",
"-",
"radius",
",",
"(",
"a",
".",
"y",
"+",
"b",
".",
"y",
")",
"/",
"2",
")",
";",
"}",
"//slope of line ab",
"double",
"abSlope",
"=",
"(",
"a",
".",
"y",
"-",
"b",
".",
"y",
")",
"/",
"(",
"a",
".",
"x",
"-",
"b",
".",
"x",
"*",
"1.0",
")",
";",
"//slope of midnormal",
"double",
"midnormalSlope",
"=",
"-",
"1.0",
"/",
"abSlope",
";",
"double",
"radian",
"=",
"Math",
".",
"tan",
"(",
"midnormalSlope",
")",
";",
"int",
"dy",
"=",
"(",
"int",
")",
"(",
"radius",
"*",
"Math",
".",
"sin",
"(",
"radian",
")",
")",
";",
"int",
"dx",
"=",
"(",
"int",
")",
"(",
"radius",
"*",
"Math",
".",
"cos",
"(",
"radian",
")",
")",
";",
"Point",
"point",
"=",
"new",
"Point",
"(",
"center",
".",
"x",
"+",
"dx",
",",
"center",
".",
"y",
"+",
"dy",
")",
";",
"if",
"(",
"!",
"inArea",
"(",
"point",
",",
"area",
",",
"0",
")",
")",
"{",
"point",
"=",
"new",
"Point",
"(",
"center",
".",
"x",
"-",
"dx",
",",
"center",
".",
"y",
"-",
"dy",
")",
";",
"}",
"return",
"point",
";",
"}"
] |
find the middle point of two intersect points in circle,only one point will be correct
@param center
@param a
@param b
@param area
@param radius
@return
|
[
"find",
"the",
"middle",
"point",
"of",
"two",
"intersect",
"points",
"in",
"circle",
"only",
"one",
"point",
"will",
"be",
"correct"
] |
5a6e5472631c2304b71a51034683f38271962ef5
|
https://github.com/linroid/FilterMenu/blob/5a6e5472631c2304b71a51034683f38271962ef5/library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java#L164-L194
|
160,387 |
linroid/FilterMenu
|
library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java
|
FilterMenuLayout.inArea
|
public static boolean inArea(Point point, Rect area, float offsetRatio) {
int offset = (int) (area.width() * offsetRatio);
return point.x >= area.left - offset && point.x <= area.right + offset &&
point.y >= area.top - offset && point.y <= area.bottom + offset;
}
|
java
|
public static boolean inArea(Point point, Rect area, float offsetRatio) {
int offset = (int) (area.width() * offsetRatio);
return point.x >= area.left - offset && point.x <= area.right + offset &&
point.y >= area.top - offset && point.y <= area.bottom + offset;
}
|
[
"public",
"static",
"boolean",
"inArea",
"(",
"Point",
"point",
",",
"Rect",
"area",
",",
"float",
"offsetRatio",
")",
"{",
"int",
"offset",
"=",
"(",
"int",
")",
"(",
"area",
".",
"width",
"(",
")",
"*",
"offsetRatio",
")",
";",
"return",
"point",
".",
"x",
">=",
"area",
".",
"left",
"-",
"offset",
"&&",
"point",
".",
"x",
"<=",
"area",
".",
"right",
"+",
"offset",
"&&",
"point",
".",
"y",
">=",
"area",
".",
"top",
"-",
"offset",
"&&",
"point",
".",
"y",
"<=",
"area",
".",
"bottom",
"+",
"offset",
";",
"}"
] |
judge if an point in the area or not
@param point
@param area
@param offsetRatio
@return
|
[
"judge",
"if",
"an",
"point",
"in",
"the",
"area",
"or",
"not"
] |
5a6e5472631c2304b71a51034683f38271962ef5
|
https://github.com/linroid/FilterMenu/blob/5a6e5472631c2304b71a51034683f38271962ef5/library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java#L212-L216
|
160,388 |
linroid/FilterMenu
|
library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java
|
FilterMenuLayout.threePointsAngle
|
private static double threePointsAngle(Point vertex, Point A, Point B) {
double b = pointsDistance(vertex, A);
double c = pointsDistance(A, B);
double a = pointsDistance(B, vertex);
return Math.toDegrees(Math.acos((a * a + b * b - c * c) / (2 * a * b)));
}
|
java
|
private static double threePointsAngle(Point vertex, Point A, Point B) {
double b = pointsDistance(vertex, A);
double c = pointsDistance(A, B);
double a = pointsDistance(B, vertex);
return Math.toDegrees(Math.acos((a * a + b * b - c * c) / (2 * a * b)));
}
|
[
"private",
"static",
"double",
"threePointsAngle",
"(",
"Point",
"vertex",
",",
"Point",
"A",
",",
"Point",
"B",
")",
"{",
"double",
"b",
"=",
"pointsDistance",
"(",
"vertex",
",",
"A",
")",
";",
"double",
"c",
"=",
"pointsDistance",
"(",
"A",
",",
"B",
")",
";",
"double",
"a",
"=",
"pointsDistance",
"(",
"B",
",",
"vertex",
")",
";",
"return",
"Math",
".",
"toDegrees",
"(",
"Math",
".",
"acos",
"(",
"(",
"a",
"*",
"a",
"+",
"b",
"*",
"b",
"-",
"c",
"*",
"c",
")",
"/",
"(",
"2",
"*",
"a",
"*",
"b",
")",
")",
")",
";",
"}"
] |
calculate the point a's angle of rectangle consist of point a,point b, point c;
@param vertex
@param A
@param B
@return
|
[
"calculate",
"the",
"point",
"a",
"s",
"angle",
"of",
"rectangle",
"consist",
"of",
"point",
"a",
"point",
"b",
"point",
"c",
";"
] |
5a6e5472631c2304b71a51034683f38271962ef5
|
https://github.com/linroid/FilterMenu/blob/5a6e5472631c2304b71a51034683f38271962ef5/library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java#L226-L233
|
160,389 |
linroid/FilterMenu
|
library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java
|
FilterMenuLayout.pointsDistance
|
private static double pointsDistance(Point a, Point b) {
int dx = b.x - a.x;
int dy = b.y - a.y;
return Math.sqrt(dx * dx + dy * dy);
}
|
java
|
private static double pointsDistance(Point a, Point b) {
int dx = b.x - a.x;
int dy = b.y - a.y;
return Math.sqrt(dx * dx + dy * dy);
}
|
[
"private",
"static",
"double",
"pointsDistance",
"(",
"Point",
"a",
",",
"Point",
"b",
")",
"{",
"int",
"dx",
"=",
"b",
".",
"x",
"-",
"a",
".",
"x",
";",
"int",
"dy",
"=",
"b",
".",
"y",
"-",
"a",
".",
"y",
";",
"return",
"Math",
".",
"sqrt",
"(",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"dy",
")",
";",
"}"
] |
calculate distance of two points
@param a
@param b
@return
|
[
"calculate",
"distance",
"of",
"two",
"points"
] |
5a6e5472631c2304b71a51034683f38271962ef5
|
https://github.com/linroid/FilterMenu/blob/5a6e5472631c2304b71a51034683f38271962ef5/library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java#L242-L246
|
160,390 |
linroid/FilterMenu
|
library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java
|
FilterMenuLayout.calculateMenuItemPosition
|
private void calculateMenuItemPosition() {
float itemRadius = (expandedRadius + collapsedRadius) / 2, f;
RectF area = new RectF(
center.x - itemRadius,
center.y - itemRadius,
center.x + itemRadius,
center.y + itemRadius);
Path path = new Path();
path.addArc(area, (float) fromAngle, (float) (toAngle - fromAngle));
PathMeasure measure = new PathMeasure(path, false);
float len = measure.getLength();
int divisor = getChildCount();
float divider = len / divisor;
for (int i = 0; i < getChildCount(); i++) {
float[] coords = new float[2];
measure.getPosTan(i * divider + divider * .5f, coords, null);
FilterMenu.Item item = (FilterMenu.Item) getChildAt(i).getTag();
item.setX((int) coords[0] - item.getView().getMeasuredWidth() / 2);
item.setY((int) coords[1] - item.getView().getMeasuredHeight() / 2);
}
}
|
java
|
private void calculateMenuItemPosition() {
float itemRadius = (expandedRadius + collapsedRadius) / 2, f;
RectF area = new RectF(
center.x - itemRadius,
center.y - itemRadius,
center.x + itemRadius,
center.y + itemRadius);
Path path = new Path();
path.addArc(area, (float) fromAngle, (float) (toAngle - fromAngle));
PathMeasure measure = new PathMeasure(path, false);
float len = measure.getLength();
int divisor = getChildCount();
float divider = len / divisor;
for (int i = 0; i < getChildCount(); i++) {
float[] coords = new float[2];
measure.getPosTan(i * divider + divider * .5f, coords, null);
FilterMenu.Item item = (FilterMenu.Item) getChildAt(i).getTag();
item.setX((int) coords[0] - item.getView().getMeasuredWidth() / 2);
item.setY((int) coords[1] - item.getView().getMeasuredHeight() / 2);
}
}
|
[
"private",
"void",
"calculateMenuItemPosition",
"(",
")",
"{",
"float",
"itemRadius",
"=",
"(",
"expandedRadius",
"+",
"collapsedRadius",
")",
"/",
"2",
",",
"f",
";",
"RectF",
"area",
"=",
"new",
"RectF",
"(",
"center",
".",
"x",
"-",
"itemRadius",
",",
"center",
".",
"y",
"-",
"itemRadius",
",",
"center",
".",
"x",
"+",
"itemRadius",
",",
"center",
".",
"y",
"+",
"itemRadius",
")",
";",
"Path",
"path",
"=",
"new",
"Path",
"(",
")",
";",
"path",
".",
"addArc",
"(",
"area",
",",
"(",
"float",
")",
"fromAngle",
",",
"(",
"float",
")",
"(",
"toAngle",
"-",
"fromAngle",
")",
")",
";",
"PathMeasure",
"measure",
"=",
"new",
"PathMeasure",
"(",
"path",
",",
"false",
")",
";",
"float",
"len",
"=",
"measure",
".",
"getLength",
"(",
")",
";",
"int",
"divisor",
"=",
"getChildCount",
"(",
")",
";",
"float",
"divider",
"=",
"len",
"/",
"divisor",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getChildCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"float",
"[",
"]",
"coords",
"=",
"new",
"float",
"[",
"2",
"]",
";",
"measure",
".",
"getPosTan",
"(",
"i",
"*",
"divider",
"+",
"divider",
"*",
".5f",
",",
"coords",
",",
"null",
")",
";",
"FilterMenu",
".",
"Item",
"item",
"=",
"(",
"FilterMenu",
".",
"Item",
")",
"getChildAt",
"(",
"i",
")",
".",
"getTag",
"(",
")",
";",
"item",
".",
"setX",
"(",
"(",
"int",
")",
"coords",
"[",
"0",
"]",
"-",
"item",
".",
"getView",
"(",
")",
".",
"getMeasuredWidth",
"(",
")",
"/",
"2",
")",
";",
"item",
".",
"setY",
"(",
"(",
"int",
")",
"coords",
"[",
"1",
"]",
"-",
"item",
".",
"getView",
"(",
")",
".",
"getMeasuredHeight",
"(",
")",
"/",
"2",
")",
";",
"}",
"}"
] |
calculate and set position to menu items
|
[
"calculate",
"and",
"set",
"position",
"to",
"menu",
"items"
] |
5a6e5472631c2304b71a51034683f38271962ef5
|
https://github.com/linroid/FilterMenu/blob/5a6e5472631c2304b71a51034683f38271962ef5/library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java#L611-L633
|
160,391 |
linroid/FilterMenu
|
library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java
|
FilterMenuLayout.isClockwise
|
private boolean isClockwise(Point center, Point a, Point b) {
double cross = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y);
return cross > 0;
}
|
java
|
private boolean isClockwise(Point center, Point a, Point b) {
double cross = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y);
return cross > 0;
}
|
[
"private",
"boolean",
"isClockwise",
"(",
"Point",
"center",
",",
"Point",
"a",
",",
"Point",
"b",
")",
"{",
"double",
"cross",
"=",
"(",
"a",
".",
"x",
"-",
"center",
".",
"x",
")",
"*",
"(",
"b",
".",
"y",
"-",
"center",
".",
"y",
")",
"-",
"(",
"b",
".",
"x",
"-",
"center",
".",
"x",
")",
"*",
"(",
"a",
".",
"y",
"-",
"center",
".",
"y",
")",
";",
"return",
"cross",
">",
"0",
";",
"}"
] |
judge a->b is ordered clockwise
@param center
@param a
@param b
@return
|
[
"judge",
"a",
"-",
">",
"b",
"is",
"ordered",
"clockwise"
] |
5a6e5472631c2304b71a51034683f38271962ef5
|
https://github.com/linroid/FilterMenu/blob/5a6e5472631c2304b71a51034683f38271962ef5/library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java#L748-L751
|
160,392 |
crawljax/crawljax
|
core/src/main/java/com/crawljax/forms/FormInput.java
|
FormInput.inputValues
|
public void inputValues(boolean... values) {
for (boolean value : values) {
InputValue inputValue = new InputValue();
inputValue.setChecked(value);
this.inputValues.add(inputValue);
}
}
|
java
|
public void inputValues(boolean... values) {
for (boolean value : values) {
InputValue inputValue = new InputValue();
inputValue.setChecked(value);
this.inputValues.add(inputValue);
}
}
|
[
"public",
"void",
"inputValues",
"(",
"boolean",
"...",
"values",
")",
"{",
"for",
"(",
"boolean",
"value",
":",
"values",
")",
"{",
"InputValue",
"inputValue",
"=",
"new",
"InputValue",
"(",
")",
";",
"inputValue",
".",
"setChecked",
"(",
"value",
")",
";",
"this",
".",
"inputValues",
".",
"add",
"(",
"inputValue",
")",
";",
"}",
"}"
] |
Sets the values of this input field. Only Applicable check-boxes and a radio buttons.
@param values Values to set.
|
[
"Sets",
"the",
"values",
"of",
"this",
"input",
"field",
".",
"Only",
"Applicable",
"check",
"-",
"boxes",
"and",
"a",
"radio",
"buttons",
"."
] |
d339f4f622ca902ccd35322065821e52a62ec543
|
https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/forms/FormInput.java#L141-L148
|
160,393 |
crawljax/crawljax
|
core/src/main/java/com/crawljax/stateabstractions/dom/RTED/LblTree.java
|
LblTree.clearTmpData
|
public void clearTmpData() {
for (Enumeration<?> e = breadthFirstEnumeration(); e.hasMoreElements(); ) {
((LblTree) e.nextElement()).setTmpData(null);
}
}
|
java
|
public void clearTmpData() {
for (Enumeration<?> e = breadthFirstEnumeration(); e.hasMoreElements(); ) {
((LblTree) e.nextElement()).setTmpData(null);
}
}
|
[
"public",
"void",
"clearTmpData",
"(",
")",
"{",
"for",
"(",
"Enumeration",
"<",
"?",
">",
"e",
"=",
"breadthFirstEnumeration",
"(",
")",
";",
"e",
".",
"hasMoreElements",
"(",
")",
";",
")",
"{",
"(",
"(",
"LblTree",
")",
"e",
".",
"nextElement",
"(",
")",
")",
".",
"setTmpData",
"(",
"null",
")",
";",
"}",
"}"
] |
Clear tmpData in subtree rooted in this node.
|
[
"Clear",
"tmpData",
"in",
"subtree",
"rooted",
"in",
"this",
"node",
"."
] |
d339f4f622ca902ccd35322065821e52a62ec543
|
https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/stateabstractions/dom/RTED/LblTree.java#L171-L175
|
160,394 |
crawljax/crawljax
|
core/src/main/java/com/crawljax/util/XPathHelper.java
|
XPathHelper.getXPathExpression
|
public static String getXPathExpression(Node node) {
Object xpathCache = node.getUserData(FULL_XPATH_CACHE);
if (xpathCache != null) {
return xpathCache.toString();
}
Node parent = node.getParentNode();
if ((parent == null) || parent.getNodeName().contains("#document")) {
String xPath = "/" + node.getNodeName() + "[1]";
node.setUserData(FULL_XPATH_CACHE, xPath, null);
return xPath;
}
if (node.hasAttributes() && node.getAttributes().getNamedItem("id") != null) {
String xPath = "//" + node.getNodeName() + "[@id = '"
+ node.getAttributes().getNamedItem("id").getNodeValue() + "']";
node.setUserData(FULL_XPATH_CACHE, xPath, null);
return xPath;
}
StringBuffer buffer = new StringBuffer();
if (parent != node) {
buffer.append(getXPathExpression(parent));
buffer.append("/");
}
buffer.append(node.getNodeName());
List<Node> mySiblings = getSiblings(parent, node);
for (int i = 0; i < mySiblings.size(); i++) {
Node el = mySiblings.get(i);
if (el.equals(node)) {
buffer.append('[').append(Integer.toString(i + 1)).append(']');
// Found so break;
break;
}
}
String xPath = buffer.toString();
node.setUserData(FULL_XPATH_CACHE, xPath, null);
return xPath;
}
|
java
|
public static String getXPathExpression(Node node) {
Object xpathCache = node.getUserData(FULL_XPATH_CACHE);
if (xpathCache != null) {
return xpathCache.toString();
}
Node parent = node.getParentNode();
if ((parent == null) || parent.getNodeName().contains("#document")) {
String xPath = "/" + node.getNodeName() + "[1]";
node.setUserData(FULL_XPATH_CACHE, xPath, null);
return xPath;
}
if (node.hasAttributes() && node.getAttributes().getNamedItem("id") != null) {
String xPath = "//" + node.getNodeName() + "[@id = '"
+ node.getAttributes().getNamedItem("id").getNodeValue() + "']";
node.setUserData(FULL_XPATH_CACHE, xPath, null);
return xPath;
}
StringBuffer buffer = new StringBuffer();
if (parent != node) {
buffer.append(getXPathExpression(parent));
buffer.append("/");
}
buffer.append(node.getNodeName());
List<Node> mySiblings = getSiblings(parent, node);
for (int i = 0; i < mySiblings.size(); i++) {
Node el = mySiblings.get(i);
if (el.equals(node)) {
buffer.append('[').append(Integer.toString(i + 1)).append(']');
// Found so break;
break;
}
}
String xPath = buffer.toString();
node.setUserData(FULL_XPATH_CACHE, xPath, null);
return xPath;
}
|
[
"public",
"static",
"String",
"getXPathExpression",
"(",
"Node",
"node",
")",
"{",
"Object",
"xpathCache",
"=",
"node",
".",
"getUserData",
"(",
"FULL_XPATH_CACHE",
")",
";",
"if",
"(",
"xpathCache",
"!=",
"null",
")",
"{",
"return",
"xpathCache",
".",
"toString",
"(",
")",
";",
"}",
"Node",
"parent",
"=",
"node",
".",
"getParentNode",
"(",
")",
";",
"if",
"(",
"(",
"parent",
"==",
"null",
")",
"||",
"parent",
".",
"getNodeName",
"(",
")",
".",
"contains",
"(",
"\"#document\"",
")",
")",
"{",
"String",
"xPath",
"=",
"\"/\"",
"+",
"node",
".",
"getNodeName",
"(",
")",
"+",
"\"[1]\"",
";",
"node",
".",
"setUserData",
"(",
"FULL_XPATH_CACHE",
",",
"xPath",
",",
"null",
")",
";",
"return",
"xPath",
";",
"}",
"if",
"(",
"node",
".",
"hasAttributes",
"(",
")",
"&&",
"node",
".",
"getAttributes",
"(",
")",
".",
"getNamedItem",
"(",
"\"id\"",
")",
"!=",
"null",
")",
"{",
"String",
"xPath",
"=",
"\"//\"",
"+",
"node",
".",
"getNodeName",
"(",
")",
"+",
"\"[@id = '\"",
"+",
"node",
".",
"getAttributes",
"(",
")",
".",
"getNamedItem",
"(",
"\"id\"",
")",
".",
"getNodeValue",
"(",
")",
"+",
"\"']\"",
";",
"node",
".",
"setUserData",
"(",
"FULL_XPATH_CACHE",
",",
"xPath",
",",
"null",
")",
";",
"return",
"xPath",
";",
"}",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"if",
"(",
"parent",
"!=",
"node",
")",
"{",
"buffer",
".",
"append",
"(",
"getXPathExpression",
"(",
"parent",
")",
")",
";",
"buffer",
".",
"append",
"(",
"\"/\"",
")",
";",
"}",
"buffer",
".",
"append",
"(",
"node",
".",
"getNodeName",
"(",
")",
")",
";",
"List",
"<",
"Node",
">",
"mySiblings",
"=",
"getSiblings",
"(",
"parent",
",",
"node",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mySiblings",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"el",
"=",
"mySiblings",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"el",
".",
"equals",
"(",
"node",
")",
")",
"{",
"buffer",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"Integer",
".",
"toString",
"(",
"i",
"+",
"1",
")",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"// Found so break;",
"break",
";",
"}",
"}",
"String",
"xPath",
"=",
"buffer",
".",
"toString",
"(",
")",
";",
"node",
".",
"setUserData",
"(",
"FULL_XPATH_CACHE",
",",
"xPath",
",",
"null",
")",
";",
"return",
"xPath",
";",
"}"
] |
Reverse Engineers an XPath Expression of a given Node in the DOM.
@param node the given node.
@return string xpath expression (e.g., "/html[1]/body[1]/div[3]").
|
[
"Reverse",
"Engineers",
"an",
"XPath",
"Expression",
"of",
"a",
"given",
"Node",
"in",
"the",
"DOM",
"."
] |
d339f4f622ca902ccd35322065821e52a62ec543
|
https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/util/XPathHelper.java#L38-L81
|
160,395 |
crawljax/crawljax
|
core/src/main/java/com/crawljax/util/XPathHelper.java
|
XPathHelper.getSiblings
|
public static List<Node> getSiblings(Node parent, Node element) {
List<Node> result = new ArrayList<>();
NodeList list = parent.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node el = list.item(i);
if (el.getNodeName().equals(element.getNodeName())) {
result.add(el);
}
}
return result;
}
|
java
|
public static List<Node> getSiblings(Node parent, Node element) {
List<Node> result = new ArrayList<>();
NodeList list = parent.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node el = list.item(i);
if (el.getNodeName().equals(element.getNodeName())) {
result.add(el);
}
}
return result;
}
|
[
"public",
"static",
"List",
"<",
"Node",
">",
"getSiblings",
"(",
"Node",
"parent",
",",
"Node",
"element",
")",
"{",
"List",
"<",
"Node",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"NodeList",
"list",
"=",
"parent",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"el",
"=",
"list",
".",
"item",
"(",
"i",
")",
";",
"if",
"(",
"el",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"element",
".",
"getNodeName",
"(",
")",
")",
")",
"{",
"result",
".",
"add",
"(",
"el",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Get siblings of the same type as element from parent.
@param parent parent node.
@param element element.
@return List of sibling (from element) under parent
|
[
"Get",
"siblings",
"of",
"the",
"same",
"type",
"as",
"element",
"from",
"parent",
"."
] |
d339f4f622ca902ccd35322065821e52a62ec543
|
https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/util/XPathHelper.java#L90-L103
|
160,396 |
crawljax/crawljax
|
core/src/main/java/com/crawljax/util/XPathHelper.java
|
XPathHelper.evaluateXpathExpression
|
public static NodeList evaluateXpathExpression(String domStr, String xpathExpr)
throws XPathExpressionException, IOException {
Document dom = DomUtils.asDocument(domStr);
return evaluateXpathExpression(dom, xpathExpr);
}
|
java
|
public static NodeList evaluateXpathExpression(String domStr, String xpathExpr)
throws XPathExpressionException, IOException {
Document dom = DomUtils.asDocument(domStr);
return evaluateXpathExpression(dom, xpathExpr);
}
|
[
"public",
"static",
"NodeList",
"evaluateXpathExpression",
"(",
"String",
"domStr",
",",
"String",
"xpathExpr",
")",
"throws",
"XPathExpressionException",
",",
"IOException",
"{",
"Document",
"dom",
"=",
"DomUtils",
".",
"asDocument",
"(",
"domStr",
")",
";",
"return",
"evaluateXpathExpression",
"(",
"dom",
",",
"xpathExpr",
")",
";",
"}"
] |
Returns the list of nodes which match the expression xpathExpr in the String domStr.
@return the list of nodes which match the query
@throws XPathExpressionException
@throws IOException
|
[
"Returns",
"the",
"list",
"of",
"nodes",
"which",
"match",
"the",
"expression",
"xpathExpr",
"in",
"the",
"String",
"domStr",
"."
] |
d339f4f622ca902ccd35322065821e52a62ec543
|
https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/util/XPathHelper.java#L112-L116
|
160,397 |
crawljax/crawljax
|
core/src/main/java/com/crawljax/util/XPathHelper.java
|
XPathHelper.evaluateXpathExpression
|
public static NodeList evaluateXpathExpression(Document dom, String xpathExpr)
throws XPathExpressionException {
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
XPathExpression expr = xpath.compile(xpathExpr);
Object result = expr.evaluate(dom, XPathConstants.NODESET);
return (NodeList) result;
}
|
java
|
public static NodeList evaluateXpathExpression(Document dom, String xpathExpr)
throws XPathExpressionException {
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
XPathExpression expr = xpath.compile(xpathExpr);
Object result = expr.evaluate(dom, XPathConstants.NODESET);
return (NodeList) result;
}
|
[
"public",
"static",
"NodeList",
"evaluateXpathExpression",
"(",
"Document",
"dom",
",",
"String",
"xpathExpr",
")",
"throws",
"XPathExpressionException",
"{",
"XPathFactory",
"factory",
"=",
"XPathFactory",
".",
"newInstance",
"(",
")",
";",
"XPath",
"xpath",
"=",
"factory",
".",
"newXPath",
"(",
")",
";",
"XPathExpression",
"expr",
"=",
"xpath",
".",
"compile",
"(",
"xpathExpr",
")",
";",
"Object",
"result",
"=",
"expr",
".",
"evaluate",
"(",
"dom",
",",
"XPathConstants",
".",
"NODESET",
")",
";",
"return",
"(",
"NodeList",
")",
"result",
";",
"}"
] |
Returns the list of nodes which match the expression xpathExpr in the Document dom.
@param dom the Document to search in
@param xpathExpr the xpath query
@return the list of nodes which match the query
@throws XPathExpressionException On error.
|
[
"Returns",
"the",
"list",
"of",
"nodes",
"which",
"match",
"the",
"expression",
"xpathExpr",
"in",
"the",
"Document",
"dom",
"."
] |
d339f4f622ca902ccd35322065821e52a62ec543
|
https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/util/XPathHelper.java#L126-L133
|
160,398 |
crawljax/crawljax
|
core/src/main/java/com/crawljax/util/XPathHelper.java
|
XPathHelper.getXPathLocation
|
public static int getXPathLocation(String dom, String xpath) {
String dom_lower = dom.toLowerCase();
String xpath_lower = xpath.toLowerCase();
String[] elements = xpath_lower.split("/");
int pos = 0;
int temp;
int number;
for (String element : elements) {
if (!element.isEmpty() && !element.startsWith("@") && !element.contains("()")) {
if (element.contains("[")) {
try {
number =
Integer.parseInt(element.substring(element.indexOf("[") + 1,
element.indexOf("]")));
} catch (NumberFormatException e) {
return -1;
}
} else {
number = 1;
}
for (int i = 0; i < number; i++) {
// find new open element
temp = dom_lower.indexOf("<" + stripEndSquareBrackets(element), pos);
if (temp > -1) {
pos = temp + 1;
// if depth>1 then goto end of current element
if (number > 1 && i < number - 1) {
pos =
getCloseElementLocation(dom_lower, pos,
stripEndSquareBrackets(element));
}
}
}
}
}
return pos - 1;
}
|
java
|
public static int getXPathLocation(String dom, String xpath) {
String dom_lower = dom.toLowerCase();
String xpath_lower = xpath.toLowerCase();
String[] elements = xpath_lower.split("/");
int pos = 0;
int temp;
int number;
for (String element : elements) {
if (!element.isEmpty() && !element.startsWith("@") && !element.contains("()")) {
if (element.contains("[")) {
try {
number =
Integer.parseInt(element.substring(element.indexOf("[") + 1,
element.indexOf("]")));
} catch (NumberFormatException e) {
return -1;
}
} else {
number = 1;
}
for (int i = 0; i < number; i++) {
// find new open element
temp = dom_lower.indexOf("<" + stripEndSquareBrackets(element), pos);
if (temp > -1) {
pos = temp + 1;
// if depth>1 then goto end of current element
if (number > 1 && i < number - 1) {
pos =
getCloseElementLocation(dom_lower, pos,
stripEndSquareBrackets(element));
}
}
}
}
}
return pos - 1;
}
|
[
"public",
"static",
"int",
"getXPathLocation",
"(",
"String",
"dom",
",",
"String",
"xpath",
")",
"{",
"String",
"dom_lower",
"=",
"dom",
".",
"toLowerCase",
"(",
")",
";",
"String",
"xpath_lower",
"=",
"xpath",
".",
"toLowerCase",
"(",
")",
";",
"String",
"[",
"]",
"elements",
"=",
"xpath_lower",
".",
"split",
"(",
"\"/\"",
")",
";",
"int",
"pos",
"=",
"0",
";",
"int",
"temp",
";",
"int",
"number",
";",
"for",
"(",
"String",
"element",
":",
"elements",
")",
"{",
"if",
"(",
"!",
"element",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"element",
".",
"startsWith",
"(",
"\"@\"",
")",
"&&",
"!",
"element",
".",
"contains",
"(",
"\"()\"",
")",
")",
"{",
"if",
"(",
"element",
".",
"contains",
"(",
"\"[\"",
")",
")",
"{",
"try",
"{",
"number",
"=",
"Integer",
".",
"parseInt",
"(",
"element",
".",
"substring",
"(",
"element",
".",
"indexOf",
"(",
"\"[\"",
")",
"+",
"1",
",",
"element",
".",
"indexOf",
"(",
"\"]\"",
")",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"return",
"-",
"1",
";",
"}",
"}",
"else",
"{",
"number",
"=",
"1",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"number",
";",
"i",
"++",
")",
"{",
"// find new open element",
"temp",
"=",
"dom_lower",
".",
"indexOf",
"(",
"\"<\"",
"+",
"stripEndSquareBrackets",
"(",
"element",
")",
",",
"pos",
")",
";",
"if",
"(",
"temp",
">",
"-",
"1",
")",
"{",
"pos",
"=",
"temp",
"+",
"1",
";",
"// if depth>1 then goto end of current element",
"if",
"(",
"number",
">",
"1",
"&&",
"i",
"<",
"number",
"-",
"1",
")",
"{",
"pos",
"=",
"getCloseElementLocation",
"(",
"dom_lower",
",",
"pos",
",",
"stripEndSquareBrackets",
"(",
"element",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"pos",
"-",
"1",
";",
"}"
] |
returns position of xpath element which match the expression xpath in the String dom.
@param dom the Document to search in
@param xpath the xpath query
@return position of xpath element, if fails returns -1
|
[
"returns",
"position",
"of",
"xpath",
"element",
"which",
"match",
"the",
"expression",
"xpath",
"in",
"the",
"String",
"dom",
"."
] |
d339f4f622ca902ccd35322065821e52a62ec543
|
https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/util/XPathHelper.java#L223-L262
|
160,399 |
crawljax/crawljax
|
core/src/main/java/com/crawljax/oraclecomparator/comparators/EditDistanceComparator.java
|
EditDistanceComparator.getThreshold
|
double getThreshold(String x, String y, double p) {
return 2 * Math.max(x.length(), y.length()) * (1 - p);
}
|
java
|
double getThreshold(String x, String y, double p) {
return 2 * Math.max(x.length(), y.length()) * (1 - p);
}
|
[
"double",
"getThreshold",
"(",
"String",
"x",
",",
"String",
"y",
",",
"double",
"p",
")",
"{",
"return",
"2",
"*",
"Math",
".",
"max",
"(",
"x",
".",
"length",
"(",
")",
",",
"y",
".",
"length",
"(",
")",
")",
"*",
"(",
"1",
"-",
"p",
")",
";",
"}"
] |
Calculate a threshold.
@param x first string.
@param y second string.
@param p the threshold coefficient.
@return 2 maxLength(x, y) (1-p)
|
[
"Calculate",
"a",
"threshold",
"."
] |
d339f4f622ca902ccd35322065821e52a62ec543
|
https://github.com/crawljax/crawljax/blob/d339f4f622ca902ccd35322065821e52a62ec543/core/src/main/java/com/crawljax/oraclecomparator/comparators/EditDistanceComparator.java#L73-L75
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.