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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/AnnotatedMethodScanner.java | AnnotatedMethodScanner.findAnnotatedMethods | public Set<Method> findAnnotatedMethods(String scanBase, Class<? extends Annotation> annotationClass) {
Set<BeanDefinition> filteredComponents = findCandidateBeans(scanBase, annotationClass);
return extractAnnotatedMethods(filteredComponents, annotationClass);
} | java | public Set<Method> findAnnotatedMethods(String scanBase, Class<? extends Annotation> annotationClass) {
Set<BeanDefinition> filteredComponents = findCandidateBeans(scanBase, annotationClass);
return extractAnnotatedMethods(filteredComponents, annotationClass);
} | [
"public",
"Set",
"<",
"Method",
">",
"findAnnotatedMethods",
"(",
"String",
"scanBase",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
")",
"{",
"Set",
"<",
"BeanDefinition",
">",
"filteredComponents",
"=",
"findCandidateBeans",
"(",
"s... | Find all methods on classes under scanBase that are annotated with annotationClass.
@param scanBase Package to scan recursively, in dot notation (ie: org.jrugged...)
@param annotationClass Class of the annotation to search for
@return Set<Method> The set of all @{java.lang.reflect.Method}s having the annotation | [
"Find",
"all",
"methods",
"on",
"classes",
"under",
"scanBase",
"that",
"are",
"annotated",
"with",
"annotationClass",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/AnnotatedMethodScanner.java#L48-L51 | train |
Comcast/jrugged | jrugged-core/src/main/java/org/fishwife/jrugged/CircuitBreaker.java | CircuitBreaker.reset | public void reset() {
state = BreakerState.CLOSED;
isHardTrip = false;
byPass = false;
isAttemptLive = false;
notifyBreakerStateChange(getStatus());
} | java | public void reset() {
state = BreakerState.CLOSED;
isHardTrip = false;
byPass = false;
isAttemptLive = false;
notifyBreakerStateChange(getStatus());
} | [
"public",
"void",
"reset",
"(",
")",
"{",
"state",
"=",
"BreakerState",
".",
"CLOSED",
";",
"isHardTrip",
"=",
"false",
";",
"byPass",
"=",
"false",
";",
"isAttemptLive",
"=",
"false",
";",
"notifyBreakerStateChange",
"(",
"getStatus",
"(",
")",
")",
";",
... | Manually set the breaker to be reset and ready for use. This
is only useful after a manual trip otherwise the breaker will
trip automatically again if the service is still unavailable.
Just like a real breaker. WOOT!!! | [
"Manually",
"set",
"the",
"breaker",
"to",
"be",
"reset",
"and",
"ready",
"for",
"use",
".",
"This",
"is",
"only",
"useful",
"after",
"a",
"manual",
"trip",
"otherwise",
"the",
"breaker",
"will",
"trip",
"automatically",
"again",
"if",
"the",
"service",
"i... | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-core/src/main/java/org/fishwife/jrugged/CircuitBreaker.java#L403-L410 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanServerAdapter.java | WebMBeanServerAdapter.createWebMBeanAdapter | public WebMBeanAdapter createWebMBeanAdapter(String mBeanName, String encoding)
throws JMException, UnsupportedEncodingException {
return new WebMBeanAdapter(mBeanServer, mBeanName, encoding);
} | java | public WebMBeanAdapter createWebMBeanAdapter(String mBeanName, String encoding)
throws JMException, UnsupportedEncodingException {
return new WebMBeanAdapter(mBeanServer, mBeanName, encoding);
} | [
"public",
"WebMBeanAdapter",
"createWebMBeanAdapter",
"(",
"String",
"mBeanName",
",",
"String",
"encoding",
")",
"throws",
"JMException",
",",
"UnsupportedEncodingException",
"{",
"return",
"new",
"WebMBeanAdapter",
"(",
"mBeanServer",
",",
"mBeanName",
",",
"encoding"... | Create a WebMBeanAdaptor for a specified MBean name.
@param mBeanName the MBean name (can be URL-encoded).
@param encoding the string encoding to be used (i.e. UTF-8)
@return the created WebMBeanAdaptor.
@throws JMException Java Management Exception
@throws UnsupportedEncodingException if the encoding is not supported. | [
"Create",
"a",
"WebMBeanAdaptor",
"for",
"a",
"specified",
"MBean",
"name",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanServerAdapter.java#L71-L74 | train |
Comcast/jrugged | jrugged-core/src/main/java/org/fishwife/jrugged/WindowedEventCounter.java | WindowedEventCounter.mark | public void mark() {
final long currentTimeMillis = clock.currentTimeMillis();
synchronized (queue) {
if (queue.size() == capacity) {
/*
* we're all filled up already, let's dequeue the oldest
* timestamp to make room for this new one.
*/
queue.removeFirst();
}
queue.addLast(currentTimeMillis);
}
} | java | public void mark() {
final long currentTimeMillis = clock.currentTimeMillis();
synchronized (queue) {
if (queue.size() == capacity) {
/*
* we're all filled up already, let's dequeue the oldest
* timestamp to make room for this new one.
*/
queue.removeFirst();
}
queue.addLast(currentTimeMillis);
}
} | [
"public",
"void",
"mark",
"(",
")",
"{",
"final",
"long",
"currentTimeMillis",
"=",
"clock",
".",
"currentTimeMillis",
"(",
")",
";",
"synchronized",
"(",
"queue",
")",
"{",
"if",
"(",
"queue",
".",
"size",
"(",
")",
"==",
"capacity",
")",
"{",
"/*\n ... | Record a new event. | [
"Record",
"a",
"new",
"event",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-core/src/main/java/org/fishwife/jrugged/WindowedEventCounter.java#L75-L88 | train |
Comcast/jrugged | jrugged-core/src/main/java/org/fishwife/jrugged/WindowedEventCounter.java | WindowedEventCounter.tally | public int tally() {
long currentTimeMillis = clock.currentTimeMillis();
// calculates time for which we remove any errors before
final long removeTimesBeforeMillis = currentTimeMillis - windowMillis;
synchronized (queue) {
// drain out any expired timestamps but don't drain past empty
while (!queue.isEmpty() && queue.peek() < removeTimesBeforeMillis) {
queue.removeFirst();
}
return queue.size();
}
} | java | public int tally() {
long currentTimeMillis = clock.currentTimeMillis();
// calculates time for which we remove any errors before
final long removeTimesBeforeMillis = currentTimeMillis - windowMillis;
synchronized (queue) {
// drain out any expired timestamps but don't drain past empty
while (!queue.isEmpty() && queue.peek() < removeTimesBeforeMillis) {
queue.removeFirst();
}
return queue.size();
}
} | [
"public",
"int",
"tally",
"(",
")",
"{",
"long",
"currentTimeMillis",
"=",
"clock",
".",
"currentTimeMillis",
"(",
")",
";",
"// calculates time for which we remove any errors before",
"final",
"long",
"removeTimesBeforeMillis",
"=",
"currentTimeMillis",
"-",
"windowMilli... | Returns a count of in-window events.
@return the the count of in-window events. | [
"Returns",
"a",
"count",
"of",
"in",
"-",
"window",
"events",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-core/src/main/java/org/fishwife/jrugged/WindowedEventCounter.java#L95-L108 | train |
Comcast/jrugged | jrugged-core/src/main/java/org/fishwife/jrugged/WindowedEventCounter.java | WindowedEventCounter.setCapacity | public void setCapacity(int capacity) {
if (capacity <= 0) {
throw new IllegalArgumentException("capacity must be greater than 0");
}
synchronized (queue) {
// If the capacity was reduced, we remove oldest elements until the
// queue fits inside the specified capacity
if (capacity < this.capacity) {
while (queue.size() > capacity) {
queue.removeFirst();
}
}
}
this.capacity = capacity;
} | java | public void setCapacity(int capacity) {
if (capacity <= 0) {
throw new IllegalArgumentException("capacity must be greater than 0");
}
synchronized (queue) {
// If the capacity was reduced, we remove oldest elements until the
// queue fits inside the specified capacity
if (capacity < this.capacity) {
while (queue.size() > capacity) {
queue.removeFirst();
}
}
}
this.capacity = capacity;
} | [
"public",
"void",
"setCapacity",
"(",
"int",
"capacity",
")",
"{",
"if",
"(",
"capacity",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"capacity must be greater than 0\"",
")",
";",
"}",
"synchronized",
"(",
"queue",
")",
"{",
"// If... | Specifies the maximum capacity of the counter.
@param capacity
<code>long</code>
@throws IllegalArgumentException
if windowMillis is less than 1. | [
"Specifies",
"the",
"maximum",
"capacity",
"of",
"the",
"counter",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-core/src/main/java/org/fishwife/jrugged/WindowedEventCounter.java#L128-L144 | train |
Comcast/jrugged | jrugged-aspects/src/main/java/org/fishwife/jrugged/aspects/RetryableAspect.java | RetryableAspect.call | @Around("@annotation(retryableAnnotation)")
public Object call(final ProceedingJoinPoint pjp, Retryable retryableAnnotation) throws Throwable {
final int maxTries = retryableAnnotation.maxTries();
final int retryDelayMillies = retryableAnnotation.retryDelayMillis();
final Class<? extends Throwable>[] retryOn = retryableAnnotation.retryOn();
final boolean doubleDelay = retryableAnnotation.doubleDelay();
final boolean throwCauseException = retryableAnnotation.throwCauseException();
if (logger.isDebugEnabled()) {
logger.debug("Have @Retryable method wrapping call on method {} of target object {}",
new Object[] {
pjp.getSignature().getName(),
pjp.getTarget()
});
}
ServiceRetrier serviceRetrier =
new ServiceRetrier(retryDelayMillies, maxTries, doubleDelay, throwCauseException, retryOn);
return serviceRetrier.invoke(
new Callable<Object>() {
public Object call() throws Exception {
try {
return pjp.proceed();
}
catch (Exception e) {
throw e;
}
catch (Error e) {
throw e;
}
catch (Throwable t) {
throw new RuntimeException(t);
}
}
}
);
} | java | @Around("@annotation(retryableAnnotation)")
public Object call(final ProceedingJoinPoint pjp, Retryable retryableAnnotation) throws Throwable {
final int maxTries = retryableAnnotation.maxTries();
final int retryDelayMillies = retryableAnnotation.retryDelayMillis();
final Class<? extends Throwable>[] retryOn = retryableAnnotation.retryOn();
final boolean doubleDelay = retryableAnnotation.doubleDelay();
final boolean throwCauseException = retryableAnnotation.throwCauseException();
if (logger.isDebugEnabled()) {
logger.debug("Have @Retryable method wrapping call on method {} of target object {}",
new Object[] {
pjp.getSignature().getName(),
pjp.getTarget()
});
}
ServiceRetrier serviceRetrier =
new ServiceRetrier(retryDelayMillies, maxTries, doubleDelay, throwCauseException, retryOn);
return serviceRetrier.invoke(
new Callable<Object>() {
public Object call() throws Exception {
try {
return pjp.proceed();
}
catch (Exception e) {
throw e;
}
catch (Error e) {
throw e;
}
catch (Throwable t) {
throw new RuntimeException(t);
}
}
}
);
} | [
"@",
"Around",
"(",
"\"@annotation(retryableAnnotation)\"",
")",
"public",
"Object",
"call",
"(",
"final",
"ProceedingJoinPoint",
"pjp",
",",
"Retryable",
"retryableAnnotation",
")",
"throws",
"Throwable",
"{",
"final",
"int",
"maxTries",
"=",
"retryableAnnotation",
"... | Runs a method call with retries.
@param pjp a {@link ProceedingJoinPoint} representing an annotated
method call.
@param retryableAnnotation the {@link org.fishwife.jrugged.aspects.Retryable}
annotation that wrapped the method.
@throws Throwable if the method invocation itself throws one during execution.
@return The return value from the method call. | [
"Runs",
"a",
"method",
"call",
"with",
"retries",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-aspects/src/main/java/org/fishwife/jrugged/aspects/RetryableAspect.java#L49-L86 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java | WebMBeanAdapter.getAttributeMetadata | public Map<String, MBeanAttributeInfo> getAttributeMetadata() {
MBeanAttributeInfo[] attributeList = mBeanInfo.getAttributes();
Map<String, MBeanAttributeInfo> attributeMap = new TreeMap<String, MBeanAttributeInfo>();
for (MBeanAttributeInfo attribute: attributeList) {
attributeMap.put(attribute.getName(), attribute);
}
return attributeMap;
} | java | public Map<String, MBeanAttributeInfo> getAttributeMetadata() {
MBeanAttributeInfo[] attributeList = mBeanInfo.getAttributes();
Map<String, MBeanAttributeInfo> attributeMap = new TreeMap<String, MBeanAttributeInfo>();
for (MBeanAttributeInfo attribute: attributeList) {
attributeMap.put(attribute.getName(), attribute);
}
return attributeMap;
} | [
"public",
"Map",
"<",
"String",
",",
"MBeanAttributeInfo",
">",
"getAttributeMetadata",
"(",
")",
"{",
"MBeanAttributeInfo",
"[",
"]",
"attributeList",
"=",
"mBeanInfo",
".",
"getAttributes",
"(",
")",
";",
"Map",
"<",
"String",
",",
"MBeanAttributeInfo",
">",
... | Get the Attribute metadata for an MBean by name.
@return the {@link Map} of {@link String} attribute names to {@link MBeanAttributeInfo} values. | [
"Get",
"the",
"Attribute",
"metadata",
"for",
"an",
"MBean",
"by",
"name",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java#L73-L82 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java | WebMBeanAdapter.getOperationMetadata | public Map<String, MBeanOperationInfo> getOperationMetadata() {
MBeanOperationInfo[] operations = mBeanInfo.getOperations();
Map<String, MBeanOperationInfo> operationMap = new TreeMap<String, MBeanOperationInfo>();
for (MBeanOperationInfo operation: operations) {
operationMap.put(operation.getName(), operation);
}
return operationMap;
} | java | public Map<String, MBeanOperationInfo> getOperationMetadata() {
MBeanOperationInfo[] operations = mBeanInfo.getOperations();
Map<String, MBeanOperationInfo> operationMap = new TreeMap<String, MBeanOperationInfo>();
for (MBeanOperationInfo operation: operations) {
operationMap.put(operation.getName(), operation);
}
return operationMap;
} | [
"public",
"Map",
"<",
"String",
",",
"MBeanOperationInfo",
">",
"getOperationMetadata",
"(",
")",
"{",
"MBeanOperationInfo",
"[",
"]",
"operations",
"=",
"mBeanInfo",
".",
"getOperations",
"(",
")",
";",
"Map",
"<",
"String",
",",
"MBeanOperationInfo",
">",
"o... | Get the Operation metadata for an MBean by name.
@return the {@link Map} of {@link String} operation names to {@link MBeanOperationInfo} values. | [
"Get",
"the",
"Operation",
"metadata",
"for",
"an",
"MBean",
"by",
"name",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java#L88-L97 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java | WebMBeanAdapter.getOperationInfo | public MBeanOperationInfo getOperationInfo(String operationName)
throws OperationNotFoundException, UnsupportedEncodingException {
String decodedOperationName = sanitizer.urlDecode(operationName, encoding);
Map<String, MBeanOperationInfo> operationMap = getOperationMetadata();
if (operationMap.containsKey(decodedOperationName)) {
return operationMap.get(decodedOperationName);
}
throw new OperationNotFoundException("Could not find operation " + operationName + " on MBean " +
objectName.getCanonicalName());
} | java | public MBeanOperationInfo getOperationInfo(String operationName)
throws OperationNotFoundException, UnsupportedEncodingException {
String decodedOperationName = sanitizer.urlDecode(operationName, encoding);
Map<String, MBeanOperationInfo> operationMap = getOperationMetadata();
if (operationMap.containsKey(decodedOperationName)) {
return operationMap.get(decodedOperationName);
}
throw new OperationNotFoundException("Could not find operation " + operationName + " on MBean " +
objectName.getCanonicalName());
} | [
"public",
"MBeanOperationInfo",
"getOperationInfo",
"(",
"String",
"operationName",
")",
"throws",
"OperationNotFoundException",
",",
"UnsupportedEncodingException",
"{",
"String",
"decodedOperationName",
"=",
"sanitizer",
".",
"urlDecode",
"(",
"operationName",
",",
"encod... | Get the Operation metadata for a single operation on an MBean by name.
@param operationName the Operation name (can be URL-encoded).
@return the {@link MBeanOperationInfo} for the operation.
@throws OperationNotFoundException Method was not found
@throws UnsupportedEncodingException if the encoding is not supported. | [
"Get",
"the",
"Operation",
"metadata",
"for",
"a",
"single",
"operation",
"on",
"an",
"MBean",
"by",
"name",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java#L106-L116 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java | WebMBeanAdapter.getAttributeValues | public Map<String,Object> getAttributeValues()
throws AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
HashSet<String> attributeSet = new HashSet<String>();
for (MBeanAttributeInfo attributeInfo : mBeanInfo.getAttributes()) {
attributeSet.add(attributeInfo.getName());
}
AttributeList attributeList =
mBeanServer.getAttributes(objectName, attributeSet.toArray(new String[attributeSet.size()]));
Map<String, Object> attributeValueMap = new TreeMap<String, Object>();
for (Attribute attribute : attributeList.asList()) {
attributeValueMap.put(attribute.getName(), sanitizer.escapeValue(attribute.getValue()));
}
return attributeValueMap;
} | java | public Map<String,Object> getAttributeValues()
throws AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
HashSet<String> attributeSet = new HashSet<String>();
for (MBeanAttributeInfo attributeInfo : mBeanInfo.getAttributes()) {
attributeSet.add(attributeInfo.getName());
}
AttributeList attributeList =
mBeanServer.getAttributes(objectName, attributeSet.toArray(new String[attributeSet.size()]));
Map<String, Object> attributeValueMap = new TreeMap<String, Object>();
for (Attribute attribute : attributeList.asList()) {
attributeValueMap.put(attribute.getName(), sanitizer.escapeValue(attribute.getValue()));
}
return attributeValueMap;
} | [
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"getAttributeValues",
"(",
")",
"throws",
"AttributeNotFoundException",
",",
"InstanceNotFoundException",
",",
"ReflectionException",
"{",
"HashSet",
"<",
"String",
">",
"attributeSet",
"=",
"new",
"HashSet",
"<",
... | Get all the attribute values for an MBean by name. The values are HTML escaped.
@return the {@link Map} of attribute names and values.
@throws javax.management.AttributeNotFoundException Unable to find the 'attribute'
@throws InstanceNotFoundException unable to find the specific bean
@throws ReflectionException unable to interrogate the bean | [
"Get",
"all",
"the",
"attribute",
"values",
"for",
"an",
"MBean",
"by",
"name",
".",
"The",
"values",
"are",
"HTML",
"escaped",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java#L125-L143 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java | WebMBeanAdapter.getAttributeValue | public String getAttributeValue(String attributeName)
throws JMException, UnsupportedEncodingException {
String decodedAttributeName = sanitizer.urlDecode(attributeName, encoding);
return sanitizer.escapeValue(mBeanServer.getAttribute(objectName, decodedAttributeName));
} | java | public String getAttributeValue(String attributeName)
throws JMException, UnsupportedEncodingException {
String decodedAttributeName = sanitizer.urlDecode(attributeName, encoding);
return sanitizer.escapeValue(mBeanServer.getAttribute(objectName, decodedAttributeName));
} | [
"public",
"String",
"getAttributeValue",
"(",
"String",
"attributeName",
")",
"throws",
"JMException",
",",
"UnsupportedEncodingException",
"{",
"String",
"decodedAttributeName",
"=",
"sanitizer",
".",
"urlDecode",
"(",
"attributeName",
",",
"encoding",
")",
";",
"ret... | Get the value for a single attribute on an MBean by name.
@param attributeName the attribute name (can be URL-encoded).
@return the value as a String.
@throws JMException Java Management Exception
@throws UnsupportedEncodingException if the encoding is not supported. | [
"Get",
"the",
"value",
"for",
"a",
"single",
"attribute",
"on",
"an",
"MBean",
"by",
"name",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java#L152-L156 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java | WebMBeanAdapter.invokeOperation | public String invokeOperation(String operationName, Map<String, String[]> parameterMap)
throws JMException, UnsupportedEncodingException {
MBeanOperationInfo operationInfo = getOperationInfo(operationName);
MBeanOperationInvoker invoker = createMBeanOperationInvoker(mBeanServer, objectName, operationInfo);
return sanitizer.escapeValue(invoker.invokeOperation(parameterMap));
} | java | public String invokeOperation(String operationName, Map<String, String[]> parameterMap)
throws JMException, UnsupportedEncodingException {
MBeanOperationInfo operationInfo = getOperationInfo(operationName);
MBeanOperationInvoker invoker = createMBeanOperationInvoker(mBeanServer, objectName, operationInfo);
return sanitizer.escapeValue(invoker.invokeOperation(parameterMap));
} | [
"public",
"String",
"invokeOperation",
"(",
"String",
"operationName",
",",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"parameterMap",
")",
"throws",
"JMException",
",",
"UnsupportedEncodingException",
"{",
"MBeanOperationInfo",
"operationInfo",
"=",
"getOp... | Invoke an operation on an MBean by name.
Note that only basic data types are supported for parameter values.
@param operationName the operation name (can be URL-encoded).
@param parameterMap the {@link Map} of parameter names and value arrays.
@return the returned value from the operation.
@throws JMException Java Management Exception
@throws UnsupportedEncodingException if the encoding is not supported. | [
"Invoke",
"an",
"operation",
"on",
"an",
"MBean",
"by",
"name",
".",
"Note",
"that",
"only",
"basic",
"data",
"types",
"are",
"supported",
"for",
"parameter",
"values",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/WebMBeanAdapter.java#L167-L172 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/MBeanStringSanitizer.java | MBeanStringSanitizer.urlDecode | String urlDecode(String name, String encoding) throws UnsupportedEncodingException {
return URLDecoder.decode(name, encoding);
} | java | String urlDecode(String name, String encoding) throws UnsupportedEncodingException {
return URLDecoder.decode(name, encoding);
} | [
"String",
"urlDecode",
"(",
"String",
"name",
",",
"String",
"encoding",
")",
"throws",
"UnsupportedEncodingException",
"{",
"return",
"URLDecoder",
".",
"decode",
"(",
"name",
",",
"encoding",
")",
";",
"}"
] | Convert a URL Encoded name back to the original form.
@param name the name to URL urlDecode.
@param encoding the string encoding to be used (i.e. UTF-8)
@return the name in original form.
@throws UnsupportedEncodingException if the encoding is not supported. | [
"Convert",
"a",
"URL",
"Encoded",
"name",
"back",
"to",
"the",
"original",
"form",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/MBeanStringSanitizer.java#L37-L39 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/MBeanStringSanitizer.java | MBeanStringSanitizer.escapeValue | String escapeValue(Object value) {
return HtmlUtils.htmlEscape(value != null ? value.toString() : "<null>");
} | java | String escapeValue(Object value) {
return HtmlUtils.htmlEscape(value != null ? value.toString() : "<null>");
} | [
"String",
"escapeValue",
"(",
"Object",
"value",
")",
"{",
"return",
"HtmlUtils",
".",
"htmlEscape",
"(",
"value",
"!=",
"null",
"?",
"value",
".",
"toString",
"(",
")",
":",
"\"<null>\"",
")",
";",
"}"
] | Escape a value to be HTML friendly.
@param value the Object value.
@return the HTML-escaped String, or <null> if the value is null. | [
"Escape",
"a",
"value",
"to",
"be",
"HTML",
"friendly",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/MBeanStringSanitizer.java#L46-L48 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/config/PerformanceMonitorBeanDefinitionDecorator.java | PerformanceMonitorBeanDefinitionDecorator.registerProxyCreator | private void registerProxyCreator(Node source,
BeanDefinitionHolder holder,
ParserContext context) {
String beanName = holder.getBeanName();
String proxyName = beanName + "Proxy";
String interceptorName = beanName + "PerformanceMonitorInterceptor";
BeanDefinitionBuilder initializer =
BeanDefinitionBuilder.rootBeanDefinition(BeanNameAutoProxyCreator.class);
initializer.addPropertyValue("beanNames", beanName);
initializer.addPropertyValue("interceptorNames", interceptorName);
BeanDefinitionRegistry registry = context.getRegistry();
registry.registerBeanDefinition(proxyName, initializer.getBeanDefinition());
} | java | private void registerProxyCreator(Node source,
BeanDefinitionHolder holder,
ParserContext context) {
String beanName = holder.getBeanName();
String proxyName = beanName + "Proxy";
String interceptorName = beanName + "PerformanceMonitorInterceptor";
BeanDefinitionBuilder initializer =
BeanDefinitionBuilder.rootBeanDefinition(BeanNameAutoProxyCreator.class);
initializer.addPropertyValue("beanNames", beanName);
initializer.addPropertyValue("interceptorNames", interceptorName);
BeanDefinitionRegistry registry = context.getRegistry();
registry.registerBeanDefinition(proxyName, initializer.getBeanDefinition());
} | [
"private",
"void",
"registerProxyCreator",
"(",
"Node",
"source",
",",
"BeanDefinitionHolder",
"holder",
",",
"ParserContext",
"context",
")",
"{",
"String",
"beanName",
"=",
"holder",
".",
"getBeanName",
"(",
")",
";",
"String",
"proxyName",
"=",
"beanName",
"+... | Registers a BeanNameAutoProxyCreator class that wraps the bean being
monitored. The proxy is associated with the PerformanceMonitorInterceptor
for the bean, which is created when parsing the methods attribute from
the springconfiguration xml file.
@param source An Attribute node from the spring configuration
@param holder A container for the beans I will create
@param context the context currently parsing my spring config | [
"Registers",
"a",
"BeanNameAutoProxyCreator",
"class",
"that",
"wraps",
"the",
"bean",
"being",
"monitored",
".",
"The",
"proxy",
"is",
"associated",
"with",
"the",
"PerformanceMonitorInterceptor",
"for",
"the",
"bean",
"which",
"is",
"created",
"when",
"parsing",
... | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/config/PerformanceMonitorBeanDefinitionDecorator.java#L78-L94 | train |
Comcast/jrugged | jrugged-core/src/main/java/org/fishwife/jrugged/CircuitBreakerFactory.java | CircuitBreakerFactory.getIntegerPropertyOverrideValue | private Integer getIntegerPropertyOverrideValue(String name, String key) {
if (properties != null) {
String propertyName = getPropertyName(name, key);
String propertyOverrideValue = properties.getProperty(propertyName);
if (propertyOverrideValue != null) {
try {
return Integer.parseInt(propertyOverrideValue);
}
catch (NumberFormatException e) {
logger.error("Could not parse property override key={}, value={}",
key, propertyOverrideValue);
}
}
}
return null;
} | java | private Integer getIntegerPropertyOverrideValue(String name, String key) {
if (properties != null) {
String propertyName = getPropertyName(name, key);
String propertyOverrideValue = properties.getProperty(propertyName);
if (propertyOverrideValue != null) {
try {
return Integer.parseInt(propertyOverrideValue);
}
catch (NumberFormatException e) {
logger.error("Could not parse property override key={}, value={}",
key, propertyOverrideValue);
}
}
}
return null;
} | [
"private",
"Integer",
"getIntegerPropertyOverrideValue",
"(",
"String",
"name",
",",
"String",
"key",
")",
"{",
"if",
"(",
"properties",
"!=",
"null",
")",
"{",
"String",
"propertyName",
"=",
"getPropertyName",
"(",
"name",
",",
"key",
")",
";",
"String",
"p... | Get an integer property override value.
@param name the {@link CircuitBreaker} name.
@param key the property override key.
@return the property override value, or null if it is not found. | [
"Get",
"an",
"integer",
"property",
"override",
"value",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-core/src/main/java/org/fishwife/jrugged/CircuitBreakerFactory.java#L174-L191 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/config/SingleServiceWrapperInterceptor.java | SingleServiceWrapperInterceptor.shouldWrapMethodCall | private boolean shouldWrapMethodCall(String methodName) {
if (methodList == null) {
return true; // Wrap all by default
}
if (methodList.contains(methodName)) {
return true; //Wrap a specific method
}
// If I get to this point, I should not wrap the call.
return false;
} | java | private boolean shouldWrapMethodCall(String methodName) {
if (methodList == null) {
return true; // Wrap all by default
}
if (methodList.contains(methodName)) {
return true; //Wrap a specific method
}
// If I get to this point, I should not wrap the call.
return false;
} | [
"private",
"boolean",
"shouldWrapMethodCall",
"(",
"String",
"methodName",
")",
"{",
"if",
"(",
"methodList",
"==",
"null",
")",
"{",
"return",
"true",
";",
"// Wrap all by default",
"}",
"if",
"(",
"methodList",
".",
"contains",
"(",
"methodName",
")",
")",
... | Checks if the method being invoked should be wrapped by a service.
It looks the method name up in the methodList. If its in the list, then
the method should be wrapped. If the list is null, then all methods
are wrapped.
@param methodName The method being called
@return boolean | [
"Checks",
"if",
"the",
"method",
"being",
"invoked",
"should",
"be",
"wrapped",
"by",
"a",
"service",
".",
"It",
"looks",
"the",
"method",
"name",
"up",
"in",
"the",
"methodList",
".",
"If",
"its",
"in",
"the",
"list",
"then",
"the",
"method",
"should",
... | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/config/SingleServiceWrapperInterceptor.java#L79-L90 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/MBeanOperationInvoker.java | MBeanOperationInvoker.invokeOperation | public Object invokeOperation(Map<String, String[]> parameterMap) throws JMException {
MBeanParameterInfo[] parameterInfoArray = operationInfo.getSignature();
Object[] values = new Object[parameterInfoArray.length];
String[] types = new String[parameterInfoArray.length];
MBeanValueConverter valueConverter = createMBeanValueConverter(parameterMap);
for (int parameterNum = 0; parameterNum < parameterInfoArray.length; parameterNum++) {
MBeanParameterInfo parameterInfo = parameterInfoArray[parameterNum];
String type = parameterInfo.getType();
types[parameterNum] = type;
values[parameterNum] = valueConverter.convertParameterValue(parameterInfo.getName(), type);
}
return mBeanServer.invoke(objectName, operationInfo.getName(), values, types);
} | java | public Object invokeOperation(Map<String, String[]> parameterMap) throws JMException {
MBeanParameterInfo[] parameterInfoArray = operationInfo.getSignature();
Object[] values = new Object[parameterInfoArray.length];
String[] types = new String[parameterInfoArray.length];
MBeanValueConverter valueConverter = createMBeanValueConverter(parameterMap);
for (int parameterNum = 0; parameterNum < parameterInfoArray.length; parameterNum++) {
MBeanParameterInfo parameterInfo = parameterInfoArray[parameterNum];
String type = parameterInfo.getType();
types[parameterNum] = type;
values[parameterNum] = valueConverter.convertParameterValue(parameterInfo.getName(), type);
}
return mBeanServer.invoke(objectName, operationInfo.getName(), values, types);
} | [
"public",
"Object",
"invokeOperation",
"(",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"parameterMap",
")",
"throws",
"JMException",
"{",
"MBeanParameterInfo",
"[",
"]",
"parameterInfoArray",
"=",
"operationInfo",
".",
"getSignature",
"(",
")",
";",
"... | Invoke the operation.
@param parameterMap the {@link Map} of parameter names to value arrays.
@return the {@link Object} return value from the operation.
@throws JMException Java Management Exception | [
"Invoke",
"the",
"operation",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/jmx/MBeanOperationInvoker.java#L52-L68 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/config/MonitorMethodInterceptorDefinitionDecorator.java | MonitorMethodInterceptorDefinitionDecorator.registerInterceptor | private void registerInterceptor(Node source,
String beanName,
BeanDefinitionRegistry registry) {
List<String> methodList = buildMethodList(source);
BeanDefinitionBuilder initializer =
BeanDefinitionBuilder.rootBeanDefinition(SingleServiceWrapperInterceptor.class);
initializer.addPropertyValue("methods", methodList);
String perfMonitorName = beanName + "PerformanceMonitor";
initializer.addPropertyReference("serviceWrapper", perfMonitorName);
String interceptorName = beanName + "PerformanceMonitorInterceptor";
registry.registerBeanDefinition(interceptorName, initializer.getBeanDefinition());
} | java | private void registerInterceptor(Node source,
String beanName,
BeanDefinitionRegistry registry) {
List<String> methodList = buildMethodList(source);
BeanDefinitionBuilder initializer =
BeanDefinitionBuilder.rootBeanDefinition(SingleServiceWrapperInterceptor.class);
initializer.addPropertyValue("methods", methodList);
String perfMonitorName = beanName + "PerformanceMonitor";
initializer.addPropertyReference("serviceWrapper", perfMonitorName);
String interceptorName = beanName + "PerformanceMonitorInterceptor";
registry.registerBeanDefinition(interceptorName, initializer.getBeanDefinition());
} | [
"private",
"void",
"registerInterceptor",
"(",
"Node",
"source",
",",
"String",
"beanName",
",",
"BeanDefinitionRegistry",
"registry",
")",
"{",
"List",
"<",
"String",
">",
"methodList",
"=",
"buildMethodList",
"(",
"source",
")",
";",
"BeanDefinitionBuilder",
"in... | Register a new SingleServiceWrapperInterceptor for the bean being
wrapped, associate it with the PerformanceMonitor and tell it which methods
to intercept.
@param source An Attribute node from the spring configuration
@param beanName The name of the bean that this performance monitor is wrapped around
@param registry The registry where all the spring beans are registered | [
"Register",
"a",
"new",
"SingleServiceWrapperInterceptor",
"for",
"the",
"bean",
"being",
"wrapped",
"associate",
"it",
"with",
"the",
"PerformanceMonitor",
"and",
"tell",
"it",
"which",
"methods",
"to",
"intercept",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/config/MonitorMethodInterceptorDefinitionDecorator.java#L69-L83 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/config/MonitorMethodInterceptorDefinitionDecorator.java | MonitorMethodInterceptorDefinitionDecorator.parseMethodList | public List<String> parseMethodList(String methods) {
String[] methodArray = StringUtils.delimitedListToStringArray(methods, ",");
List<String> methodList = new ArrayList<String>();
for (String methodName : methodArray) {
methodList.add(methodName.trim());
}
return methodList;
} | java | public List<String> parseMethodList(String methods) {
String[] methodArray = StringUtils.delimitedListToStringArray(methods, ",");
List<String> methodList = new ArrayList<String>();
for (String methodName : methodArray) {
methodList.add(methodName.trim());
}
return methodList;
} | [
"public",
"List",
"<",
"String",
">",
"parseMethodList",
"(",
"String",
"methods",
")",
"{",
"String",
"[",
"]",
"methodArray",
"=",
"StringUtils",
".",
"delimitedListToStringArray",
"(",
"methods",
",",
"\",\"",
")",
";",
"List",
"<",
"String",
">",
"method... | Parse a comma-delimited list of method names into a List of strings.
Whitespace is ignored.
@param methods the comma delimited list of methods from the spring configuration
@return List<String> | [
"Parse",
"a",
"comma",
"-",
"delimited",
"list",
"of",
"method",
"names",
"into",
"a",
"List",
"of",
"strings",
".",
"Whitespace",
"is",
"ignored",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/config/MonitorMethodInterceptorDefinitionDecorator.java#L107-L117 | train |
Comcast/jrugged | jrugged-spring/src/main/java/org/fishwife/jrugged/spring/config/MonitorMethodInterceptorDefinitionDecorator.java | MonitorMethodInterceptorDefinitionDecorator.registerPerformanceMonitor | private void registerPerformanceMonitor(String beanName,
BeanDefinitionRegistry registry) {
String perfMonitorName = beanName + "PerformanceMonitor";
if (!registry.containsBeanDefinition(perfMonitorName)) {
BeanDefinitionBuilder initializer =
BeanDefinitionBuilder.rootBeanDefinition(PerformanceMonitorBean.class);
registry.registerBeanDefinition(perfMonitorName, initializer.getBeanDefinition());
}
} | java | private void registerPerformanceMonitor(String beanName,
BeanDefinitionRegistry registry) {
String perfMonitorName = beanName + "PerformanceMonitor";
if (!registry.containsBeanDefinition(perfMonitorName)) {
BeanDefinitionBuilder initializer =
BeanDefinitionBuilder.rootBeanDefinition(PerformanceMonitorBean.class);
registry.registerBeanDefinition(perfMonitorName, initializer.getBeanDefinition());
}
} | [
"private",
"void",
"registerPerformanceMonitor",
"(",
"String",
"beanName",
",",
"BeanDefinitionRegistry",
"registry",
")",
"{",
"String",
"perfMonitorName",
"=",
"beanName",
"+",
"\"PerformanceMonitor\"",
";",
"if",
"(",
"!",
"registry",
".",
"containsBeanDefinition",
... | Register a new PerformanceMonitor with Spring if it does not already exist.
@param beanName The name of the bean that this performance monitor is wrapped around
@param registry The registry where all the spring beans are registered | [
"Register",
"a",
"new",
"PerformanceMonitor",
"with",
"Spring",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | b6a5147c68ee733faf5616d49800abcbba67afe9 | https://github.com/Comcast/jrugged/blob/b6a5147c68ee733faf5616d49800abcbba67afe9/jrugged-spring/src/main/java/org/fishwife/jrugged/spring/config/MonitorMethodInterceptorDefinitionDecorator.java#L125-L134 | train |
flapdoodle-oss/de.flapdoodle.embed.process | src/main/java/de/flapdoodle/embed/process/io/file/Files.java | Files.forceDelete | public static void forceDelete(final Path path) throws IOException {
if (!java.nio.file.Files.isDirectory(path)) {
java.nio.file.Files.delete(path);
} else {
java.nio.file.Files.walkFileTree(path, DeleteDirVisitor.getInstance());
}
} | java | public static void forceDelete(final Path path) throws IOException {
if (!java.nio.file.Files.isDirectory(path)) {
java.nio.file.Files.delete(path);
} else {
java.nio.file.Files.walkFileTree(path, DeleteDirVisitor.getInstance());
}
} | [
"public",
"static",
"void",
"forceDelete",
"(",
"final",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"java",
".",
"nio",
".",
"file",
".",
"Files",
".",
"isDirectory",
"(",
"path",
")",
")",
"{",
"java",
".",
"nio",
".",
"file"... | Deletes a path from the filesystem
If the path is a directory its contents
will be recursively deleted before it itself
is deleted.
Note that removal of a directory is not an atomic-operation
and so if an error occurs during removal, some of the directories
descendants may have already been removed
@throws IOException if an error occurs whilst removing a file or directory | [
"Deletes",
"a",
"path",
"from",
"the",
"filesystem"
] | c6eebcf6705372ab15d4c438dcefcd50ffbde6d0 | https://github.com/flapdoodle-oss/de.flapdoodle.embed.process/blob/c6eebcf6705372ab15d4c438dcefcd50ffbde6d0/src/main/java/de/flapdoodle/embed/process/io/file/Files.java#L143-L149 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/SelectCreator.java | SelectCreator.count | public PreparedStatementCreator count(final Dialect dialect) {
return new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection con)
throws SQLException {
return getPreparedStatementCreator()
.setSql(dialect.createCountSelect(builder.toString()))
.createPreparedStatement(con);
}
};
} | java | public PreparedStatementCreator count(final Dialect dialect) {
return new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection con)
throws SQLException {
return getPreparedStatementCreator()
.setSql(dialect.createCountSelect(builder.toString()))
.createPreparedStatement(con);
}
};
} | [
"public",
"PreparedStatementCreator",
"count",
"(",
"final",
"Dialect",
"dialect",
")",
"{",
"return",
"new",
"PreparedStatementCreator",
"(",
")",
"{",
"public",
"PreparedStatement",
"createPreparedStatement",
"(",
"Connection",
"con",
")",
"throws",
"SQLException",
... | Returns a PreparedStatementCreator that returns a count of the rows that
this creator would return.
@param dialect
Database dialect. | [
"Returns",
"a",
"PreparedStatementCreator",
"that",
"returns",
"a",
"count",
"of",
"the",
"rows",
"that",
"this",
"creator",
"would",
"return",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/SelectCreator.java#L80-L89 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/SelectCreator.java | SelectCreator.page | public PreparedStatementCreator page(final Dialect dialect, final int limit, final int offset) {
return new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
return getPreparedStatementCreator()
.setSql(dialect.createPageSelect(builder.toString(), limit, offset))
.createPreparedStatement(con);
}
};
} | java | public PreparedStatementCreator page(final Dialect dialect, final int limit, final int offset) {
return new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
return getPreparedStatementCreator()
.setSql(dialect.createPageSelect(builder.toString(), limit, offset))
.createPreparedStatement(con);
}
};
} | [
"public",
"PreparedStatementCreator",
"page",
"(",
"final",
"Dialect",
"dialect",
",",
"final",
"int",
"limit",
",",
"final",
"int",
"offset",
")",
"{",
"return",
"new",
"PreparedStatementCreator",
"(",
")",
"{",
"public",
"PreparedStatement",
"createPreparedStateme... | Returns a PreparedStatementCreator that returns a page of the underlying
result set.
@param dialect
Database dialect to use.
@param limit
Maximum number of rows to return.
@param offset
Index of the first row to return. | [
"Returns",
"a",
"PreparedStatementCreator",
"that",
"returns",
"a",
"page",
"of",
"the",
"underlying",
"result",
"set",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/SelectCreator.java#L165-L173 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/Column.java | Column.toColumnName | private static String toColumnName(String fieldName) {
int lastDot = fieldName.indexOf('.');
if (lastDot > -1) {
return fieldName.substring(lastDot + 1);
} else {
return fieldName;
}
} | java | private static String toColumnName(String fieldName) {
int lastDot = fieldName.indexOf('.');
if (lastDot > -1) {
return fieldName.substring(lastDot + 1);
} else {
return fieldName;
}
} | [
"private",
"static",
"String",
"toColumnName",
"(",
"String",
"fieldName",
")",
"{",
"int",
"lastDot",
"=",
"fieldName",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"lastDot",
">",
"-",
"1",
")",
"{",
"return",
"fieldName",
".",
"substring",
"(... | Returns the portion of the field name after the last dot, as field names
may actually be paths. | [
"Returns",
"the",
"portion",
"of",
"the",
"field",
"name",
"after",
"the",
"last",
"dot",
"as",
"field",
"names",
"may",
"actually",
"be",
"paths",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/Column.java#L15-L22 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/Predicates.java | Predicates.anyBitsSet | public static Predicate anyBitsSet(final String expr, final long bits) {
return new Predicate() {
private String param;
public void init(AbstractSqlCreator creator) {
param = creator.allocateParameter();
creator.setParameter(param, bits);
}
public String toSql() {
return String.format("(%s & :%s) > 0", expr, param);
}
};
} | java | public static Predicate anyBitsSet(final String expr, final long bits) {
return new Predicate() {
private String param;
public void init(AbstractSqlCreator creator) {
param = creator.allocateParameter();
creator.setParameter(param, bits);
}
public String toSql() {
return String.format("(%s & :%s) > 0", expr, param);
}
};
} | [
"public",
"static",
"Predicate",
"anyBitsSet",
"(",
"final",
"String",
"expr",
",",
"final",
"long",
"bits",
")",
"{",
"return",
"new",
"Predicate",
"(",
")",
"{",
"private",
"String",
"param",
";",
"public",
"void",
"init",
"(",
"AbstractSqlCreator",
"creat... | Adds a clause that checks whether ANY set bits in a bitmask are present
in a numeric expression.
@param expr
SQL numeric expression to check.
@param bits
Integer containing the bits for which to check. | [
"Adds",
"a",
"clause",
"that",
"checks",
"whether",
"ANY",
"set",
"bits",
"in",
"a",
"bitmask",
"are",
"present",
"in",
"a",
"numeric",
"expression",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/Predicates.java#L74-L85 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/Predicates.java | Predicates.is | public static Predicate is(final String sql) {
return new Predicate() {
public String toSql() {
return sql;
}
public void init(AbstractSqlCreator creator) {
}
};
} | java | public static Predicate is(final String sql) {
return new Predicate() {
public String toSql() {
return sql;
}
public void init(AbstractSqlCreator creator) {
}
};
} | [
"public",
"static",
"Predicate",
"is",
"(",
"final",
"String",
"sql",
")",
"{",
"return",
"new",
"Predicate",
"(",
")",
"{",
"public",
"String",
"toSql",
"(",
")",
"{",
"return",
"sql",
";",
"}",
"public",
"void",
"init",
"(",
"AbstractSqlCreator",
"crea... | Returns a predicate that takes no parameters. The given SQL expression is
used directly.
@param sql
SQL text of the expression | [
"Returns",
"a",
"predicate",
"that",
"takes",
"no",
"parameters",
".",
"The",
"given",
"SQL",
"expression",
"is",
"used",
"directly",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/Predicates.java#L171-L179 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/Predicates.java | Predicates.join | private static Predicate join(final String joinWord, final List<Predicate> preds) {
return new Predicate() {
public void init(AbstractSqlCreator creator) {
for (Predicate p : preds) {
p.init(creator);
}
}
public String toSql() {
StringBuilder sb = new StringBuilder()
.append("(");
boolean first = true;
for (Predicate p : preds) {
if (!first) {
sb.append(" ").append(joinWord).append(" ");
}
sb.append(p.toSql());
first = false;
}
return sb.append(")").toString();
}
};
} | java | private static Predicate join(final String joinWord, final List<Predicate> preds) {
return new Predicate() {
public void init(AbstractSqlCreator creator) {
for (Predicate p : preds) {
p.init(creator);
}
}
public String toSql() {
StringBuilder sb = new StringBuilder()
.append("(");
boolean first = true;
for (Predicate p : preds) {
if (!first) {
sb.append(" ").append(joinWord).append(" ");
}
sb.append(p.toSql());
first = false;
}
return sb.append(")").toString();
}
};
} | [
"private",
"static",
"Predicate",
"join",
"(",
"final",
"String",
"joinWord",
",",
"final",
"List",
"<",
"Predicate",
">",
"preds",
")",
"{",
"return",
"new",
"Predicate",
"(",
")",
"{",
"public",
"void",
"init",
"(",
"AbstractSqlCreator",
"creator",
")",
... | Factory for 'and' and 'or' predicates. | [
"Factory",
"for",
"and",
"and",
"or",
"predicates",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/Predicates.java#L184-L205 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java | Mapping.addFields | public Mapping<T> addFields() {
if (idColumn == null) {
throw new RuntimeException("Map ID column before adding class fields");
}
for (Field f : ReflectionUtils.getDeclaredFieldsInHierarchy(clazz)) {
if (!Modifier.isStatic(f.getModifiers())
&& !isFieldMapped(f.getName())
&& !ignoredFields.contains(f.getName())) {
addColumn(f.getName());
}
}
return this;
} | java | public Mapping<T> addFields() {
if (idColumn == null) {
throw new RuntimeException("Map ID column before adding class fields");
}
for (Field f : ReflectionUtils.getDeclaredFieldsInHierarchy(clazz)) {
if (!Modifier.isStatic(f.getModifiers())
&& !isFieldMapped(f.getName())
&& !ignoredFields.contains(f.getName())) {
addColumn(f.getName());
}
}
return this;
} | [
"public",
"Mapping",
"<",
"T",
">",
"addFields",
"(",
")",
"{",
"if",
"(",
"idColumn",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Map ID column before adding class fields\"",
")",
";",
"}",
"for",
"(",
"Field",
"f",
":",
"ReflectionU... | Adds mappings for each declared field in the mapped class. Any fields
already mapped by addColumn are skipped. | [
"Adds",
"mappings",
"for",
"each",
"declared",
"field",
"in",
"the",
"mapped",
"class",
".",
"Any",
"fields",
"already",
"mapped",
"by",
"addColumn",
"are",
"skipped",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java#L300-L315 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java | Mapping.createInstance | protected T createInstance() {
try {
Constructor<T> ctor = clazz.getDeclaredConstructor();
ctor.setAccessible(true);
return ctor.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (SecurityException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
} | java | protected T createInstance() {
try {
Constructor<T> ctor = clazz.getDeclaredConstructor();
ctor.setAccessible(true);
return ctor.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (SecurityException e) {
throw new RuntimeException(e);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
} | [
"protected",
"T",
"createInstance",
"(",
")",
"{",
"try",
"{",
"Constructor",
"<",
"T",
">",
"ctor",
"=",
"clazz",
".",
"getDeclaredConstructor",
"(",
")",
";",
"ctor",
".",
"setAccessible",
"(",
"true",
")",
";",
"return",
"ctor",
".",
"newInstance",
"(... | Creates instance of the entity class. This method is called to create the object
instances when returning query results. | [
"Creates",
"instance",
"of",
"the",
"entity",
"class",
".",
"This",
"method",
"is",
"called",
"to",
"create",
"the",
"object",
"instances",
"when",
"returning",
"query",
"results",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java#L330-L348 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java | Mapping.deleteById | public void deleteById(Object id) {
int count = beginDelete().whereEquals(idColumn.getColumnName(), id).delete();
if (count == 0) {
throw new RowNotFoundException(table, id);
}
} | java | public void deleteById(Object id) {
int count = beginDelete().whereEquals(idColumn.getColumnName(), id).delete();
if (count == 0) {
throw new RowNotFoundException(table, id);
}
} | [
"public",
"void",
"deleteById",
"(",
"Object",
"id",
")",
"{",
"int",
"count",
"=",
"beginDelete",
"(",
")",
".",
"whereEquals",
"(",
"idColumn",
".",
"getColumnName",
"(",
")",
",",
"id",
")",
".",
"delete",
"(",
")",
";",
"if",
"(",
"count",
"==",
... | Deletes an entity by its primary key.
@param id
Primary key of the entity. | [
"Deletes",
"an",
"entity",
"by",
"its",
"primary",
"key",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java#L363-L370 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java | Mapping.findById | public T findById(Object id) throws RowNotFoundException, TooManyRowsException {
return findWhere(eq(idColumn.getColumnName(), id)).getSingleResult();
} | java | public T findById(Object id) throws RowNotFoundException, TooManyRowsException {
return findWhere(eq(idColumn.getColumnName(), id)).getSingleResult();
} | [
"public",
"T",
"findById",
"(",
"Object",
"id",
")",
"throws",
"RowNotFoundException",
",",
"TooManyRowsException",
"{",
"return",
"findWhere",
"(",
"eq",
"(",
"idColumn",
".",
"getColumnName",
"(",
")",
",",
"id",
")",
")",
".",
"getSingleResult",
"(",
")",... | Finds an entity given its primary key.
@throws RowNotFoundException
If no such object was found.
@throws TooManyRowsException
If more that one object was returned for the given ID. | [
"Finds",
"an",
"entity",
"given",
"its",
"primary",
"key",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java#L380-L382 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java | Mapping.insert | public T insert(T entity) {
if (!hasPrimaryKey(entity)) {
throw new RuntimeException(String.format("Tried to insert entity of type %s with null or zero primary key",
entity.getClass().getSimpleName()));
}
InsertCreator insert = new InsertCreator(table);
insert.setValue(idColumn.getColumnName(), getPrimaryKey(entity));
if (versionColumn != null) {
insert.setValue(versionColumn.getColumnName(), 0);
}
for (Column column : columns) {
if (!column.isReadOnly()) {
insert.setValue(column.getColumnName(), getFieldValueAsColumn(entity, column));
}
}
new JdbcTemplate(ormConfig.getDataSource()).update(insert);
if (versionColumn != null) {
ReflectionUtils.setFieldValue(entity, versionColumn.getFieldName(), 0);
}
return entity;
} | java | public T insert(T entity) {
if (!hasPrimaryKey(entity)) {
throw new RuntimeException(String.format("Tried to insert entity of type %s with null or zero primary key",
entity.getClass().getSimpleName()));
}
InsertCreator insert = new InsertCreator(table);
insert.setValue(idColumn.getColumnName(), getPrimaryKey(entity));
if (versionColumn != null) {
insert.setValue(versionColumn.getColumnName(), 0);
}
for (Column column : columns) {
if (!column.isReadOnly()) {
insert.setValue(column.getColumnName(), getFieldValueAsColumn(entity, column));
}
}
new JdbcTemplate(ormConfig.getDataSource()).update(insert);
if (versionColumn != null) {
ReflectionUtils.setFieldValue(entity, versionColumn.getFieldName(), 0);
}
return entity;
} | [
"public",
"T",
"insert",
"(",
"T",
"entity",
")",
"{",
"if",
"(",
"!",
"hasPrimaryKey",
"(",
"entity",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"String",
".",
"format",
"(",
"\"Tried to insert entity of type %s with null or zero primary key\"",
",",... | Insert entity object. The caller must first initialize the primary key
field. | [
"Insert",
"entity",
"object",
".",
"The",
"caller",
"must",
"first",
"initialize",
"the",
"primary",
"key",
"field",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java#L454-L482 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java | Mapping.hasPrimaryKey | private boolean hasPrimaryKey(T entity) {
Object pk = getPrimaryKey(entity);
if (pk == null) {
return false;
} else {
if (pk instanceof Number && ((Number) pk).longValue() == 0) {
return false;
}
}
return true;
} | java | private boolean hasPrimaryKey(T entity) {
Object pk = getPrimaryKey(entity);
if (pk == null) {
return false;
} else {
if (pk instanceof Number && ((Number) pk).longValue() == 0) {
return false;
}
}
return true;
} | [
"private",
"boolean",
"hasPrimaryKey",
"(",
"T",
"entity",
")",
"{",
"Object",
"pk",
"=",
"getPrimaryKey",
"(",
"entity",
")",
";",
"if",
"(",
"pk",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"pk",
"instanceof",
"Num... | Returns true if this entity's primary key is not null, and for numeric
fields, is non-zero. | [
"Returns",
"true",
"if",
"this",
"entity",
"s",
"primary",
"key",
"is",
"not",
"null",
"and",
"for",
"numeric",
"fields",
"is",
"non",
"-",
"zero",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java#L507-L517 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java | Mapping.update | public T update(T entity) throws RowNotFoundException, OptimisticLockException {
if (!hasPrimaryKey(entity)) {
throw new RuntimeException(String.format("Tried to update entity of type %s without a primary key", entity
.getClass().getSimpleName()));
}
UpdateCreator update = new UpdateCreator(table);
update.whereEquals(idColumn.getColumnName(), getPrimaryKey(entity));
if (versionColumn != null) {
update.set(versionColumn.getColumnName() + " = " + versionColumn.getColumnName() + " + 1");
update.whereEquals(versionColumn.getColumnName(), getVersion(entity));
}
for (Column column : columns) {
if (!column.isReadOnly()) {
update.setValue(column.getColumnName(), getFieldValueAsColumn(entity, column));
}
}
int rows = new JdbcTemplate(ormConfig.getDataSource()).update(update);
if (rows == 1) {
if (versionColumn != null) {
ReflectionUtils.setFieldValue(entity, versionColumn.getFieldName(), getVersion(entity) + 1);
}
return entity;
} else if (rows > 1) {
throw new RuntimeException(
String.format("Updating table %s with id %s updated %d rows. There must be a mapping problem. Is column %s really the primary key?",
table, getPrimaryKey(entity), rows, idColumn));
} else {
//
// Updated zero rows. This could be because our ID is wrong, or
// because our object is out-of date. Let's try querying just by ID.
//
SelectCreator selectById = new SelectCreator()
.column("count(*)")
.from(table)
.whereEquals(idColumn.getColumnName(), getPrimaryKey(entity));
rows = new JdbcTemplate(ormConfig.getDataSource()).query(selectById, new ResultSetExtractor<Integer>() {
@Override
public Integer extractData(ResultSet rs) throws SQLException, DataAccessException {
rs.next();
return rs.getInt(1);
}
});
if (rows == 0) {
throw new RowNotFoundException(table, getPrimaryKey(entity));
} else {
throw new OptimisticLockException(table, getPrimaryKey(entity));
}
}
} | java | public T update(T entity) throws RowNotFoundException, OptimisticLockException {
if (!hasPrimaryKey(entity)) {
throw new RuntimeException(String.format("Tried to update entity of type %s without a primary key", entity
.getClass().getSimpleName()));
}
UpdateCreator update = new UpdateCreator(table);
update.whereEquals(idColumn.getColumnName(), getPrimaryKey(entity));
if (versionColumn != null) {
update.set(versionColumn.getColumnName() + " = " + versionColumn.getColumnName() + " + 1");
update.whereEquals(versionColumn.getColumnName(), getVersion(entity));
}
for (Column column : columns) {
if (!column.isReadOnly()) {
update.setValue(column.getColumnName(), getFieldValueAsColumn(entity, column));
}
}
int rows = new JdbcTemplate(ormConfig.getDataSource()).update(update);
if (rows == 1) {
if (versionColumn != null) {
ReflectionUtils.setFieldValue(entity, versionColumn.getFieldName(), getVersion(entity) + 1);
}
return entity;
} else if (rows > 1) {
throw new RuntimeException(
String.format("Updating table %s with id %s updated %d rows. There must be a mapping problem. Is column %s really the primary key?",
table, getPrimaryKey(entity), rows, idColumn));
} else {
//
// Updated zero rows. This could be because our ID is wrong, or
// because our object is out-of date. Let's try querying just by ID.
//
SelectCreator selectById = new SelectCreator()
.column("count(*)")
.from(table)
.whereEquals(idColumn.getColumnName(), getPrimaryKey(entity));
rows = new JdbcTemplate(ormConfig.getDataSource()).query(selectById, new ResultSetExtractor<Integer>() {
@Override
public Integer extractData(ResultSet rs) throws SQLException, DataAccessException {
rs.next();
return rs.getInt(1);
}
});
if (rows == 0) {
throw new RowNotFoundException(table, getPrimaryKey(entity));
} else {
throw new OptimisticLockException(table, getPrimaryKey(entity));
}
}
} | [
"public",
"T",
"update",
"(",
"T",
"entity",
")",
"throws",
"RowNotFoundException",
",",
"OptimisticLockException",
"{",
"if",
"(",
"!",
"hasPrimaryKey",
"(",
"entity",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"String",
".",
"format",
"(",
"\"... | Updates value of entity in the table. | [
"Updates",
"value",
"of",
"entity",
"in",
"the",
"table",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/Mapping.java#L558-L622 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/AbstractSqlCreator.java | AbstractSqlCreator.setParameter | public AbstractSqlCreator setParameter(String name, Object value) {
ppsc.setParameter(name, value);
return this;
} | java | public AbstractSqlCreator setParameter(String name, Object value) {
ppsc.setParameter(name, value);
return this;
} | [
"public",
"AbstractSqlCreator",
"setParameter",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"ppsc",
".",
"setParameter",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Sets a parameter for the creator. | [
"Sets",
"a",
"parameter",
"for",
"the",
"creator",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/AbstractSqlCreator.java#L64-L67 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/InsertBuilder.java | InsertBuilder.set | public InsertBuilder set(String column, String value) {
columns.add(column);
values.add(value);
return this;
} | java | public InsertBuilder set(String column, String value) {
columns.add(column);
values.add(value);
return this;
} | [
"public",
"InsertBuilder",
"set",
"(",
"String",
"column",
",",
"String",
"value",
")",
"{",
"columns",
".",
"add",
"(",
"column",
")",
";",
"values",
".",
"add",
"(",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Inserts a column name, value pair into the SQL.
@param column
Name of the table column.
@param value
Value to substitute in. InsertBuilder does *no* interpretation
of this. If you want a string constant inserted, you must
provide the single quotes and escape the internal quotes. It
is more common to use a question mark or a token in the style
of {@link ParameterizedPreparedStatementCreator}, e.g. ":foo". | [
"Inserts",
"a",
"column",
"name",
"value",
"pair",
"into",
"the",
"SQL",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/InsertBuilder.java#L44-L48 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/SelectBuilder.java | SelectBuilder.orderBy | public SelectBuilder orderBy(String name, boolean ascending) {
if (ascending) {
orderBys.add(name + " asc");
} else {
orderBys.add(name + " desc");
}
return this;
} | java | public SelectBuilder orderBy(String name, boolean ascending) {
if (ascending) {
orderBys.add(name + " asc");
} else {
orderBys.add(name + " desc");
}
return this;
} | [
"public",
"SelectBuilder",
"orderBy",
"(",
"String",
"name",
",",
"boolean",
"ascending",
")",
"{",
"if",
"(",
"ascending",
")",
"{",
"orderBys",
".",
"add",
"(",
"name",
"+",
"\" asc\"",
")",
";",
"}",
"else",
"{",
"orderBys",
".",
"add",
"(",
"name",... | Adds an ORDER BY item with a direction indicator.
@param name
Name of the column by which to sort.
@param ascending
If true, specifies the direction "asc", otherwise, specifies
the direction "desc". | [
"Adds",
"an",
"ORDER",
"BY",
"item",
"with",
"a",
"direction",
"indicator",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/SelectBuilder.java#L248-L255 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/StringListFlattener.java | StringListFlattener.split | public List<String> split(String s) {
List<String> result = new ArrayList<String>();
if (s == null) {
return result;
}
boolean seenEscape = false;
// Used to detect if the last char was a separator,
// in which case we append an empty string
boolean seenSeparator = false;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
seenSeparator = false;
char c = s.charAt(i);
if (seenEscape) {
if (c == escapeChar || c == separator) {
sb.append(c);
} else {
sb.append(escapeChar).append(c);
}
seenEscape = false;
} else {
if (c == escapeChar) {
seenEscape = true;
} else if (c == separator) {
if (sb.length() == 0 && convertEmptyToNull) {
result.add(null);
} else {
result.add(sb.toString());
}
sb.setLength(0);
seenSeparator = true;
} else {
sb.append(c);
}
}
}
// Clean up
if (seenEscape) {
sb.append(escapeChar);
}
if (sb.length() > 0 || seenSeparator) {
if (sb.length() == 0 && convertEmptyToNull) {
result.add(null);
} else {
result.add(sb.toString());
}
}
return result;
} | java | public List<String> split(String s) {
List<String> result = new ArrayList<String>();
if (s == null) {
return result;
}
boolean seenEscape = false;
// Used to detect if the last char was a separator,
// in which case we append an empty string
boolean seenSeparator = false;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
seenSeparator = false;
char c = s.charAt(i);
if (seenEscape) {
if (c == escapeChar || c == separator) {
sb.append(c);
} else {
sb.append(escapeChar).append(c);
}
seenEscape = false;
} else {
if (c == escapeChar) {
seenEscape = true;
} else if (c == separator) {
if (sb.length() == 0 && convertEmptyToNull) {
result.add(null);
} else {
result.add(sb.toString());
}
sb.setLength(0);
seenSeparator = true;
} else {
sb.append(c);
}
}
}
// Clean up
if (seenEscape) {
sb.append(escapeChar);
}
if (sb.length() > 0 || seenSeparator) {
if (sb.length() == 0 && convertEmptyToNull) {
result.add(null);
} else {
result.add(sb.toString());
}
}
return result;
} | [
"public",
"List",
"<",
"String",
">",
"split",
"(",
"String",
"s",
")",
"{",
"List",
"<",
"String",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"s",
"==",
"null",
")",
"{",
"return",
"result",
";",
"}",
... | Splits the given string. | [
"Splits",
"the",
"given",
"string",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/StringListFlattener.java#L35-L93 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/StringListFlattener.java | StringListFlattener.join | public String join(List<String> list) {
if (list == null) {
return null;
}
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String s : list) {
if (s == null) {
if (convertEmptyToNull) {
s = "";
} else {
throw new IllegalArgumentException("StringListFlattener does not support null strings in the list. Consider calling setConvertEmptyToNull(true).");
}
}
if (!first) {
sb.append(separator);
}
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == escapeChar || c == separator) {
sb.append(escapeChar);
}
sb.append(c);
}
first = false;
}
return sb.toString();
} | java | public String join(List<String> list) {
if (list == null) {
return null;
}
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String s : list) {
if (s == null) {
if (convertEmptyToNull) {
s = "";
} else {
throw new IllegalArgumentException("StringListFlattener does not support null strings in the list. Consider calling setConvertEmptyToNull(true).");
}
}
if (!first) {
sb.append(separator);
}
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == escapeChar || c == separator) {
sb.append(escapeChar);
}
sb.append(c);
}
first = false;
}
return sb.toString();
} | [
"public",
"String",
"join",
"(",
"List",
"<",
"String",
">",
"list",
")",
"{",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"first",
"=",
"true",
... | Joins the given list into a single string. | [
"Joins",
"the",
"given",
"list",
"into",
"a",
"single",
"string",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/StringListFlattener.java#L98-L131 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/AbstractSqlBuilder.java | AbstractSqlBuilder.appendList | protected void appendList(StringBuilder sql, List<?> list, String init, String sep) {
boolean first = true;
for (Object s : list) {
if (first) {
sql.append(init);
} else {
sql.append(sep);
}
sql.append(s);
first = false;
}
} | java | protected void appendList(StringBuilder sql, List<?> list, String init, String sep) {
boolean first = true;
for (Object s : list) {
if (first) {
sql.append(init);
} else {
sql.append(sep);
}
sql.append(s);
first = false;
}
} | [
"protected",
"void",
"appendList",
"(",
"StringBuilder",
"sql",
",",
"List",
"<",
"?",
">",
"list",
",",
"String",
"init",
",",
"String",
"sep",
")",
"{",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"Object",
"s",
":",
"list",
")",
"{",
"if",
... | Constructs a list of items with given separators.
@param sql
StringBuilder to which the constructed string will be
appended.
@param list
List of objects (usually strings) to join.
@param init
String to be added to the start of the list, before any of the
items.
@param sep
Separator string to be added between items in the list. | [
"Constructs",
"a",
"list",
"of",
"items",
"with",
"given",
"separators",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/AbstractSqlBuilder.java#L26-L39 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/EnumStringConverter.java | EnumStringConverter.create | public static <E extends Enum<E>> EnumStringConverter<E> create(Class<E> enumType) {
return new EnumStringConverter<E>(enumType);
} | java | public static <E extends Enum<E>> EnumStringConverter<E> create(Class<E> enumType) {
return new EnumStringConverter<E>(enumType);
} | [
"public",
"static",
"<",
"E",
"extends",
"Enum",
"<",
"E",
">",
">",
"EnumStringConverter",
"<",
"E",
">",
"create",
"(",
"Class",
"<",
"E",
">",
"enumType",
")",
"{",
"return",
"new",
"EnumStringConverter",
"<",
"E",
">",
"(",
"enumType",
")",
";",
... | Factory method to create EnumStringConverter
@param <E>
enum type inferred from enumType parameter
@param enumType
particular enum class
@return instance of EnumConverter | [
"Factory",
"method",
"to",
"create",
"EnumStringConverter"
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/EnumStringConverter.java#L26-L28 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/ReflectionUtils.java | ReflectionUtils.getDeclaredFieldsInHierarchy | public static Field[] getDeclaredFieldsInHierarchy(Class<?> clazz) {
if (clazz.isPrimitive()) {
throw new IllegalArgumentException("Primitive types not supported.");
}
List<Field> result = new ArrayList<Field>();
while (true) {
if (clazz == Object.class) {
break;
}
result.addAll(Arrays.asList(clazz.getDeclaredFields()));
clazz = clazz.getSuperclass();
}
return result.toArray(new Field[result.size()]);
} | java | public static Field[] getDeclaredFieldsInHierarchy(Class<?> clazz) {
if (clazz.isPrimitive()) {
throw new IllegalArgumentException("Primitive types not supported.");
}
List<Field> result = new ArrayList<Field>();
while (true) {
if (clazz == Object.class) {
break;
}
result.addAll(Arrays.asList(clazz.getDeclaredFields()));
clazz = clazz.getSuperclass();
}
return result.toArray(new Field[result.size()]);
} | [
"public",
"static",
"Field",
"[",
"]",
"getDeclaredFieldsInHierarchy",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
".",
"isPrimitive",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Primitive types not supported.\... | Returns an array of all declared fields in the given class and all
super-classes. | [
"Returns",
"an",
"array",
"of",
"all",
"declared",
"fields",
"in",
"the",
"given",
"class",
"and",
"all",
"super",
"-",
"classes",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/ReflectionUtils.java#L14-L33 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/ReflectionUtils.java | ReflectionUtils.getDeclaredFieldWithPath | public static Field getDeclaredFieldWithPath(Class<?> clazz, String path) {
int lastDot = path.lastIndexOf('.');
if (lastDot > -1) {
String parentPath = path.substring(0, lastDot);
String fieldName = path.substring(lastDot + 1);
Field parentField = getDeclaredFieldWithPath(clazz, parentPath);
return getDeclaredFieldInHierarchy(parentField.getType(), fieldName);
} else {
return getDeclaredFieldInHierarchy(clazz, path);
}
} | java | public static Field getDeclaredFieldWithPath(Class<?> clazz, String path) {
int lastDot = path.lastIndexOf('.');
if (lastDot > -1) {
String parentPath = path.substring(0, lastDot);
String fieldName = path.substring(lastDot + 1);
Field parentField = getDeclaredFieldWithPath(clazz, parentPath);
return getDeclaredFieldInHierarchy(parentField.getType(), fieldName);
} else {
return getDeclaredFieldInHierarchy(clazz, path);
}
} | [
"public",
"static",
"Field",
"getDeclaredFieldWithPath",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"path",
")",
"{",
"int",
"lastDot",
"=",
"path",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"lastDot",
">",
"-",
"1",
")",
"{",... | Returns the Field for a given parent class and a dot-separated path of
field names.
@param clazz
Parent class.
@param path
Path to the desired field. | [
"Returns",
"the",
"Field",
"for",
"a",
"given",
"parent",
"class",
"and",
"a",
"dot",
"-",
"separated",
"path",
"of",
"field",
"names",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/ReflectionUtils.java#L44-L56 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/ReflectionUtils.java | ReflectionUtils.getFieldValue | public static Object getFieldValue(Object object, String fieldName) {
try {
return getDeclaredFieldInHierarchy(object.getClass(), fieldName).get(object);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | java | public static Object getFieldValue(Object object, String fieldName) {
try {
return getDeclaredFieldInHierarchy(object.getClass(), fieldName).get(object);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"Object",
"getFieldValue",
"(",
"Object",
"object",
",",
"String",
"fieldName",
")",
"{",
"try",
"{",
"return",
"getDeclaredFieldInHierarchy",
"(",
"object",
".",
"getClass",
"(",
")",
",",
"fieldName",
")",
".",
"get",
"(",
"object",
")"... | Convenience method for getting the value of a private object field,
without the stress of checked exceptions in the reflection API.
@param object
Object containing the field.
@param fieldName
Name of the field whose value to return. | [
"Convenience",
"method",
"for",
"getting",
"the",
"value",
"of",
"a",
"private",
"object",
"field",
"without",
"the",
"stress",
"of",
"checked",
"exceptions",
"in",
"the",
"reflection",
"API",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/ReflectionUtils.java#L85-L93 | train |
jkrasnay/sqlbuilder | src/main/java/ca/krasnay/sqlbuilder/orm/ReflectionUtils.java | ReflectionUtils.setFieldValue | public static void setFieldValue(Object object, String fieldName, Object value) {
try {
getDeclaredFieldInHierarchy(object.getClass(), fieldName).set(object, value);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | java | public static void setFieldValue(Object object, String fieldName, Object value) {
try {
getDeclaredFieldInHierarchy(object.getClass(), fieldName).set(object, value);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"void",
"setFieldValue",
"(",
"Object",
"object",
",",
"String",
"fieldName",
",",
"Object",
"value",
")",
"{",
"try",
"{",
"getDeclaredFieldInHierarchy",
"(",
"object",
".",
"getClass",
"(",
")",
",",
"fieldName",
")",
".",
"set",
"(",
... | Convenience method for setting the value of a private object field,
without the stress of checked exceptions in the reflection API.
@param object
Object containing the field.
@param fieldName
Name of the field to set.
@param value
Value to which to set the field. | [
"Convenience",
"method",
"for",
"setting",
"the",
"value",
"of",
"a",
"private",
"object",
"field",
"without",
"the",
"stress",
"of",
"checked",
"exceptions",
"in",
"the",
"reflection",
"API",
"."
] | 8e6acedc51cfad0527263376af51e1ef052f7147 | https://github.com/jkrasnay/sqlbuilder/blob/8e6acedc51cfad0527263376af51e1ef052f7147/src/main/java/ca/krasnay/sqlbuilder/orm/ReflectionUtils.java#L139-L147 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/constraint/LMinMax.java | LMinMax.checkPreconditions | private static void checkPreconditions(final long min, final long max) {
if( max < min ) {
throw new IllegalArgumentException(String.format("max (%d) should not be < min (%d)", max, min));
}
} | java | private static void checkPreconditions(final long min, final long max) {
if( max < min ) {
throw new IllegalArgumentException(String.format("max (%d) should not be < min (%d)", max, min));
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"final",
"long",
"min",
",",
"final",
"long",
"max",
")",
"{",
"if",
"(",
"max",
"<",
"min",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"max (%d) should n... | Checks the preconditions for creating a new LMinMax processor.
@param min
the minimum value (inclusive)
@param max
the maximum value (inclusive)
@throws IllegalArgumentException
if {@code max < min} | [
"Checks",
"the",
"preconditions",
"for",
"creating",
"a",
"new",
"LMinMax",
"processor",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/constraint/LMinMax.java#L125-L129 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/ReflectionUtils.java | ReflectionUtils.findGetter | public static Method findGetter(final Object object, final String fieldName) {
if( object == null ) {
throw new NullPointerException("object should not be null");
} else if( fieldName == null ) {
throw new NullPointerException("fieldName should not be null");
}
final Class<?> clazz = object.getClass();
// find a standard getter
final String standardGetterName = getMethodNameForField(GET_PREFIX, fieldName);
Method getter = findGetterWithCompatibleReturnType(standardGetterName, clazz, false);
// if that fails, try for an isX() style boolean getter
if( getter == null ) {
final String booleanGetterName = getMethodNameForField(IS_PREFIX, fieldName);
getter = findGetterWithCompatibleReturnType(booleanGetterName, clazz, true);
}
if( getter == null ) {
throw new SuperCsvReflectionException(
String
.format(
"unable to find getter for field %s in class %s - check that the corresponding nameMapping element matches the field name in the bean",
fieldName, clazz.getName()));
}
return getter;
} | java | public static Method findGetter(final Object object, final String fieldName) {
if( object == null ) {
throw new NullPointerException("object should not be null");
} else if( fieldName == null ) {
throw new NullPointerException("fieldName should not be null");
}
final Class<?> clazz = object.getClass();
// find a standard getter
final String standardGetterName = getMethodNameForField(GET_PREFIX, fieldName);
Method getter = findGetterWithCompatibleReturnType(standardGetterName, clazz, false);
// if that fails, try for an isX() style boolean getter
if( getter == null ) {
final String booleanGetterName = getMethodNameForField(IS_PREFIX, fieldName);
getter = findGetterWithCompatibleReturnType(booleanGetterName, clazz, true);
}
if( getter == null ) {
throw new SuperCsvReflectionException(
String
.format(
"unable to find getter for field %s in class %s - check that the corresponding nameMapping element matches the field name in the bean",
fieldName, clazz.getName()));
}
return getter;
} | [
"public",
"static",
"Method",
"findGetter",
"(",
"final",
"Object",
"object",
",",
"final",
"String",
"fieldName",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"object should not be null\"",
")",
";",
"}... | Returns the getter method associated with the object's field.
@param object
the object
@param fieldName
the name of the field
@return the getter method
@throws NullPointerException
if object or fieldName is null
@throws SuperCsvReflectionException
if the getter doesn't exist or is not visible | [
"Returns",
"the",
"getter",
"method",
"associated",
"with",
"the",
"object",
"s",
"field",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/ReflectionUtils.java#L77-L105 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/Util.java | Util.filterListToMap | public static <T> void filterListToMap(final Map<String, T> destinationMap, final String[] nameMapping,
final List<? extends T> sourceList) {
if( destinationMap == null ) {
throw new NullPointerException("destinationMap should not be null");
} else if( nameMapping == null ) {
throw new NullPointerException("nameMapping should not be null");
} else if( sourceList == null ) {
throw new NullPointerException("sourceList should not be null");
} else if( nameMapping.length != sourceList.size() ) {
throw new SuperCsvException(
String
.format(
"the nameMapping array and the sourceList should be the same size (nameMapping length = %d, sourceList size = %d)",
nameMapping.length, sourceList.size()));
}
destinationMap.clear();
for( int i = 0; i < nameMapping.length; i++ ) {
final String key = nameMapping[i];
if( key == null ) {
continue; // null's in the name mapping means skip column
}
// no duplicates allowed
if( destinationMap.containsKey(key) ) {
throw new SuperCsvException(String.format("duplicate nameMapping '%s' at index %d", key, i));
}
destinationMap.put(key, sourceList.get(i));
}
} | java | public static <T> void filterListToMap(final Map<String, T> destinationMap, final String[] nameMapping,
final List<? extends T> sourceList) {
if( destinationMap == null ) {
throw new NullPointerException("destinationMap should not be null");
} else if( nameMapping == null ) {
throw new NullPointerException("nameMapping should not be null");
} else if( sourceList == null ) {
throw new NullPointerException("sourceList should not be null");
} else if( nameMapping.length != sourceList.size() ) {
throw new SuperCsvException(
String
.format(
"the nameMapping array and the sourceList should be the same size (nameMapping length = %d, sourceList size = %d)",
nameMapping.length, sourceList.size()));
}
destinationMap.clear();
for( int i = 0; i < nameMapping.length; i++ ) {
final String key = nameMapping[i];
if( key == null ) {
continue; // null's in the name mapping means skip column
}
// no duplicates allowed
if( destinationMap.containsKey(key) ) {
throw new SuperCsvException(String.format("duplicate nameMapping '%s' at index %d", key, i));
}
destinationMap.put(key, sourceList.get(i));
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"filterListToMap",
"(",
"final",
"Map",
"<",
"String",
",",
"T",
">",
"destinationMap",
",",
"final",
"String",
"[",
"]",
"nameMapping",
",",
"final",
"List",
"<",
"?",
"extends",
"T",
">",
"sourceList",
")",
... | Converts a List to a Map using the elements of the nameMapping array as the keys of the Map.
@param destinationMap
the destination Map (which is cleared before it's populated)
@param nameMapping
the keys of the Map (corresponding with the elements in the sourceList). Cannot contain duplicates.
@param sourceList
the List to convert
@param <T>
the type of the values in the map
@throws NullPointerException
if destinationMap, nameMapping or sourceList are null
@throws SuperCsvException
if nameMapping and sourceList are not the same size | [
"Converts",
"a",
"List",
"to",
"a",
"Map",
"using",
"the",
"elements",
"of",
"the",
"nameMapping",
"array",
"as",
"the",
"keys",
"of",
"the",
"Map",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/Util.java#L114-L146 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/Util.java | Util.filterMapToList | public static List<Object> filterMapToList(final Map<String, ?> map, final String[] nameMapping) {
if( map == null ) {
throw new NullPointerException("map should not be null");
} else if( nameMapping == null ) {
throw new NullPointerException("nameMapping should not be null");
}
final List<Object> result = new ArrayList<Object>(nameMapping.length);
for( final String key : nameMapping ) {
result.add(map.get(key));
}
return result;
} | java | public static List<Object> filterMapToList(final Map<String, ?> map, final String[] nameMapping) {
if( map == null ) {
throw new NullPointerException("map should not be null");
} else if( nameMapping == null ) {
throw new NullPointerException("nameMapping should not be null");
}
final List<Object> result = new ArrayList<Object>(nameMapping.length);
for( final String key : nameMapping ) {
result.add(map.get(key));
}
return result;
} | [
"public",
"static",
"List",
"<",
"Object",
">",
"filterMapToList",
"(",
"final",
"Map",
"<",
"String",
",",
"?",
">",
"map",
",",
"final",
"String",
"[",
"]",
"nameMapping",
")",
"{",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPoi... | Returns a List of all of the values in the Map whose key matches an entry in the nameMapping array.
@param map
the map
@param nameMapping
the keys of the Map values to add to the List
@return a List of all of the values in the Map whose key matches an entry in the nameMapping array
@throws NullPointerException
if map or nameMapping is null | [
"Returns",
"a",
"List",
"of",
"all",
"of",
"the",
"values",
"in",
"the",
"Map",
"whose",
"key",
"matches",
"an",
"entry",
"in",
"the",
"nameMapping",
"array",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/Util.java#L159-L171 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/Util.java | Util.filterMapToObjectArray | public static Object[] filterMapToObjectArray(final Map<String, ?> values, final String[] nameMapping) {
if( values == null ) {
throw new NullPointerException("values should not be null");
} else if( nameMapping == null ) {
throw new NullPointerException("nameMapping should not be null");
}
final Object[] targetArray = new Object[nameMapping.length];
int i = 0;
for( final String name : nameMapping ) {
targetArray[i++] = values.get(name);
}
return targetArray;
} | java | public static Object[] filterMapToObjectArray(final Map<String, ?> values, final String[] nameMapping) {
if( values == null ) {
throw new NullPointerException("values should not be null");
} else if( nameMapping == null ) {
throw new NullPointerException("nameMapping should not be null");
}
final Object[] targetArray = new Object[nameMapping.length];
int i = 0;
for( final String name : nameMapping ) {
targetArray[i++] = values.get(name);
}
return targetArray;
} | [
"public",
"static",
"Object",
"[",
"]",
"filterMapToObjectArray",
"(",
"final",
"Map",
"<",
"String",
",",
"?",
">",
"values",
",",
"final",
"String",
"[",
"]",
"nameMapping",
")",
"{",
"if",
"(",
"values",
"==",
"null",
")",
"{",
"throw",
"new",
"Null... | Converts a Map to an array of objects, adding only those entries whose key is in the nameMapping array.
@param values
the Map of values to convert
@param nameMapping
the keys to extract from the Map (elements in the target array will be added in this order)
@return the array of Objects
@throws NullPointerException
if values or nameMapping is null | [
"Converts",
"a",
"Map",
"to",
"an",
"array",
"of",
"objects",
"adding",
"only",
"those",
"entries",
"whose",
"key",
"is",
"in",
"the",
"nameMapping",
"array",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/Util.java#L184-L198 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/constraint/IsIncludedIn.java | IsIncludedIn.checkPreconditions | private static void checkPreconditions(final Set<Object> possibleValues) {
if( possibleValues == null ) {
throw new NullPointerException("possibleValues Set should not be null");
} else if( possibleValues.isEmpty() ) {
throw new IllegalArgumentException("possibleValues Set should not be empty");
}
} | java | private static void checkPreconditions(final Set<Object> possibleValues) {
if( possibleValues == null ) {
throw new NullPointerException("possibleValues Set should not be null");
} else if( possibleValues.isEmpty() ) {
throw new IllegalArgumentException("possibleValues Set should not be empty");
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"final",
"Set",
"<",
"Object",
">",
"possibleValues",
")",
"{",
"if",
"(",
"possibleValues",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"possibleValues Set should not be null\"",
")"... | Checks the preconditions for creating a new IsIncludedIn processor with a Set of Objects.
@param possibleValues
the Set of possible values
@throws NullPointerException
if possibleValues is null
@throws IllegalArgumentException
if possibleValues is empty | [
"Checks",
"the",
"preconditions",
"for",
"creating",
"a",
"new",
"IsIncludedIn",
"processor",
"with",
"a",
"Set",
"of",
"Objects",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/constraint/IsIncludedIn.java#L128-L134 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/Truncate.java | Truncate.checkPreconditions | private static void checkPreconditions(final int maxSize, final String suffix) {
if( maxSize <= 0 ) {
throw new IllegalArgumentException(String.format("maxSize should be > 0 but was %d", maxSize));
}
if( suffix == null ) {
throw new NullPointerException("suffix should not be null");
}
} | java | private static void checkPreconditions(final int maxSize, final String suffix) {
if( maxSize <= 0 ) {
throw new IllegalArgumentException(String.format("maxSize should be > 0 but was %d", maxSize));
}
if( suffix == null ) {
throw new NullPointerException("suffix should not be null");
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"final",
"int",
"maxSize",
",",
"final",
"String",
"suffix",
")",
"{",
"if",
"(",
"maxSize",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"maxSiz... | Checks the preconditions for creating a new Truncate processor.
@param maxSize
the maximum size of the String
@param suffix
the String to append if the input is truncated (e.g. "...")
@throws IllegalArgumentException
if {@code maxSize <= 0}
@throws NullPointerException
if suffix is null | [
"Checks",
"the",
"preconditions",
"for",
"creating",
"a",
"new",
"Truncate",
"processor",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/Truncate.java#L128-L135 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/io/AbstractCsvWriter.java | AbstractCsvWriter.writeRow | protected void writeRow(final String... columns) throws IOException {
if( columns == null ) {
throw new NullPointerException(String.format("columns to write should not be null on line %d", lineNumber));
} else if( columns.length == 0 ) {
throw new IllegalArgumentException(String.format("columns to write should not be empty on line %d",
lineNumber));
}
StringBuilder builder = new StringBuilder();
for( int i = 0; i < columns.length; i++ ) {
columnNumber = i + 1; // column no used by CsvEncoder
if( i > 0 ) {
builder.append((char) preference.getDelimiterChar()); // delimiter
}
final String csvElement = columns[i];
if( csvElement != null ) {
final CsvContext context = new CsvContext(lineNumber, rowNumber, columnNumber);
final String escapedCsv = encoder.encode(csvElement, context, preference);
builder.append(escapedCsv);
lineNumber = context.getLineNumber(); // line number can increment when encoding multi-line columns
}
}
builder.append(preference.getEndOfLineSymbols()); // EOL
writer.write(builder.toString());
} | java | protected void writeRow(final String... columns) throws IOException {
if( columns == null ) {
throw new NullPointerException(String.format("columns to write should not be null on line %d", lineNumber));
} else if( columns.length == 0 ) {
throw new IllegalArgumentException(String.format("columns to write should not be empty on line %d",
lineNumber));
}
StringBuilder builder = new StringBuilder();
for( int i = 0; i < columns.length; i++ ) {
columnNumber = i + 1; // column no used by CsvEncoder
if( i > 0 ) {
builder.append((char) preference.getDelimiterChar()); // delimiter
}
final String csvElement = columns[i];
if( csvElement != null ) {
final CsvContext context = new CsvContext(lineNumber, rowNumber, columnNumber);
final String escapedCsv = encoder.encode(csvElement, context, preference);
builder.append(escapedCsv);
lineNumber = context.getLineNumber(); // line number can increment when encoding multi-line columns
}
}
builder.append(preference.getEndOfLineSymbols()); // EOL
writer.write(builder.toString());
} | [
"protected",
"void",
"writeRow",
"(",
"final",
"String",
"...",
"columns",
")",
"throws",
"IOException",
"{",
"if",
"(",
"columns",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"String",
".",
"format",
"(",
"\"columns to write should not ... | Writes one or more String columns as a line to the CsvWriter.
@param columns
the columns to write
@throws IllegalArgumentException
if columns.length == 0
@throws IOException
If an I/O error occurs
@throws NullPointerException
if columns is null | [
"Writes",
"one",
"or",
"more",
"String",
"columns",
"as",
"a",
"line",
"to",
"the",
"CsvWriter",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/io/AbstractCsvWriter.java#L174-L204 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/HashMapper.java | HashMapper.checkPreconditions | private static void checkPreconditions(final Map<Object, Object> mapping) {
if( mapping == null ) {
throw new NullPointerException("mapping should not be null");
} else if( mapping.isEmpty() ) {
throw new IllegalArgumentException("mapping should not be empty");
}
} | java | private static void checkPreconditions(final Map<Object, Object> mapping) {
if( mapping == null ) {
throw new NullPointerException("mapping should not be null");
} else if( mapping.isEmpty() ) {
throw new IllegalArgumentException("mapping should not be empty");
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"final",
"Map",
"<",
"Object",
",",
"Object",
">",
"mapping",
")",
"{",
"if",
"(",
"mapping",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"mapping should not be null\"",
")",
";... | Checks the preconditions for creating a new HashMapper processor.
@param mapping
the Map
@throws NullPointerException
if mapping is null
@throws IllegalArgumentException
if mapping is empty | [
"Checks",
"the",
"preconditions",
"for",
"creating",
"a",
"new",
"HashMapper",
"processor",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/HashMapper.java#L134-L140 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/ParseDateTimeAbstract.java | ParseDateTimeAbstract.checkPreconditions | private static void checkPreconditions(final String dateFormat, final Locale locale) {
if( dateFormat == null ) {
throw new NullPointerException("dateFormat should not be null");
} else if( locale == null ) {
throw new NullPointerException("locale should not be null");
}
} | java | private static void checkPreconditions(final String dateFormat, final Locale locale) {
if( dateFormat == null ) {
throw new NullPointerException("dateFormat should not be null");
} else if( locale == null ) {
throw new NullPointerException("locale should not be null");
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"final",
"String",
"dateFormat",
",",
"final",
"Locale",
"locale",
")",
"{",
"if",
"(",
"dateFormat",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"dateFormat should not be null\"",
... | Checks the preconditions for creating a new ParseDateTimeAbstract processor with date format and locale.
@param dateFormat
the date format to use
@param locale
the Locale used to parse the date
@throws NullPointerException
if dateFormat or locale is null | [
"Checks",
"the",
"preconditions",
"for",
"creating",
"a",
"new",
"ParseDateTimeAbstract",
"processor",
"with",
"date",
"format",
"and",
"locale",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/ParseDateTimeAbstract.java#L196-L202 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/StrReplace.java | StrReplace.checkPreconditions | private static void checkPreconditions(final String regex, final String replacement) {
if( regex == null ) {
throw new NullPointerException("regex should not be null");
} else if( regex.length() == 0 ) {
throw new IllegalArgumentException("regex should not be empty");
}
if( replacement == null ) {
throw new NullPointerException("replacement should not be null");
}
} | java | private static void checkPreconditions(final String regex, final String replacement) {
if( regex == null ) {
throw new NullPointerException("regex should not be null");
} else if( regex.length() == 0 ) {
throw new IllegalArgumentException("regex should not be empty");
}
if( replacement == null ) {
throw new NullPointerException("replacement should not be null");
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"final",
"String",
"regex",
",",
"final",
"String",
"replacement",
")",
"{",
"if",
"(",
"regex",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"regex should not be null\"",
")",
";"... | Checks the preconditions for creating a new StrRegExReplace processor.
@param regex
the supplied regular expression
@param replacement
the supplied replacement text
@throws IllegalArgumentException
if regex is empty
@throws NullPointerException
if regex or replacement is null | [
"Checks",
"the",
"preconditions",
"for",
"creating",
"a",
"new",
"StrRegExReplace",
"processor",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/StrReplace.java#L101-L111 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/TwoDHashMap.java | TwoDHashMap.get | public V get(final K1 firstKey, final K2 secondKey) {
// existence check on inner map
final HashMap<K2, V> innerMap = map.get(firstKey);
if( innerMap == null ) {
return null;
}
return innerMap.get(secondKey);
} | java | public V get(final K1 firstKey, final K2 secondKey) {
// existence check on inner map
final HashMap<K2, V> innerMap = map.get(firstKey);
if( innerMap == null ) {
return null;
}
return innerMap.get(secondKey);
} | [
"public",
"V",
"get",
"(",
"final",
"K1",
"firstKey",
",",
"final",
"K2",
"secondKey",
")",
"{",
"// existence check on inner map",
"final",
"HashMap",
"<",
"K2",
",",
"V",
">",
"innerMap",
"=",
"map",
".",
"get",
"(",
"firstKey",
")",
";",
"if",
"(",
... | Fetch a value from the Hashmap .
@param firstKey
first key
@param secondKey
second key
@return the element or null. | [
"Fetch",
"a",
"value",
"from",
"the",
"Hashmap",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/TwoDHashMap.java#L88-L95 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/MethodCache.java | MethodCache.getGetMethod | public Method getGetMethod(final Object object, final String fieldName) {
if( object == null ) {
throw new NullPointerException("object should not be null");
} else if( fieldName == null ) {
throw new NullPointerException("fieldName should not be null");
}
Method method = getCache.get(object.getClass().getName(), fieldName);
if( method == null ) {
method = ReflectionUtils.findGetter(object, fieldName);
getCache.set(object.getClass().getName(), fieldName, method);
}
return method;
} | java | public Method getGetMethod(final Object object, final String fieldName) {
if( object == null ) {
throw new NullPointerException("object should not be null");
} else if( fieldName == null ) {
throw new NullPointerException("fieldName should not be null");
}
Method method = getCache.get(object.getClass().getName(), fieldName);
if( method == null ) {
method = ReflectionUtils.findGetter(object, fieldName);
getCache.set(object.getClass().getName(), fieldName, method);
}
return method;
} | [
"public",
"Method",
"getGetMethod",
"(",
"final",
"Object",
"object",
",",
"final",
"String",
"fieldName",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"object should not be null\"",
")",
";",
"}",
"else... | Returns the getter method for field on an object.
@param object
the object
@param fieldName
the field name
@return the getter associated with the field on the object
@throws NullPointerException
if object or fieldName is null
@throws SuperCsvReflectionException
if the getter doesn't exist or is not visible | [
"Returns",
"the",
"getter",
"method",
"for",
"field",
"on",
"an",
"object",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/MethodCache.java#L53-L66 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/MethodCache.java | MethodCache.getSetMethod | public <T> Method getSetMethod(final Object object, final String fieldName, final Class<?> argumentType) {
if( object == null ) {
throw new NullPointerException("object should not be null");
} else if( fieldName == null ) {
throw new NullPointerException("fieldName should not be null");
} else if( argumentType == null ) {
throw new NullPointerException("argumentType should not be null");
}
Method method = setMethodsCache.get(object.getClass(), argumentType, fieldName);
if( method == null ) {
method = ReflectionUtils.findSetter(object, fieldName, argumentType);
setMethodsCache.set(object.getClass(), argumentType, fieldName, method);
}
return method;
} | java | public <T> Method getSetMethod(final Object object, final String fieldName, final Class<?> argumentType) {
if( object == null ) {
throw new NullPointerException("object should not be null");
} else if( fieldName == null ) {
throw new NullPointerException("fieldName should not be null");
} else if( argumentType == null ) {
throw new NullPointerException("argumentType should not be null");
}
Method method = setMethodsCache.get(object.getClass(), argumentType, fieldName);
if( method == null ) {
method = ReflectionUtils.findSetter(object, fieldName, argumentType);
setMethodsCache.set(object.getClass(), argumentType, fieldName, method);
}
return method;
} | [
"public",
"<",
"T",
">",
"Method",
"getSetMethod",
"(",
"final",
"Object",
"object",
",",
"final",
"String",
"fieldName",
",",
"final",
"Class",
"<",
"?",
">",
"argumentType",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"throw",
"new",
"Null... | Returns the setter method for the field on an object.
@param object
the object
@param fieldName
the field name
@param argumentType
the type to be passed to the setter
@param <T>
the object type
@return the setter method associated with the field on the object
@throws NullPointerException
if object, fieldName or fieldType is null
@throws SuperCsvReflectionException
if the setter doesn't exist or is not visible | [
"Returns",
"the",
"setter",
"method",
"for",
"the",
"field",
"on",
"an",
"object",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/MethodCache.java#L85-L100 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/io/CsvBeanReader.java | CsvBeanReader.invokeSetter | private static void invokeSetter(final Object bean, final Method setMethod, final Object fieldValue) {
try {
setMethod.setAccessible(true);
setMethod.invoke(bean, fieldValue);
}
catch(final Exception e) {
throw new SuperCsvReflectionException(String.format("error invoking method %s()", setMethod.getName()), e);
}
} | java | private static void invokeSetter(final Object bean, final Method setMethod, final Object fieldValue) {
try {
setMethod.setAccessible(true);
setMethod.invoke(bean, fieldValue);
}
catch(final Exception e) {
throw new SuperCsvReflectionException(String.format("error invoking method %s()", setMethod.getName()), e);
}
} | [
"private",
"static",
"void",
"invokeSetter",
"(",
"final",
"Object",
"bean",
",",
"final",
"Method",
"setMethod",
",",
"final",
"Object",
"fieldValue",
")",
"{",
"try",
"{",
"setMethod",
".",
"setAccessible",
"(",
"true",
")",
";",
"setMethod",
".",
"invoke"... | Invokes the setter on the bean with the supplied value.
@param bean
the bean
@param setMethod
the setter method for the field
@param fieldValue
the field value to set
@throws SuperCsvException
if there was an exception invoking the setter | [
"Invokes",
"the",
"setter",
"on",
"the",
"bean",
"with",
"the",
"supplied",
"value",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/io/CsvBeanReader.java#L133-L141 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/io/CsvBeanReader.java | CsvBeanReader.populateBean | private <T> T populateBean(final T resultBean, final String[] nameMapping) {
// map each column to its associated field on the bean
for( int i = 0; i < nameMapping.length; i++ ) {
final Object fieldValue = processedColumns.get(i);
// don't call a set-method in the bean if there is no name mapping for the column or no result to store
if( nameMapping[i] == null || fieldValue == null ) {
continue;
}
// invoke the setter on the bean
Method setMethod = cache.getSetMethod(resultBean, nameMapping[i], fieldValue.getClass());
invokeSetter(resultBean, setMethod, fieldValue);
}
return resultBean;
} | java | private <T> T populateBean(final T resultBean, final String[] nameMapping) {
// map each column to its associated field on the bean
for( int i = 0; i < nameMapping.length; i++ ) {
final Object fieldValue = processedColumns.get(i);
// don't call a set-method in the bean if there is no name mapping for the column or no result to store
if( nameMapping[i] == null || fieldValue == null ) {
continue;
}
// invoke the setter on the bean
Method setMethod = cache.getSetMethod(resultBean, nameMapping[i], fieldValue.getClass());
invokeSetter(resultBean, setMethod, fieldValue);
}
return resultBean;
} | [
"private",
"<",
"T",
">",
"T",
"populateBean",
"(",
"final",
"T",
"resultBean",
",",
"final",
"String",
"[",
"]",
"nameMapping",
")",
"{",
"// map each column to its associated field on the bean",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nameMapping",... | Populates the bean by mapping the processed columns to the fields of the bean.
@param resultBean
the bean to populate
@param nameMapping
the name mappings
@return the populated bean
@throws SuperCsvReflectionException
if there was a reflection exception while populating the bean | [
"Populates",
"the",
"bean",
"by",
"mapping",
"the",
"processed",
"columns",
"to",
"the",
"fields",
"of",
"the",
"bean",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/io/CsvBeanReader.java#L154-L173 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/io/CsvBeanReader.java | CsvBeanReader.readIntoBean | private <T> T readIntoBean(final T bean, final String[] nameMapping, final CellProcessor[] processors)
throws IOException {
if( readRow() ) {
if( nameMapping.length != length() ) {
throw new IllegalArgumentException(String.format(
"the nameMapping array and the number of columns read "
+ "should be the same size (nameMapping length = %d, columns = %d)", nameMapping.length,
length()));
}
if( processors == null ) {
processedColumns.clear();
processedColumns.addAll(getColumns());
} else {
executeProcessors(processedColumns, processors);
}
return populateBean(bean, nameMapping);
}
return null; // EOF
} | java | private <T> T readIntoBean(final T bean, final String[] nameMapping, final CellProcessor[] processors)
throws IOException {
if( readRow() ) {
if( nameMapping.length != length() ) {
throw new IllegalArgumentException(String.format(
"the nameMapping array and the number of columns read "
+ "should be the same size (nameMapping length = %d, columns = %d)", nameMapping.length,
length()));
}
if( processors == null ) {
processedColumns.clear();
processedColumns.addAll(getColumns());
} else {
executeProcessors(processedColumns, processors);
}
return populateBean(bean, nameMapping);
}
return null; // EOF
} | [
"private",
"<",
"T",
">",
"T",
"readIntoBean",
"(",
"final",
"T",
"bean",
",",
"final",
"String",
"[",
"]",
"nameMapping",
",",
"final",
"CellProcessor",
"[",
"]",
"processors",
")",
"throws",
"IOException",
"{",
"if",
"(",
"readRow",
"(",
")",
")",
"{... | Reads a row of a CSV file and populates the bean, using the supplied name mapping to map column values to the
appropriate fields. If processors are supplied then they are used, otherwise the raw String values will be used.
@param bean
the bean to populate
@param nameMapping
the name mapping array
@param processors
the (optional) cell processors
@return the populated bean, or null if EOF was reached
@throws IllegalArgumentException
if nameMapping.length != number of CSV columns read
@throws IOException
if an I/O error occurred
@throws NullPointerException
if bean or nameMapping are null
@throws SuperCsvConstraintViolationException
if a CellProcessor constraint failed
@throws SuperCsvException
if there was a general exception while reading/processing
@throws SuperCsvReflectionException
if there was an reflection exception while mapping the values to the bean | [
"Reads",
"a",
"row",
"of",
"a",
"CSV",
"file",
"and",
"populates",
"the",
"bean",
"using",
"the",
"supplied",
"name",
"mapping",
"to",
"map",
"column",
"values",
"to",
"the",
"appropriate",
"fields",
".",
"If",
"processors",
"are",
"supplied",
"then",
"the... | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/io/CsvBeanReader.java#L259-L281 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/constraint/Strlen.java | Strlen.checkAndAddLengths | private void checkAndAddLengths(final int... requiredLengths) {
for( final int length : requiredLengths ) {
if( length < 0 ) {
throw new IllegalArgumentException(String.format("required length cannot be negative but was %d",
length));
}
this.requiredLengths.add(length);
}
} | java | private void checkAndAddLengths(final int... requiredLengths) {
for( final int length : requiredLengths ) {
if( length < 0 ) {
throw new IllegalArgumentException(String.format("required length cannot be negative but was %d",
length));
}
this.requiredLengths.add(length);
}
} | [
"private",
"void",
"checkAndAddLengths",
"(",
"final",
"int",
"...",
"requiredLengths",
")",
"{",
"for",
"(",
"final",
"int",
"length",
":",
"requiredLengths",
")",
"{",
"if",
"(",
"length",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"("... | Adds each required length, ensuring it isn't negative.
@param requiredLengths
one or more required lengths
@throws IllegalArgumentException
if a supplied length is negative | [
"Adds",
"each",
"required",
"length",
"ensuring",
"it",
"isn",
"t",
"negative",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/constraint/Strlen.java#L119-L127 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/constraint/RequireSubStr.java | RequireSubStr.checkPreconditions | private static void checkPreconditions(List<String> requiredSubStrings) {
if( requiredSubStrings == null ) {
throw new NullPointerException("requiredSubStrings List should not be null");
} else if( requiredSubStrings.isEmpty() ) {
throw new IllegalArgumentException("requiredSubStrings List should not be empty");
}
} | java | private static void checkPreconditions(List<String> requiredSubStrings) {
if( requiredSubStrings == null ) {
throw new NullPointerException("requiredSubStrings List should not be null");
} else if( requiredSubStrings.isEmpty() ) {
throw new IllegalArgumentException("requiredSubStrings List should not be empty");
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"List",
"<",
"String",
">",
"requiredSubStrings",
")",
"{",
"if",
"(",
"requiredSubStrings",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"requiredSubStrings List should not be null\"",
... | Checks the preconditions for creating a new RequireSubStr processor with a List of Strings.
@param requiredSubStrings
the required substrings
@throws NullPointerException
if requiredSubStrings or one of its elements is null
@throws IllegalArgumentException
if requiredSubStrings is empty | [
"Checks",
"the",
"preconditions",
"for",
"creating",
"a",
"new",
"RequireSubStr",
"processor",
"with",
"a",
"List",
"of",
"Strings",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/constraint/RequireSubStr.java#L139-L145 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/constraint/RequireSubStr.java | RequireSubStr.checkAndAddRequiredSubStrings | private void checkAndAddRequiredSubStrings(final List<String> requiredSubStrings) {
for( String required : requiredSubStrings ) {
if( required == null ) {
throw new NullPointerException("required substring should not be null");
}
this.requiredSubStrings.add(required);
}
} | java | private void checkAndAddRequiredSubStrings(final List<String> requiredSubStrings) {
for( String required : requiredSubStrings ) {
if( required == null ) {
throw new NullPointerException("required substring should not be null");
}
this.requiredSubStrings.add(required);
}
} | [
"private",
"void",
"checkAndAddRequiredSubStrings",
"(",
"final",
"List",
"<",
"String",
">",
"requiredSubStrings",
")",
"{",
"for",
"(",
"String",
"required",
":",
"requiredSubStrings",
")",
"{",
"if",
"(",
"required",
"==",
"null",
")",
"{",
"throw",
"new",
... | Adds each required substring, checking that it's not null.
@param requiredSubStrings
the required substrings
@throws NullPointerException
if a required substring is null | [
"Adds",
"each",
"required",
"substring",
"checking",
"that",
"it",
"s",
"not",
"null",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/constraint/RequireSubStr.java#L155-L162 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/constraint/ForbidSubStr.java | ForbidSubStr.checkPreconditions | private static void checkPreconditions(final List<String> forbiddenSubStrings) {
if( forbiddenSubStrings == null ) {
throw new NullPointerException("forbiddenSubStrings list should not be null");
} else if( forbiddenSubStrings.isEmpty() ) {
throw new IllegalArgumentException("forbiddenSubStrings list should not be empty");
}
} | java | private static void checkPreconditions(final List<String> forbiddenSubStrings) {
if( forbiddenSubStrings == null ) {
throw new NullPointerException("forbiddenSubStrings list should not be null");
} else if( forbiddenSubStrings.isEmpty() ) {
throw new IllegalArgumentException("forbiddenSubStrings list should not be empty");
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"final",
"List",
"<",
"String",
">",
"forbiddenSubStrings",
")",
"{",
"if",
"(",
"forbiddenSubStrings",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"forbiddenSubStrings list should not ... | Checks the preconditions for creating a new ForbidSubStr processor with a List of forbidden substrings.
@param forbiddenSubStrings
the forbidden substrings
@throws NullPointerException
if forbiddenSubStrings is null
@throws IllegalArgumentException
if forbiddenSubStrings is empty | [
"Checks",
"the",
"preconditions",
"for",
"creating",
"a",
"new",
"ForbidSubStr",
"processor",
"with",
"a",
"List",
"of",
"forbidden",
"substrings",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/constraint/ForbidSubStr.java#L138-L144 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/constraint/ForbidSubStr.java | ForbidSubStr.checkAndAddForbiddenStrings | private void checkAndAddForbiddenStrings(final List<String> forbiddenSubStrings) {
for( String forbidden : forbiddenSubStrings ) {
if( forbidden == null ) {
throw new NullPointerException("forbidden substring should not be null");
}
this.forbiddenSubStrings.add(forbidden);
}
} | java | private void checkAndAddForbiddenStrings(final List<String> forbiddenSubStrings) {
for( String forbidden : forbiddenSubStrings ) {
if( forbidden == null ) {
throw new NullPointerException("forbidden substring should not be null");
}
this.forbiddenSubStrings.add(forbidden);
}
} | [
"private",
"void",
"checkAndAddForbiddenStrings",
"(",
"final",
"List",
"<",
"String",
">",
"forbiddenSubStrings",
")",
"{",
"for",
"(",
"String",
"forbidden",
":",
"forbiddenSubStrings",
")",
"{",
"if",
"(",
"forbidden",
"==",
"null",
")",
"{",
"throw",
"new"... | Adds each forbidden substring, checking that it's not null.
@param forbiddenSubStrings
the forbidden substrings
@throws NullPointerException
if a forbidden substring is null | [
"Adds",
"each",
"forbidden",
"substring",
"checking",
"that",
"it",
"s",
"not",
"null",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/constraint/ForbidSubStr.java#L184-L191 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/ThreeDHashMap.java | ThreeDHashMap.get | public HashMap<K2, HashMap<K3, V>> get(final K1 firstKey) {
return map.get(firstKey);
} | java | public HashMap<K2, HashMap<K3, V>> get(final K1 firstKey) {
return map.get(firstKey);
} | [
"public",
"HashMap",
"<",
"K2",
",",
"HashMap",
"<",
"K3",
",",
"V",
">",
">",
"get",
"(",
"final",
"K1",
"firstKey",
")",
"{",
"return",
"map",
".",
"get",
"(",
"firstKey",
")",
";",
"}"
] | Fetch the outermost Hashmap.
@param firstKey
first key
@return the the innermost hashmap | [
"Fetch",
"the",
"outermost",
"Hashmap",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/ThreeDHashMap.java#L92-L94 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/ThreeDHashMap.java | ThreeDHashMap.getAs2d | public TwoDHashMap<K2, K3, V> getAs2d(final K1 firstKey) {
final HashMap<K2, HashMap<K3, V>> innerMap1 = map.get(firstKey);
if( innerMap1 != null ) {
return new TwoDHashMap<K2, K3, V>(innerMap1);
} else {
return new TwoDHashMap<K2, K3, V>();
}
} | java | public TwoDHashMap<K2, K3, V> getAs2d(final K1 firstKey) {
final HashMap<K2, HashMap<K3, V>> innerMap1 = map.get(firstKey);
if( innerMap1 != null ) {
return new TwoDHashMap<K2, K3, V>(innerMap1);
} else {
return new TwoDHashMap<K2, K3, V>();
}
} | [
"public",
"TwoDHashMap",
"<",
"K2",
",",
"K3",
",",
"V",
">",
"getAs2d",
"(",
"final",
"K1",
"firstKey",
")",
"{",
"final",
"HashMap",
"<",
"K2",
",",
"HashMap",
"<",
"K3",
",",
"V",
">",
">",
"innerMap1",
"=",
"map",
".",
"get",
"(",
"firstKey",
... | Fetch the outermost Hashmap as a TwoDHashMap.
@param firstKey
first key
@return the the innermost hashmap | [
"Fetch",
"the",
"outermost",
"Hashmap",
"as",
"a",
"TwoDHashMap",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/ThreeDHashMap.java#L103-L111 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/ThreeDHashMap.java | ThreeDHashMap.size | public int size(final K1 firstKey) {
// existence check on inner map
final HashMap<K2, HashMap<K3, V>> innerMap = map.get(firstKey);
if( innerMap == null ) {
return 0;
}
return innerMap.size();
} | java | public int size(final K1 firstKey) {
// existence check on inner map
final HashMap<K2, HashMap<K3, V>> innerMap = map.get(firstKey);
if( innerMap == null ) {
return 0;
}
return innerMap.size();
} | [
"public",
"int",
"size",
"(",
"final",
"K1",
"firstKey",
")",
"{",
"// existence check on inner map",
"final",
"HashMap",
"<",
"K2",
",",
"HashMap",
"<",
"K3",
",",
"V",
">",
">",
"innerMap",
"=",
"map",
".",
"get",
"(",
"firstKey",
")",
";",
"if",
"("... | Returns the number of key-value mappings in this map for the second key.
@param firstKey
the first key
@return Returns the number of key-value mappings in this map for the second key. | [
"Returns",
"the",
"number",
"of",
"key",
"-",
"value",
"mappings",
"in",
"this",
"map",
"for",
"the",
"second",
"key",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/ThreeDHashMap.java#L208-L215 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/ThreeDHashMap.java | ThreeDHashMap.size | public int size(final K1 firstKey, final K2 secondKey) {
// existence check on inner map
final HashMap<K2, HashMap<K3, V>> innerMap1 = map.get(firstKey);
if( innerMap1 == null ) {
return 0;
}
// existence check on inner map1
final HashMap<K3, V> innerMap2 = innerMap1.get(secondKey);
if( innerMap2 == null ) {
return 0;
}
return innerMap2.size();
} | java | public int size(final K1 firstKey, final K2 secondKey) {
// existence check on inner map
final HashMap<K2, HashMap<K3, V>> innerMap1 = map.get(firstKey);
if( innerMap1 == null ) {
return 0;
}
// existence check on inner map1
final HashMap<K3, V> innerMap2 = innerMap1.get(secondKey);
if( innerMap2 == null ) {
return 0;
}
return innerMap2.size();
} | [
"public",
"int",
"size",
"(",
"final",
"K1",
"firstKey",
",",
"final",
"K2",
"secondKey",
")",
"{",
"// existence check on inner map",
"final",
"HashMap",
"<",
"K2",
",",
"HashMap",
"<",
"K3",
",",
"V",
">",
">",
"innerMap1",
"=",
"map",
".",
"get",
"(",... | Returns the number of key-value mappings in this map for the third key.
@param firstKey
the first key
@param secondKey
the second key
@return Returns the number of key-value mappings in this map for the third key. | [
"Returns",
"the",
"number",
"of",
"key",
"-",
"value",
"mappings",
"in",
"this",
"map",
"for",
"the",
"third",
"key",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/ThreeDHashMap.java#L226-L239 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/util/BeanInterfaceProxy.java | BeanInterfaceProxy.createProxy | public static <T> T createProxy(final Class<T> proxyInterface) {
if( proxyInterface == null ) {
throw new NullPointerException("proxyInterface should not be null");
}
return proxyInterface.cast(Proxy.newProxyInstance(proxyInterface.getClassLoader(),
new Class[] { proxyInterface }, new BeanInterfaceProxy()));
} | java | public static <T> T createProxy(final Class<T> proxyInterface) {
if( proxyInterface == null ) {
throw new NullPointerException("proxyInterface should not be null");
}
return proxyInterface.cast(Proxy.newProxyInstance(proxyInterface.getClassLoader(),
new Class[] { proxyInterface }, new BeanInterfaceProxy()));
} | [
"public",
"static",
"<",
"T",
">",
"T",
"createProxy",
"(",
"final",
"Class",
"<",
"T",
">",
"proxyInterface",
")",
"{",
"if",
"(",
"proxyInterface",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"proxyInterface should not be null\"",
... | Creates a proxy object which implements a given bean interface.
@param proxyInterface
the interface the the proxy will implement
@param <T>
the proxy implementation type
@return the proxy implementation
@throws NullPointerException
if proxyInterface is null | [
"Creates",
"a",
"proxy",
"object",
"which",
"implements",
"a",
"given",
"bean",
"interface",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/util/BeanInterfaceProxy.java#L57-L63 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/exception/SuperCsvCellProcessorException.java | SuperCsvCellProcessorException.getUnexpectedTypeMessage | private static String getUnexpectedTypeMessage(final Class<?> expectedType, final Object actualValue) {
if( expectedType == null ) {
throw new NullPointerException("expectedType should not be null");
}
String expectedClassName = expectedType.getName();
String actualClassName = (actualValue != null) ? actualValue.getClass().getName() : "null";
return String.format("the input value should be of type %s but is %s", expectedClassName, actualClassName);
} | java | private static String getUnexpectedTypeMessage(final Class<?> expectedType, final Object actualValue) {
if( expectedType == null ) {
throw new NullPointerException("expectedType should not be null");
}
String expectedClassName = expectedType.getName();
String actualClassName = (actualValue != null) ? actualValue.getClass().getName() : "null";
return String.format("the input value should be of type %s but is %s", expectedClassName, actualClassName);
} | [
"private",
"static",
"String",
"getUnexpectedTypeMessage",
"(",
"final",
"Class",
"<",
"?",
">",
"expectedType",
",",
"final",
"Object",
"actualValue",
")",
"{",
"if",
"(",
"expectedType",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\... | Assembles the exception message when the value received by a CellProcessor isn't of the correct type.
@param expectedType
the expected type
@param actualValue
the value received by the CellProcessor
@return the message
@throws NullPointerException
if expectedType is null | [
"Assembles",
"the",
"exception",
"message",
"when",
"the",
"value",
"received",
"by",
"a",
"CellProcessor",
"isn",
"t",
"of",
"the",
"correct",
"type",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/exception/SuperCsvCellProcessorException.java#L97-L104 | train |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/io/AbstractCsvReader.java | AbstractCsvReader.executeProcessors | protected List<Object> executeProcessors(final List<Object> processedColumns, final CellProcessor[] processors) {
Util.executeCellProcessors(processedColumns, getColumns(), processors, getLineNumber(), getRowNumber());
return processedColumns;
} | java | protected List<Object> executeProcessors(final List<Object> processedColumns, final CellProcessor[] processors) {
Util.executeCellProcessors(processedColumns, getColumns(), processors, getLineNumber(), getRowNumber());
return processedColumns;
} | [
"protected",
"List",
"<",
"Object",
">",
"executeProcessors",
"(",
"final",
"List",
"<",
"Object",
">",
"processedColumns",
",",
"final",
"CellProcessor",
"[",
"]",
"processors",
")",
"{",
"Util",
".",
"executeCellProcessors",
"(",
"processedColumns",
",",
"getC... | Executes the supplied cell processors on the last row of CSV that was read and populates the supplied List of
processed columns.
@param processedColumns
the List to populate with processed columns
@param processors
the cell processors
@return the updated List
@throws NullPointerException
if processedColumns or processors is null
@throws SuperCsvConstraintViolationException
if a CellProcessor constraint failed
@throws SuperCsvException
if the wrong number of processors are supplied, or CellProcessor execution failed | [
"Executes",
"the",
"supplied",
"cell",
"processors",
"on",
"the",
"last",
"row",
"of",
"CSV",
"that",
"was",
"read",
"and",
"populates",
"the",
"supplied",
"List",
"of",
"processed",
"columns",
"."
] | f18db724674dc1c4116e25142c1b5403ebf43e96 | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/io/AbstractCsvReader.java#L202-L205 | train |
bwaldvogel/mongo-java-server | core/src/main/java/de/bwaldvogel/mongo/MongoServer.java | MongoServer.stopListenting | public void stopListenting() {
if (channel != null) {
log.info("closing server channel");
channel.close().syncUninterruptibly();
channel = null;
}
} | java | public void stopListenting() {
if (channel != null) {
log.info("closing server channel");
channel.close().syncUninterruptibly();
channel = null;
}
} | [
"public",
"void",
"stopListenting",
"(",
")",
"{",
"if",
"(",
"channel",
"!=",
"null",
")",
"{",
"log",
".",
"info",
"(",
"\"closing server channel\"",
")",
";",
"channel",
".",
"close",
"(",
")",
".",
"syncUninterruptibly",
"(",
")",
";",
"channel",
"="... | Closes the server socket. No new clients are accepted afterwards. | [
"Closes",
"the",
"server",
"socket",
".",
"No",
"new",
"clients",
"are",
"accepted",
"afterwards",
"."
] | df0bf7cf5f51ed61cca976cea27026e79ed68d4a | https://github.com/bwaldvogel/mongo-java-server/blob/df0bf7cf5f51ed61cca976cea27026e79ed68d4a/core/src/main/java/de/bwaldvogel/mongo/MongoServer.java#L153-L159 | train |
bwaldvogel/mongo-java-server | core/src/main/java/de/bwaldvogel/mongo/backend/AbstractMongoCollection.java | AbstractMongoCollection.convertSelectorToDocument | Document convertSelectorToDocument(Document selector) {
Document document = new Document();
for (String key : selector.keySet()) {
if (key.startsWith("$")) {
continue;
}
Object value = selector.get(key);
if (!Utils.containsQueryExpression(value)) {
Utils.changeSubdocumentValue(document, key, value, (AtomicReference<Integer>) null);
}
}
return document;
} | java | Document convertSelectorToDocument(Document selector) {
Document document = new Document();
for (String key : selector.keySet()) {
if (key.startsWith("$")) {
continue;
}
Object value = selector.get(key);
if (!Utils.containsQueryExpression(value)) {
Utils.changeSubdocumentValue(document, key, value, (AtomicReference<Integer>) null);
}
}
return document;
} | [
"Document",
"convertSelectorToDocument",
"(",
"Document",
"selector",
")",
"{",
"Document",
"document",
"=",
"new",
"Document",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"selector",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"key",
".",
"starts... | convert selector used in an upsert statement into a document | [
"convert",
"selector",
"used",
"in",
"an",
"upsert",
"statement",
"into",
"a",
"document"
] | df0bf7cf5f51ed61cca976cea27026e79ed68d4a | https://github.com/bwaldvogel/mongo-java-server/blob/df0bf7cf5f51ed61cca976cea27026e79ed68d4a/core/src/main/java/de/bwaldvogel/mongo/backend/AbstractMongoCollection.java#L499-L512 | train |
bwaldvogel/mongo-java-server | core/src/main/java/de/bwaldvogel/mongo/wire/BsonDecoder.java | BsonDecoder.decodeCString | String decodeCString(ByteBuf buffer) throws IOException {
int length = buffer.bytesBefore(BsonConstants.STRING_TERMINATION);
if (length < 0)
throw new IOException("string termination not found");
String result = buffer.toString(buffer.readerIndex(), length, StandardCharsets.UTF_8);
buffer.skipBytes(length + 1);
return result;
} | java | String decodeCString(ByteBuf buffer) throws IOException {
int length = buffer.bytesBefore(BsonConstants.STRING_TERMINATION);
if (length < 0)
throw new IOException("string termination not found");
String result = buffer.toString(buffer.readerIndex(), length, StandardCharsets.UTF_8);
buffer.skipBytes(length + 1);
return result;
} | [
"String",
"decodeCString",
"(",
"ByteBuf",
"buffer",
")",
"throws",
"IOException",
"{",
"int",
"length",
"=",
"buffer",
".",
"bytesBefore",
"(",
"BsonConstants",
".",
"STRING_TERMINATION",
")",
";",
"if",
"(",
"length",
"<",
"0",
")",
"throw",
"new",
"IOExce... | default visibility for unit test | [
"default",
"visibility",
"for",
"unit",
"test"
] | df0bf7cf5f51ed61cca976cea27026e79ed68d4a | https://github.com/bwaldvogel/mongo-java-server/blob/df0bf7cf5f51ed61cca976cea27026e79ed68d4a/core/src/main/java/de/bwaldvogel/mongo/wire/BsonDecoder.java#L142-L150 | train |
FasterXML/jackson-modules-java8 | datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java | InstantDeserializer._countPeriods | protected int _countPeriods(String str)
{
int commas = 0;
for (int i = 0, end = str.length(); i < end; ++i) {
int ch = str.charAt(i);
if (ch < '0' || ch > '9') {
if (ch == '.') {
++commas;
} else {
return -1;
}
}
}
return commas;
} | java | protected int _countPeriods(String str)
{
int commas = 0;
for (int i = 0, end = str.length(); i < end; ++i) {
int ch = str.charAt(i);
if (ch < '0' || ch > '9') {
if (ch == '.') {
++commas;
} else {
return -1;
}
}
}
return commas;
} | [
"protected",
"int",
"_countPeriods",
"(",
"String",
"str",
")",
"{",
"int",
"commas",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"end",
"=",
"str",
".",
"length",
"(",
")",
";",
"i",
"<",
"end",
";",
"++",
"i",
")",
"{",
"int",
"ch... | Helper method to find Strings of form "all digits" and "digits-comma-digits" | [
"Helper",
"method",
"to",
"find",
"Strings",
"of",
"form",
"all",
"digits",
"and",
"digits",
"-",
"comma",
"-",
"digits"
] | bd093eafbd4d5216e13093b0a031e06dcbb8839b | https://github.com/FasterXML/jackson-modules-java8/blob/bd093eafbd4d5216e13093b0a031e06dcbb8839b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java#L253-L267 | train |
FasterXML/jackson-modules-java8 | datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310DeserializerBase.java | JSR310DeserializerBase._peelDTE | protected DateTimeException _peelDTE(DateTimeException e) {
while (true) {
Throwable t = e.getCause();
if (t != null && t instanceof DateTimeException) {
e = (DateTimeException) t;
continue;
}
break;
}
return e;
} | java | protected DateTimeException _peelDTE(DateTimeException e) {
while (true) {
Throwable t = e.getCause();
if (t != null && t instanceof DateTimeException) {
e = (DateTimeException) t;
continue;
}
break;
}
return e;
} | [
"protected",
"DateTimeException",
"_peelDTE",
"(",
"DateTimeException",
"e",
")",
"{",
"while",
"(",
"true",
")",
"{",
"Throwable",
"t",
"=",
"e",
".",
"getCause",
"(",
")",
";",
"if",
"(",
"t",
"!=",
"null",
"&&",
"t",
"instanceof",
"DateTimeException",
... | Helper method used to peel off spurious wrappings of DateTimeException
@param e DateTimeException to peel
@return DateTimeException that does not have another DateTimeException as its cause. | [
"Helper",
"method",
"used",
"to",
"peel",
"off",
"spurious",
"wrappings",
"of",
"DateTimeException"
] | bd093eafbd4d5216e13093b0a031e06dcbb8839b | https://github.com/FasterXML/jackson-modules-java8/blob/bd093eafbd4d5216e13093b0a031e06dcbb8839b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/JSR310DeserializerBase.java#L123-L133 | train |
FasterXML/jackson-modules-java8 | datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializerBase.java | InstantSerializerBase._acceptTimestampVisitor | @Override
protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
SerializerProvider prov = visitor.getProvider();
if ((prov != null) && useNanoseconds(prov)) {
JsonNumberFormatVisitor v2 = visitor.expectNumberFormat(typeHint);
if (v2 != null) {
v2.numberType(NumberType.BIG_DECIMAL);
}
} else {
JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint);
if (v2 != null) {
v2.numberType(NumberType.LONG);
}
}
} | java | @Override
protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
SerializerProvider prov = visitor.getProvider();
if ((prov != null) && useNanoseconds(prov)) {
JsonNumberFormatVisitor v2 = visitor.expectNumberFormat(typeHint);
if (v2 != null) {
v2.numberType(NumberType.BIG_DECIMAL);
}
} else {
JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint);
if (v2 != null) {
v2.numberType(NumberType.LONG);
}
}
} | [
"@",
"Override",
"protected",
"void",
"_acceptTimestampVisitor",
"(",
"JsonFormatVisitorWrapper",
"visitor",
",",
"JavaType",
"typeHint",
")",
"throws",
"JsonMappingException",
"{",
"SerializerProvider",
"prov",
"=",
"visitor",
".",
"getProvider",
"(",
")",
";",
"if",... | Overridden to ensure that our timestamp handling is as expected | [
"Overridden",
"to",
"ensure",
"that",
"our",
"timestamp",
"handling",
"is",
"as",
"expected"
] | bd093eafbd4d5216e13093b0a031e06dcbb8839b | https://github.com/FasterXML/jackson-modules-java8/blob/bd093eafbd4d5216e13093b0a031e06dcbb8839b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/ser/InstantSerializerBase.java#L107-L123 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/util/HyperLinkUtil.java | HyperLinkUtil.applyHyperLinkToElement | public static void applyHyperLinkToElement(DynamicJasperDesign design, DJHyperLink djlink, JRDesignChart chart, String name) {
JRDesignExpression hlpe = ExpressionUtils.createAndRegisterExpression(design, name, djlink.getExpression());
chart.setHyperlinkReferenceExpression(hlpe);
chart.setHyperlinkType( HyperlinkTypeEnum.REFERENCE ); //FIXME Should this be a parameter in the future?
if (djlink.getTooltip() != null){
JRDesignExpression tooltipExp = ExpressionUtils.createAndRegisterExpression(design, "tooltip_" + name, djlink.getTooltip());
chart.setHyperlinkTooltipExpression(tooltipExp);
}
} | java | public static void applyHyperLinkToElement(DynamicJasperDesign design, DJHyperLink djlink, JRDesignChart chart, String name) {
JRDesignExpression hlpe = ExpressionUtils.createAndRegisterExpression(design, name, djlink.getExpression());
chart.setHyperlinkReferenceExpression(hlpe);
chart.setHyperlinkType( HyperlinkTypeEnum.REFERENCE ); //FIXME Should this be a parameter in the future?
if (djlink.getTooltip() != null){
JRDesignExpression tooltipExp = ExpressionUtils.createAndRegisterExpression(design, "tooltip_" + name, djlink.getTooltip());
chart.setHyperlinkTooltipExpression(tooltipExp);
}
} | [
"public",
"static",
"void",
"applyHyperLinkToElement",
"(",
"DynamicJasperDesign",
"design",
",",
"DJHyperLink",
"djlink",
",",
"JRDesignChart",
"chart",
",",
"String",
"name",
")",
"{",
"JRDesignExpression",
"hlpe",
"=",
"ExpressionUtils",
".",
"createAndRegisterExpres... | Creates necessary objects to make a chart an hyperlink
@param design
@param djlink
@param chart
@param name | [
"Creates",
"necessary",
"objects",
"to",
"make",
"a",
"chart",
"an",
"hyperlink"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/util/HyperLinkUtil.java#L95-L104 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java | Dj2JrCrosstabBuilder.setCrosstabOptions | private void setCrosstabOptions() {
if (djcross.isUseFullWidth()){
jrcross.setWidth(layoutManager.getReport().getOptions().getPrintableWidth());
} else {
jrcross.setWidth(djcross.getWidth());
}
jrcross.setHeight(djcross.getHeight());
jrcross.setColumnBreakOffset(djcross.getColumnBreakOffset());
jrcross.setIgnoreWidth(djcross.isIgnoreWidth());
} | java | private void setCrosstabOptions() {
if (djcross.isUseFullWidth()){
jrcross.setWidth(layoutManager.getReport().getOptions().getPrintableWidth());
} else {
jrcross.setWidth(djcross.getWidth());
}
jrcross.setHeight(djcross.getHeight());
jrcross.setColumnBreakOffset(djcross.getColumnBreakOffset());
jrcross.setIgnoreWidth(djcross.isIgnoreWidth());
} | [
"private",
"void",
"setCrosstabOptions",
"(",
")",
"{",
"if",
"(",
"djcross",
".",
"isUseFullWidth",
"(",
")",
")",
"{",
"jrcross",
".",
"setWidth",
"(",
"layoutManager",
".",
"getReport",
"(",
")",
".",
"getOptions",
"(",
")",
".",
"getPrintableWidth",
"(... | Sets the options contained in the DJCrosstab to the JRDesignCrosstab.
Also fits the correct width | [
"Sets",
"the",
"options",
"contained",
"in",
"the",
"DJCrosstab",
"to",
"the",
"JRDesignCrosstab",
".",
"Also",
"fits",
"the",
"correct",
"width"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java#L174-L185 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java | Dj2JrCrosstabBuilder.setExpressionForPrecalculatedTotalValue | private void setExpressionForPrecalculatedTotalValue(
DJCrosstabColumn[] auxCols, DJCrosstabRow[] auxRows, JRDesignExpression measureExp, DJCrosstabMeasure djmeasure,
DJCrosstabColumn crosstabColumn, DJCrosstabRow crosstabRow, String meausrePrefix) {
String rowValuesExp = "new Object[]{";
String rowPropsExp = "new String[]{";
for (int i = 0; i < auxRows.length; i++) {
if (auxRows[i].getProperty()== null)
continue;
rowValuesExp += "$V{" + auxRows[i].getProperty().getProperty() +"}";
rowPropsExp += "\"" + auxRows[i].getProperty().getProperty() +"\"";
if (i+1<auxRows.length && auxRows[i+1].getProperty()!= null){
rowValuesExp += ", ";
rowPropsExp += ", ";
}
}
rowValuesExp += "}";
rowPropsExp += "}";
String colValuesExp = "new Object[]{";
String colPropsExp = "new String[]{";
for (int i = 0; i < auxCols.length; i++) {
if (auxCols[i].getProperty()== null)
continue;
colValuesExp += "$V{" + auxCols[i].getProperty().getProperty() +"}";
colPropsExp += "\"" + auxCols[i].getProperty().getProperty() +"\"";
if (i+1<auxCols.length && auxCols[i+1].getProperty()!= null){
colValuesExp += ", ";
colPropsExp += ", ";
}
}
colValuesExp += "}";
colPropsExp += "}";
String measureProperty = meausrePrefix + djmeasure.getProperty().getProperty();
String expText = "((("+DJCRosstabMeasurePrecalculatedTotalProvider.class.getName()+")$P{crosstab-measure__"+measureProperty+"_totalProvider}).getValueFor( "
+ colPropsExp +", "
+ colValuesExp +", "
+ rowPropsExp
+ ", "
+ rowValuesExp
+" ))";
if (djmeasure.getValueFormatter() != null){
String fieldsMap = ExpressionUtils.getTextForFieldsFromScriptlet();
String parametersMap = ExpressionUtils.getTextForParametersFromScriptlet();
String variablesMap = ExpressionUtils.getTextForVariablesFromScriptlet();
String stringExpression = "((("+DJValueFormatter.class.getName()+")$P{crosstab-measure__"+measureProperty+"_vf}).evaluate( "
+ "("+expText+"), " + fieldsMap +", " + variablesMap + ", " + parametersMap +" ))";
measureExp.setText(stringExpression);
measureExp.setValueClassName(djmeasure.getValueFormatter().getClassName());
} else {
// String expText = "((("+DJCRosstabMeasurePrecalculatedTotalProvider.class.getName()+")$P{crosstab-measure__"+djmeasure.getProperty().getProperty()+"_totalProvider}).getValueFor( "
// + colPropsExp +", "
// + colValuesExp +", "
// + rowPropsExp
// + ", "
// + rowValuesExp
// +" ))";
//
log.debug("text for crosstab total provider is: " + expText);
measureExp.setText(expText);
// measureExp.setValueClassName(djmeasure.getValueFormatter().getClassName());
String valueClassNameForOperation = ExpressionUtils.getValueClassNameForOperation(djmeasure.getOperation(),djmeasure.getProperty());
measureExp.setValueClassName(valueClassNameForOperation);
}
} | java | private void setExpressionForPrecalculatedTotalValue(
DJCrosstabColumn[] auxCols, DJCrosstabRow[] auxRows, JRDesignExpression measureExp, DJCrosstabMeasure djmeasure,
DJCrosstabColumn crosstabColumn, DJCrosstabRow crosstabRow, String meausrePrefix) {
String rowValuesExp = "new Object[]{";
String rowPropsExp = "new String[]{";
for (int i = 0; i < auxRows.length; i++) {
if (auxRows[i].getProperty()== null)
continue;
rowValuesExp += "$V{" + auxRows[i].getProperty().getProperty() +"}";
rowPropsExp += "\"" + auxRows[i].getProperty().getProperty() +"\"";
if (i+1<auxRows.length && auxRows[i+1].getProperty()!= null){
rowValuesExp += ", ";
rowPropsExp += ", ";
}
}
rowValuesExp += "}";
rowPropsExp += "}";
String colValuesExp = "new Object[]{";
String colPropsExp = "new String[]{";
for (int i = 0; i < auxCols.length; i++) {
if (auxCols[i].getProperty()== null)
continue;
colValuesExp += "$V{" + auxCols[i].getProperty().getProperty() +"}";
colPropsExp += "\"" + auxCols[i].getProperty().getProperty() +"\"";
if (i+1<auxCols.length && auxCols[i+1].getProperty()!= null){
colValuesExp += ", ";
colPropsExp += ", ";
}
}
colValuesExp += "}";
colPropsExp += "}";
String measureProperty = meausrePrefix + djmeasure.getProperty().getProperty();
String expText = "((("+DJCRosstabMeasurePrecalculatedTotalProvider.class.getName()+")$P{crosstab-measure__"+measureProperty+"_totalProvider}).getValueFor( "
+ colPropsExp +", "
+ colValuesExp +", "
+ rowPropsExp
+ ", "
+ rowValuesExp
+" ))";
if (djmeasure.getValueFormatter() != null){
String fieldsMap = ExpressionUtils.getTextForFieldsFromScriptlet();
String parametersMap = ExpressionUtils.getTextForParametersFromScriptlet();
String variablesMap = ExpressionUtils.getTextForVariablesFromScriptlet();
String stringExpression = "((("+DJValueFormatter.class.getName()+")$P{crosstab-measure__"+measureProperty+"_vf}).evaluate( "
+ "("+expText+"), " + fieldsMap +", " + variablesMap + ", " + parametersMap +" ))";
measureExp.setText(stringExpression);
measureExp.setValueClassName(djmeasure.getValueFormatter().getClassName());
} else {
// String expText = "((("+DJCRosstabMeasurePrecalculatedTotalProvider.class.getName()+")$P{crosstab-measure__"+djmeasure.getProperty().getProperty()+"_totalProvider}).getValueFor( "
// + colPropsExp +", "
// + colValuesExp +", "
// + rowPropsExp
// + ", "
// + rowValuesExp
// +" ))";
//
log.debug("text for crosstab total provider is: " + expText);
measureExp.setText(expText);
// measureExp.setValueClassName(djmeasure.getValueFormatter().getClassName());
String valueClassNameForOperation = ExpressionUtils.getValueClassNameForOperation(djmeasure.getOperation(),djmeasure.getProperty());
measureExp.setValueClassName(valueClassNameForOperation);
}
} | [
"private",
"void",
"setExpressionForPrecalculatedTotalValue",
"(",
"DJCrosstabColumn",
"[",
"]",
"auxCols",
",",
"DJCrosstabRow",
"[",
"]",
"auxRows",
",",
"JRDesignExpression",
"measureExp",
",",
"DJCrosstabMeasure",
"djmeasure",
",",
"DJCrosstabColumn",
"crosstabColumn",
... | set proper expression text invoking the DJCRosstabMeasurePrecalculatedTotalProvider for the cell
@param auxRows
@param auxCols
@param measureExp
@param djmeasure
@param crosstabColumn
@param crosstabRow
@param meausrePrefix | [
"set",
"proper",
"expression",
"text",
"invoking",
"the",
"DJCRosstabMeasurePrecalculatedTotalProvider",
"for",
"the",
"cell"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java#L557-L629 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java | Dj2JrCrosstabBuilder.getRowTotalStyle | private Style getRowTotalStyle(DJCrosstabRow crosstabRow) {
return crosstabRow.getTotalStyle() == null ? this.djcross.getRowTotalStyle(): crosstabRow.getTotalStyle();
} | java | private Style getRowTotalStyle(DJCrosstabRow crosstabRow) {
return crosstabRow.getTotalStyle() == null ? this.djcross.getRowTotalStyle(): crosstabRow.getTotalStyle();
} | [
"private",
"Style",
"getRowTotalStyle",
"(",
"DJCrosstabRow",
"crosstabRow",
")",
"{",
"return",
"crosstabRow",
".",
"getTotalStyle",
"(",
")",
"==",
"null",
"?",
"this",
".",
"djcross",
".",
"getRowTotalStyle",
"(",
")",
":",
"crosstabRow",
".",
"getTotalStyle"... | MOVED INSIDE ExpressionUtils
protected JRDesignExpression getExpressionForConditionalStyle(ConditionalStyle condition, String columExpression) {
String fieldsMap = "(("+DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getCurrentFields()";
String parametersMap = "(("+DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getCurrentParams()";
String variablesMap = "(("+DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getCurrentVariables()";
String evalMethodParams = fieldsMap +", " + variablesMap + ", " + parametersMap + ", " + columExpression;
String text = "(("+ConditionStyleExpression.class.getName()+")$P{" + JRParameter.REPORT_PARAMETERS_MAP + "}.get(\""+condition.getName()+"\"))."+CustomExpression.EVAL_METHOD_NAME+"("+evalMethodParams+")";
JRDesignExpression expression = new JRDesignExpression();
expression.setValueClass(Boolean.class);
expression.setText(text);
return expression;
} | [
"MOVED",
"INSIDE",
"ExpressionUtils"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java#L661-L663 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java | Dj2JrCrosstabBuilder.registerRows | private void registerRows() {
for (int i = 0; i < rows.length; i++) {
DJCrosstabRow crosstabRow = rows[i];
JRDesignCrosstabRowGroup ctRowGroup = new JRDesignCrosstabRowGroup();
ctRowGroup.setWidth(crosstabRow.getHeaderWidth());
ctRowGroup.setName(crosstabRow.getProperty().getProperty());
JRDesignCrosstabBucket rowBucket = new JRDesignCrosstabBucket();
//New in JR 4.1+
rowBucket.setValueClassName(crosstabRow.getProperty().getValueClassName());
ctRowGroup.setBucket(rowBucket);
JRDesignExpression bucketExp = ExpressionUtils.createExpression("$F{"+crosstabRow.getProperty().getProperty()+"}", crosstabRow.getProperty().getValueClassName());
rowBucket.setExpression(bucketExp);
JRDesignCellContents rowHeaderContents = new JRDesignCellContents();
JRDesignTextField rowTitle = new JRDesignTextField();
JRDesignExpression rowTitExp = new JRDesignExpression();
rowTitExp.setValueClassName(crosstabRow.getProperty().getValueClassName());
rowTitExp.setText("$V{"+crosstabRow.getProperty().getProperty()+"}");
rowTitle.setExpression(rowTitExp);
rowTitle.setWidth(crosstabRow.getHeaderWidth());
//The width can be the sum of the with of all the rows starting from the current one, up to the inner most one.
int auxHeight = getRowHeaderMaxHeight(crosstabRow);
// int auxHeight = crosstabRow.getHeight(); //FIXME getRowHeaderMaxHeight() must be FIXED because it breaks when 1rs row shows total and 2nd doesn't
rowTitle.setHeight(auxHeight);
Style headerstyle = crosstabRow.getHeaderStyle() == null ? this.djcross.getRowHeaderStyle(): crosstabRow.getHeaderStyle();
if (headerstyle != null){
layoutManager.applyStyleToElement(headerstyle, rowTitle);
rowHeaderContents.setBackcolor(headerstyle.getBackgroundColor());
}
rowHeaderContents.addElement(rowTitle);
rowHeaderContents.setMode( ModeEnum.OPAQUE );
boolean fullBorder = i <= 0; //Only outer most will have full border
applyCellBorder(rowHeaderContents, false, fullBorder);
ctRowGroup.setHeader(rowHeaderContents );
if (crosstabRow.isShowTotals())
createRowTotalHeader(ctRowGroup,crosstabRow,fullBorder);
try {
jrcross.addRowGroup(ctRowGroup);
} catch (JRException e) {
log.error(e.getMessage(),e);
}
}
} | java | private void registerRows() {
for (int i = 0; i < rows.length; i++) {
DJCrosstabRow crosstabRow = rows[i];
JRDesignCrosstabRowGroup ctRowGroup = new JRDesignCrosstabRowGroup();
ctRowGroup.setWidth(crosstabRow.getHeaderWidth());
ctRowGroup.setName(crosstabRow.getProperty().getProperty());
JRDesignCrosstabBucket rowBucket = new JRDesignCrosstabBucket();
//New in JR 4.1+
rowBucket.setValueClassName(crosstabRow.getProperty().getValueClassName());
ctRowGroup.setBucket(rowBucket);
JRDesignExpression bucketExp = ExpressionUtils.createExpression("$F{"+crosstabRow.getProperty().getProperty()+"}", crosstabRow.getProperty().getValueClassName());
rowBucket.setExpression(bucketExp);
JRDesignCellContents rowHeaderContents = new JRDesignCellContents();
JRDesignTextField rowTitle = new JRDesignTextField();
JRDesignExpression rowTitExp = new JRDesignExpression();
rowTitExp.setValueClassName(crosstabRow.getProperty().getValueClassName());
rowTitExp.setText("$V{"+crosstabRow.getProperty().getProperty()+"}");
rowTitle.setExpression(rowTitExp);
rowTitle.setWidth(crosstabRow.getHeaderWidth());
//The width can be the sum of the with of all the rows starting from the current one, up to the inner most one.
int auxHeight = getRowHeaderMaxHeight(crosstabRow);
// int auxHeight = crosstabRow.getHeight(); //FIXME getRowHeaderMaxHeight() must be FIXED because it breaks when 1rs row shows total and 2nd doesn't
rowTitle.setHeight(auxHeight);
Style headerstyle = crosstabRow.getHeaderStyle() == null ? this.djcross.getRowHeaderStyle(): crosstabRow.getHeaderStyle();
if (headerstyle != null){
layoutManager.applyStyleToElement(headerstyle, rowTitle);
rowHeaderContents.setBackcolor(headerstyle.getBackgroundColor());
}
rowHeaderContents.addElement(rowTitle);
rowHeaderContents.setMode( ModeEnum.OPAQUE );
boolean fullBorder = i <= 0; //Only outer most will have full border
applyCellBorder(rowHeaderContents, false, fullBorder);
ctRowGroup.setHeader(rowHeaderContents );
if (crosstabRow.isShowTotals())
createRowTotalHeader(ctRowGroup,crosstabRow,fullBorder);
try {
jrcross.addRowGroup(ctRowGroup);
} catch (JRException e) {
log.error(e.getMessage(),e);
}
}
} | [
"private",
"void",
"registerRows",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rows",
".",
"length",
";",
"i",
"++",
")",
"{",
"DJCrosstabRow",
"crosstabRow",
"=",
"rows",
"[",
"i",
"]",
";",
"JRDesignCrosstabRowGroup",
"ctRowGroup... | Register the Rowgroup buckets and places the header cells for the rows | [
"Register",
"the",
"Rowgroup",
"buckets",
"and",
"places",
"the",
"header",
"cells",
"for",
"the",
"rows"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java#L773-L835 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java | Dj2JrCrosstabBuilder.registerColumns | private void registerColumns() {
for (int i = 0; i < cols.length; i++) {
DJCrosstabColumn crosstabColumn = cols[i];
JRDesignCrosstabColumnGroup ctColGroup = new JRDesignCrosstabColumnGroup();
ctColGroup.setName(crosstabColumn.getProperty().getProperty());
ctColGroup.setHeight(crosstabColumn.getHeaderHeight());
JRDesignCrosstabBucket bucket = new JRDesignCrosstabBucket();
bucket.setValueClassName(crosstabColumn.getProperty().getValueClassName());
JRDesignExpression bucketExp = ExpressionUtils.createExpression("$F{"+crosstabColumn.getProperty().getProperty()+"}", crosstabColumn.getProperty().getValueClassName());
bucket.setExpression(bucketExp);
ctColGroup.setBucket(bucket);
JRDesignCellContents colHeaerContent = new JRDesignCellContents();
JRDesignTextField colTitle = new JRDesignTextField();
JRDesignExpression colTitleExp = new JRDesignExpression();
colTitleExp.setValueClassName(crosstabColumn.getProperty().getValueClassName());
colTitleExp.setText("$V{"+crosstabColumn.getProperty().getProperty()+"}");
colTitle.setExpression(colTitleExp);
colTitle.setWidth(crosstabColumn.getWidth());
colTitle.setHeight(crosstabColumn.getHeaderHeight());
//The height can be the sum of the heights of all the columns starting from the current one, up to the inner most one.
int auxWidth = calculateRowHeaderMaxWidth(crosstabColumn);
colTitle.setWidth(auxWidth);
Style headerstyle = crosstabColumn.getHeaderStyle() == null ? this.djcross.getColumnHeaderStyle(): crosstabColumn.getHeaderStyle();
if (headerstyle != null){
layoutManager.applyStyleToElement(headerstyle,colTitle);
colHeaerContent.setBackcolor(headerstyle.getBackgroundColor());
}
colHeaerContent.addElement(colTitle);
colHeaerContent.setMode( ModeEnum.OPAQUE );
boolean fullBorder = i <= 0; //Only outer most will have full border
applyCellBorder(colHeaerContent, fullBorder, false);
ctColGroup.setHeader(colHeaerContent);
if (crosstabColumn.isShowTotals())
createColumTotalHeader(ctColGroup,crosstabColumn,fullBorder);
try {
jrcross.addColumnGroup(ctColGroup);
} catch (JRException e) {
log.error(e.getMessage(),e);
}
}
} | java | private void registerColumns() {
for (int i = 0; i < cols.length; i++) {
DJCrosstabColumn crosstabColumn = cols[i];
JRDesignCrosstabColumnGroup ctColGroup = new JRDesignCrosstabColumnGroup();
ctColGroup.setName(crosstabColumn.getProperty().getProperty());
ctColGroup.setHeight(crosstabColumn.getHeaderHeight());
JRDesignCrosstabBucket bucket = new JRDesignCrosstabBucket();
bucket.setValueClassName(crosstabColumn.getProperty().getValueClassName());
JRDesignExpression bucketExp = ExpressionUtils.createExpression("$F{"+crosstabColumn.getProperty().getProperty()+"}", crosstabColumn.getProperty().getValueClassName());
bucket.setExpression(bucketExp);
ctColGroup.setBucket(bucket);
JRDesignCellContents colHeaerContent = new JRDesignCellContents();
JRDesignTextField colTitle = new JRDesignTextField();
JRDesignExpression colTitleExp = new JRDesignExpression();
colTitleExp.setValueClassName(crosstabColumn.getProperty().getValueClassName());
colTitleExp.setText("$V{"+crosstabColumn.getProperty().getProperty()+"}");
colTitle.setExpression(colTitleExp);
colTitle.setWidth(crosstabColumn.getWidth());
colTitle.setHeight(crosstabColumn.getHeaderHeight());
//The height can be the sum of the heights of all the columns starting from the current one, up to the inner most one.
int auxWidth = calculateRowHeaderMaxWidth(crosstabColumn);
colTitle.setWidth(auxWidth);
Style headerstyle = crosstabColumn.getHeaderStyle() == null ? this.djcross.getColumnHeaderStyle(): crosstabColumn.getHeaderStyle();
if (headerstyle != null){
layoutManager.applyStyleToElement(headerstyle,colTitle);
colHeaerContent.setBackcolor(headerstyle.getBackgroundColor());
}
colHeaerContent.addElement(colTitle);
colHeaerContent.setMode( ModeEnum.OPAQUE );
boolean fullBorder = i <= 0; //Only outer most will have full border
applyCellBorder(colHeaerContent, fullBorder, false);
ctColGroup.setHeader(colHeaerContent);
if (crosstabColumn.isShowTotals())
createColumTotalHeader(ctColGroup,crosstabColumn,fullBorder);
try {
jrcross.addColumnGroup(ctColGroup);
} catch (JRException e) {
log.error(e.getMessage(),e);
}
}
} | [
"private",
"void",
"registerColumns",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cols",
".",
"length",
";",
"i",
"++",
")",
"{",
"DJCrosstabColumn",
"crosstabColumn",
"=",
"cols",
"[",
"i",
"]",
";",
"JRDesignCrosstabColumnGroup",
... | Registers the Columngroup Buckets and creates the header cell for the columns | [
"Registers",
"the",
"Columngroup",
"Buckets",
"and",
"creates",
"the",
"header",
"cell",
"for",
"the",
"columns"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java#L864-L923 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java | Dj2JrCrosstabBuilder.calculateRowHeaderMaxWidth | private int calculateRowHeaderMaxWidth(DJCrosstabColumn crosstabColumn) {
int auxWidth = 0;
boolean firstTime = true;
List<DJCrosstabColumn> auxList = new ArrayList<DJCrosstabColumn>(djcross.getColumns());
Collections.reverse(auxList);
for (DJCrosstabColumn col : auxList) {
if (col.equals(crosstabColumn)){
if (auxWidth == 0)
auxWidth = col.getWidth();
break;
}
if (firstTime){
auxWidth += col.getWidth();
firstTime = false;
}
if (col.isShowTotals()) {
auxWidth += col.getWidth();
}
}
return auxWidth;
} | java | private int calculateRowHeaderMaxWidth(DJCrosstabColumn crosstabColumn) {
int auxWidth = 0;
boolean firstTime = true;
List<DJCrosstabColumn> auxList = new ArrayList<DJCrosstabColumn>(djcross.getColumns());
Collections.reverse(auxList);
for (DJCrosstabColumn col : auxList) {
if (col.equals(crosstabColumn)){
if (auxWidth == 0)
auxWidth = col.getWidth();
break;
}
if (firstTime){
auxWidth += col.getWidth();
firstTime = false;
}
if (col.isShowTotals()) {
auxWidth += col.getWidth();
}
}
return auxWidth;
} | [
"private",
"int",
"calculateRowHeaderMaxWidth",
"(",
"DJCrosstabColumn",
"crosstabColumn",
")",
"{",
"int",
"auxWidth",
"=",
"0",
";",
"boolean",
"firstTime",
"=",
"true",
";",
"List",
"<",
"DJCrosstabColumn",
">",
"auxList",
"=",
"new",
"ArrayList",
"<",
"DJCro... | The max possible width can be calculated doing the sum of of the inner cells and its totals
@param crosstabColumn
@return | [
"The",
"max",
"possible",
"width",
"can",
"be",
"calculated",
"doing",
"the",
"sum",
"of",
"of",
"the",
"inner",
"cells",
"and",
"its",
"totals"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/layout/Dj2JrCrosstabBuilder.java#L930-L951 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/domain/chart/dataset/AbstractDataset.java | AbstractDataset.getExpressionFromVariable | protected static JRDesignExpression getExpressionFromVariable(JRDesignVariable var){
JRDesignExpression exp = new JRDesignExpression();
exp.setText("$V{" + var.getName() + "}");
exp.setValueClass(var.getValueClass());
return exp;
} | java | protected static JRDesignExpression getExpressionFromVariable(JRDesignVariable var){
JRDesignExpression exp = new JRDesignExpression();
exp.setText("$V{" + var.getName() + "}");
exp.setValueClass(var.getValueClass());
return exp;
} | [
"protected",
"static",
"JRDesignExpression",
"getExpressionFromVariable",
"(",
"JRDesignVariable",
"var",
")",
"{",
"JRDesignExpression",
"exp",
"=",
"new",
"JRDesignExpression",
"(",
")",
";",
"exp",
".",
"setText",
"(",
"\"$V{\"",
"+",
"var",
".",
"getName",
"("... | Generates an expression from a variable
@param var The variable from which to generate the expression
@return A expression that represents the given variable | [
"Generates",
"an",
"expression",
"from",
"a",
"variable"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/chart/dataset/AbstractDataset.java#L54-L59 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/DynamicJasperHelper.java | DynamicJasperHelper.generateJasperPrint | public static JasperPrint generateJasperPrint(DynamicReport dr, LayoutManager layoutManager, JRDataSource ds, Map<String, Object> _parameters) throws JRException {
log.info("generating JasperPrint");
JasperPrint jp;
JasperReport jr = DynamicJasperHelper.generateJasperReport(dr, layoutManager, _parameters);
jp = JasperFillManager.fillReport(jr, _parameters, ds);
return jp;
} | java | public static JasperPrint generateJasperPrint(DynamicReport dr, LayoutManager layoutManager, JRDataSource ds, Map<String, Object> _parameters) throws JRException {
log.info("generating JasperPrint");
JasperPrint jp;
JasperReport jr = DynamicJasperHelper.generateJasperReport(dr, layoutManager, _parameters);
jp = JasperFillManager.fillReport(jr, _parameters, ds);
return jp;
} | [
"public",
"static",
"JasperPrint",
"generateJasperPrint",
"(",
"DynamicReport",
"dr",
",",
"LayoutManager",
"layoutManager",
",",
"JRDataSource",
"ds",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"_parameters",
")",
"throws",
"JRException",
"{",
"log",
".",
"... | Compiles and fills the reports design.
@param dr the DynamicReport
@param layoutManager the object in charge of doing the layout
@param ds The datasource
@param _parameters Map with parameters that the report may need
@return
@throws JRException | [
"Compiles",
"and",
"fills",
"the",
"reports",
"design",
"."
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/DynamicJasperHelper.java#L238-L247 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/DynamicJasperHelper.java | DynamicJasperHelper.generateJasperPrint | public static JasperPrint generateJasperPrint(DynamicReport dr, LayoutManager layoutManager, Connection con, Map<String, Object> _parameters) throws JRException {
log.info("generating JasperPrint");
JasperPrint jp;
if (_parameters == null)
_parameters = new HashMap<String, Object>();
visitSubreports(dr, _parameters);
compileOrLoadSubreports(dr, _parameters, "r");
DynamicJasperDesign jd = generateJasperDesign(dr);
Map<String, Object> params = new HashMap<String, Object>();
if (!_parameters.isEmpty()) {
registerParams(jd, _parameters);
params.putAll(_parameters);
}
registerEntities(jd, dr, layoutManager);
layoutManager.applyLayout(jd, dr);
JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).setProperty(JRCompiler.COMPILER_PREFIX, DJCompilerFactory.getCompilerClassName());
//JRProperties.setProperty(JRCompiler.COMPILER_PREFIX, DJCompilerFactory.getCompilerClassName());
JasperReport jr = JasperCompileManager.compileReport(jd);
params.putAll(jd.getParametersWithValues());
jp = JasperFillManager.fillReport(jr, params, con);
return jp;
} | java | public static JasperPrint generateJasperPrint(DynamicReport dr, LayoutManager layoutManager, Connection con, Map<String, Object> _parameters) throws JRException {
log.info("generating JasperPrint");
JasperPrint jp;
if (_parameters == null)
_parameters = new HashMap<String, Object>();
visitSubreports(dr, _parameters);
compileOrLoadSubreports(dr, _parameters, "r");
DynamicJasperDesign jd = generateJasperDesign(dr);
Map<String, Object> params = new HashMap<String, Object>();
if (!_parameters.isEmpty()) {
registerParams(jd, _parameters);
params.putAll(_parameters);
}
registerEntities(jd, dr, layoutManager);
layoutManager.applyLayout(jd, dr);
JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).setProperty(JRCompiler.COMPILER_PREFIX, DJCompilerFactory.getCompilerClassName());
//JRProperties.setProperty(JRCompiler.COMPILER_PREFIX, DJCompilerFactory.getCompilerClassName());
JasperReport jr = JasperCompileManager.compileReport(jd);
params.putAll(jd.getParametersWithValues());
jp = JasperFillManager.fillReport(jr, params, con);
return jp;
} | [
"public",
"static",
"JasperPrint",
"generateJasperPrint",
"(",
"DynamicReport",
"dr",
",",
"LayoutManager",
"layoutManager",
",",
"Connection",
"con",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"_parameters",
")",
"throws",
"JRException",
"{",
"log",
".",
"i... | For running queries embebed in the report design
@param dr
@param layoutManager
@param con
@param _parameters
@return
@throws JRException | [
"For",
"running",
"queries",
"embebed",
"in",
"the",
"report",
"design"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/DynamicJasperHelper.java#L259-L284 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/DynamicJasperHelper.java | DynamicJasperHelper.generateJRXML | public static void generateJRXML(DynamicReport dr, LayoutManager layoutManager, Map _parameters, String xmlEncoding, OutputStream outputStream) throws JRException {
JasperReport jr = generateJasperReport(dr, layoutManager, _parameters);
if (xmlEncoding == null)
xmlEncoding = DEFAULT_XML_ENCODING;
JRXmlWriter.writeReport(jr, outputStream, xmlEncoding);
} | java | public static void generateJRXML(DynamicReport dr, LayoutManager layoutManager, Map _parameters, String xmlEncoding, OutputStream outputStream) throws JRException {
JasperReport jr = generateJasperReport(dr, layoutManager, _parameters);
if (xmlEncoding == null)
xmlEncoding = DEFAULT_XML_ENCODING;
JRXmlWriter.writeReport(jr, outputStream, xmlEncoding);
} | [
"public",
"static",
"void",
"generateJRXML",
"(",
"DynamicReport",
"dr",
",",
"LayoutManager",
"layoutManager",
",",
"Map",
"_parameters",
",",
"String",
"xmlEncoding",
",",
"OutputStream",
"outputStream",
")",
"throws",
"JRException",
"{",
"JasperReport",
"jr",
"="... | Creates a jrxml file
@param dr
@param layoutManager
@param _parameters
@param xmlEncoding (default is UTF-8 )
@param outputStream
@throws JRException | [
"Creates",
"a",
"jrxml",
"file"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/DynamicJasperHelper.java#L350-L355 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/DynamicJasperHelper.java | DynamicJasperHelper.registerParams | public static void registerParams(DynamicJasperDesign jd, Map _parameters) {
for (Object key : _parameters.keySet()) {
if (key instanceof String) {
try {
Object value = _parameters.get(key);
if (jd.getParametersMap().get(key) != null) {
log.warn("Parameter \"" + key + "\" already registered, skipping this one: " + value);
continue;
}
JRDesignParameter parameter = new JRDesignParameter();
if (value == null) //There are some Map implementations that allows nulls values, just go on
continue;
// parameter.setValueClassName(value.getClass().getCanonicalName());
Class clazz = value.getClass().getComponentType();
if (clazz == null)
clazz = value.getClass();
parameter.setValueClass(clazz); //NOTE this is very strange
//when using an array as subreport-data-source, I must pass the parameter class name like this: value.getClass().getComponentType()
parameter.setName((String) key);
jd.addParameter(parameter);
} catch (JRException e) {
//nothing to do
}
}
}
} | java | public static void registerParams(DynamicJasperDesign jd, Map _parameters) {
for (Object key : _parameters.keySet()) {
if (key instanceof String) {
try {
Object value = _parameters.get(key);
if (jd.getParametersMap().get(key) != null) {
log.warn("Parameter \"" + key + "\" already registered, skipping this one: " + value);
continue;
}
JRDesignParameter parameter = new JRDesignParameter();
if (value == null) //There are some Map implementations that allows nulls values, just go on
continue;
// parameter.setValueClassName(value.getClass().getCanonicalName());
Class clazz = value.getClass().getComponentType();
if (clazz == null)
clazz = value.getClass();
parameter.setValueClass(clazz); //NOTE this is very strange
//when using an array as subreport-data-source, I must pass the parameter class name like this: value.getClass().getComponentType()
parameter.setName((String) key);
jd.addParameter(parameter);
} catch (JRException e) {
//nothing to do
}
}
}
} | [
"public",
"static",
"void",
"registerParams",
"(",
"DynamicJasperDesign",
"jd",
",",
"Map",
"_parameters",
")",
"{",
"for",
"(",
"Object",
"key",
":",
"_parameters",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"key",
"instanceof",
"String",
")",
"{",
"... | For every String key, it registers the object as a parameter to make it available
in the report.
@param jd
@param _parameters | [
"For",
"every",
"String",
"key",
"it",
"registers",
"the",
"object",
"as",
"a",
"parameter",
"to",
"make",
"it",
"available",
"in",
"the",
"report",
"."
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/DynamicJasperHelper.java#L462-L492 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/core/DynamicJasperHelper.java | DynamicJasperHelper.visitSubreports | @SuppressWarnings("unchecked")
protected static void visitSubreports(DynamicReport dr, Map _parameters) {
for (DJGroup group : dr.getColumnsGroups()) {
//Header Subreports
for (Subreport subreport : group.getHeaderSubreports()) {
if (subreport.getDynamicReport() != null) {
visitSubreport(dr, subreport);
visitSubreports(subreport.getDynamicReport(), _parameters);
}
}
//Footer Subreports
for (Subreport subreport : group.getFooterSubreports()) {
if (subreport.getDynamicReport() != null) {
visitSubreport(dr, subreport);
visitSubreports(subreport.getDynamicReport(), _parameters);
}
}
}
} | java | @SuppressWarnings("unchecked")
protected static void visitSubreports(DynamicReport dr, Map _parameters) {
for (DJGroup group : dr.getColumnsGroups()) {
//Header Subreports
for (Subreport subreport : group.getHeaderSubreports()) {
if (subreport.getDynamicReport() != null) {
visitSubreport(dr, subreport);
visitSubreports(subreport.getDynamicReport(), _parameters);
}
}
//Footer Subreports
for (Subreport subreport : group.getFooterSubreports()) {
if (subreport.getDynamicReport() != null) {
visitSubreport(dr, subreport);
visitSubreports(subreport.getDynamicReport(), _parameters);
}
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"static",
"void",
"visitSubreports",
"(",
"DynamicReport",
"dr",
",",
"Map",
"_parameters",
")",
"{",
"for",
"(",
"DJGroup",
"group",
":",
"dr",
".",
"getColumnsGroups",
"(",
")",
")",
"{",
"//... | Performs any needed operation on subreports after they are built like ensuring proper subreport with
if "fitToParentPrintableArea" flag is set to true
@param dr
@param _parameters
@throws JRException | [
"Performs",
"any",
"needed",
"operation",
"on",
"subreports",
"after",
"they",
"are",
"built",
"like",
"ensuring",
"proper",
"subreport",
"with",
"if",
"fitToParentPrintableArea",
"flag",
"is",
"set",
"to",
"true"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/core/DynamicJasperHelper.java#L553-L573 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/util/ExpressionUtils.java | ExpressionUtils.getDataSourceExpression | public static JRDesignExpression getDataSourceExpression(DJDataSource ds) {
JRDesignExpression exp = new JRDesignExpression();
exp.setValueClass(JRDataSource.class);
String dsType = getDataSourceTypeStr(ds.getDataSourceType());
String expText = null;
if (ds.getDataSourceOrigin() == DJConstants.DATA_SOURCE_ORIGIN_FIELD) {
expText = dsType + "$F{" + ds.getDataSourceExpression() + "})";
} else if (ds.getDataSourceOrigin() == DJConstants.DATA_SOURCE_ORIGIN_PARAMETER) {
expText = dsType + REPORT_PARAMETERS_MAP + ".get( \"" + ds.getDataSourceExpression() + "\" ) )";
} else if (ds.getDataSourceOrigin() == DJConstants.DATA_SOURCE_TYPE_SQL_CONNECTION) {
expText = dsType + REPORT_PARAMETERS_MAP + ".get( \"" + ds.getDataSourceExpression() + "\" ) )";
} else if (ds.getDataSourceOrigin() == DJConstants.DATA_SOURCE_ORIGIN_REPORT_DATASOURCE) {
expText = "((" + JRDataSource.class.getName() + ") $P{REPORT_DATA_SOURCE})";
}
exp.setText(expText);
return exp;
} | java | public static JRDesignExpression getDataSourceExpression(DJDataSource ds) {
JRDesignExpression exp = new JRDesignExpression();
exp.setValueClass(JRDataSource.class);
String dsType = getDataSourceTypeStr(ds.getDataSourceType());
String expText = null;
if (ds.getDataSourceOrigin() == DJConstants.DATA_SOURCE_ORIGIN_FIELD) {
expText = dsType + "$F{" + ds.getDataSourceExpression() + "})";
} else if (ds.getDataSourceOrigin() == DJConstants.DATA_SOURCE_ORIGIN_PARAMETER) {
expText = dsType + REPORT_PARAMETERS_MAP + ".get( \"" + ds.getDataSourceExpression() + "\" ) )";
} else if (ds.getDataSourceOrigin() == DJConstants.DATA_SOURCE_TYPE_SQL_CONNECTION) {
expText = dsType + REPORT_PARAMETERS_MAP + ".get( \"" + ds.getDataSourceExpression() + "\" ) )";
} else if (ds.getDataSourceOrigin() == DJConstants.DATA_SOURCE_ORIGIN_REPORT_DATASOURCE) {
expText = "((" + JRDataSource.class.getName() + ") $P{REPORT_DATA_SOURCE})";
}
exp.setText(expText);
return exp;
} | [
"public",
"static",
"JRDesignExpression",
"getDataSourceExpression",
"(",
"DJDataSource",
"ds",
")",
"{",
"JRDesignExpression",
"exp",
"=",
"new",
"JRDesignExpression",
"(",
")",
";",
"exp",
".",
"setValueClass",
"(",
"JRDataSource",
".",
"class",
")",
";",
"Strin... | Returns the expression string required
@param ds
@return | [
"Returns",
"the",
"expression",
"string",
"required"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/util/ExpressionUtils.java#L101-L120 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/util/ExpressionUtils.java | ExpressionUtils.getReportConnectionExpression | public static JRDesignExpression getReportConnectionExpression() {
JRDesignExpression connectionExpression = new JRDesignExpression();
connectionExpression.setText("$P{" + JRDesignParameter.REPORT_CONNECTION + "}");
connectionExpression.setValueClass(Connection.class);
return connectionExpression;
} | java | public static JRDesignExpression getReportConnectionExpression() {
JRDesignExpression connectionExpression = new JRDesignExpression();
connectionExpression.setText("$P{" + JRDesignParameter.REPORT_CONNECTION + "}");
connectionExpression.setValueClass(Connection.class);
return connectionExpression;
} | [
"public",
"static",
"JRDesignExpression",
"getReportConnectionExpression",
"(",
")",
"{",
"JRDesignExpression",
"connectionExpression",
"=",
"new",
"JRDesignExpression",
"(",
")",
";",
"connectionExpression",
".",
"setText",
"(",
"\"$P{\"",
"+",
"JRDesignParameter",
".",
... | Returns a JRDesignExpression that points to the main report connection
@return | [
"Returns",
"a",
"JRDesignExpression",
"that",
"points",
"to",
"the",
"main",
"report",
"connection"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/util/ExpressionUtils.java#L139-L144 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/util/ExpressionUtils.java | ExpressionUtils.getVariablesMapExpression | public static String getVariablesMapExpression(Collection variables) {
StringBuilder variablesMap = new StringBuilder("new " + PropertiesMap.class.getName() + "()");
for (Object variable : variables) {
JRVariable jrvar = (JRVariable) variable;
String varname = jrvar.getName();
variablesMap.append(".with(\"").append(varname).append("\",$V{").append(varname).append("})");
}
return variablesMap.toString();
} | java | public static String getVariablesMapExpression(Collection variables) {
StringBuilder variablesMap = new StringBuilder("new " + PropertiesMap.class.getName() + "()");
for (Object variable : variables) {
JRVariable jrvar = (JRVariable) variable;
String varname = jrvar.getName();
variablesMap.append(".with(\"").append(varname).append("\",$V{").append(varname).append("})");
}
return variablesMap.toString();
} | [
"public",
"static",
"String",
"getVariablesMapExpression",
"(",
"Collection",
"variables",
")",
"{",
"StringBuilder",
"variablesMap",
"=",
"new",
"StringBuilder",
"(",
"\"new \"",
"+",
"PropertiesMap",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\"()\"",
")",
... | Collection of JRVariable
@param variables
@return | [
"Collection",
"of",
"JRVariable"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/util/ExpressionUtils.java#L263-L271 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/util/ExpressionUtils.java | ExpressionUtils.createCustomExpressionInvocationText | public static String createCustomExpressionInvocationText(CustomExpression customExpression, String customExpName, boolean usePreviousFieldValues) {
String stringExpression;
if (customExpression instanceof DJSimpleExpression) {
DJSimpleExpression varexp = (DJSimpleExpression) customExpression;
String symbol;
switch (varexp.getType()) {
case DJSimpleExpression.TYPE_FIELD:
symbol = "F";
break;
case DJSimpleExpression.TYPE_VARIABLE:
symbol = "V";
break;
case DJSimpleExpression.TYPE_PARAMATER:
symbol = "P";
break;
default:
throw new DJException("Invalid DJSimpleExpression, type must be FIELD, VARIABLE or PARAMETER");
}
stringExpression = "$" + symbol + "{" + varexp.getVariableName() + "}";
} else {
String fieldsMap = "((" + DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getCurrentFields()";
if (usePreviousFieldValues) {
fieldsMap = "((" + DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getPreviousFields()";
}
String parametersMap = "((" + DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getCurrentParams()";
String variablesMap = "((" + DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getCurrentVariables()";
stringExpression = "((" + CustomExpression.class.getName() + ")$P{REPORT_PARAMETERS_MAP}.get(\"" + customExpName + "\"))."
+ CustomExpression.EVAL_METHOD_NAME + "( " + fieldsMap + ", " + variablesMap + ", " + parametersMap + " )";
}
return stringExpression;
} | java | public static String createCustomExpressionInvocationText(CustomExpression customExpression, String customExpName, boolean usePreviousFieldValues) {
String stringExpression;
if (customExpression instanceof DJSimpleExpression) {
DJSimpleExpression varexp = (DJSimpleExpression) customExpression;
String symbol;
switch (varexp.getType()) {
case DJSimpleExpression.TYPE_FIELD:
symbol = "F";
break;
case DJSimpleExpression.TYPE_VARIABLE:
symbol = "V";
break;
case DJSimpleExpression.TYPE_PARAMATER:
symbol = "P";
break;
default:
throw new DJException("Invalid DJSimpleExpression, type must be FIELD, VARIABLE or PARAMETER");
}
stringExpression = "$" + symbol + "{" + varexp.getVariableName() + "}";
} else {
String fieldsMap = "((" + DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getCurrentFields()";
if (usePreviousFieldValues) {
fieldsMap = "((" + DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getPreviousFields()";
}
String parametersMap = "((" + DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getCurrentParams()";
String variablesMap = "((" + DJDefaultScriptlet.class.getName() + ")$P{REPORT_SCRIPTLET}).getCurrentVariables()";
stringExpression = "((" + CustomExpression.class.getName() + ")$P{REPORT_PARAMETERS_MAP}.get(\"" + customExpName + "\"))."
+ CustomExpression.EVAL_METHOD_NAME + "( " + fieldsMap + ", " + variablesMap + ", " + parametersMap + " )";
}
return stringExpression;
} | [
"public",
"static",
"String",
"createCustomExpressionInvocationText",
"(",
"CustomExpression",
"customExpression",
",",
"String",
"customExpName",
",",
"boolean",
"usePreviousFieldValues",
")",
"{",
"String",
"stringExpression",
";",
"if",
"(",
"customExpression",
"instance... | If you register a CustomExpression with the name "customExpName", then this will create the text needed
to invoke it in a JRDesignExpression
@param customExpName
@param usePreviousFieldValues
@return | [
"If",
"you",
"register",
"a",
"CustomExpression",
"with",
"the",
"name",
"customExpName",
"then",
"this",
"will",
"create",
"the",
"text",
"needed",
"to",
"invoke",
"it",
"in",
"a",
"JRDesignExpression"
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/util/ExpressionUtils.java#L293-L327 | train |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/domain/builders/ReflectiveReportBuilder.java | ReflectiveReportBuilder.addProperties | private void addProperties(final PropertyDescriptor[] _properties) throws ColumnBuilderException, ClassNotFoundException {
for (final PropertyDescriptor property : _properties) {
if (isValidProperty(property)) {
addColumn(getColumnTitle(property), property.getName(), property.getPropertyType().getName(), getColumnWidth(property));
}
}
setUseFullPageWidth(true);
} | java | private void addProperties(final PropertyDescriptor[] _properties) throws ColumnBuilderException, ClassNotFoundException {
for (final PropertyDescriptor property : _properties) {
if (isValidProperty(property)) {
addColumn(getColumnTitle(property), property.getName(), property.getPropertyType().getName(), getColumnWidth(property));
}
}
setUseFullPageWidth(true);
} | [
"private",
"void",
"addProperties",
"(",
"final",
"PropertyDescriptor",
"[",
"]",
"_properties",
")",
"throws",
"ColumnBuilderException",
",",
"ClassNotFoundException",
"{",
"for",
"(",
"final",
"PropertyDescriptor",
"property",
":",
"_properties",
")",
"{",
"if",
"... | Adds columns for the specified properties.
@param _properties the array of <code>PropertyDescriptor</code>s to be added.
@throws ColumnBuilderException if an error occurs.
@throws ClassNotFoundException if an error occurs. | [
"Adds",
"columns",
"for",
"the",
"specified",
"properties",
"."
] | 63919574cc401ae40574d13129f628e66d1682a3 | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/builders/ReflectiveReportBuilder.java#L103-L110 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.