code stringlengths 73 34.1k | label stringclasses 1 value |
|---|---|
public Set<Method> findAnnotatedMethods(String scanBase, Class<? extends Annotation> annotationClass) {
Set<BeanDefinition> filteredComponents = findCandidateBeans(scanBase, annotationClass);
return extractAnnotatedMethods(filteredComponents, annotationClass);
} | java |
public void reset() {
state = BreakerState.CLOSED;
isHardTrip = false;
byPass = false;
isAttemptLive = false;
notifyBreakerStateChange(getStatus());
} | java |
public WebMBeanAdapter createWebMBeanAdapter(String mBeanName, String encoding)
throws JMException, UnsupportedEncodingException {
return new WebMBeanAdapter(mBeanServer, mBeanName, encoding);
} | 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);
}
} | 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();
}
} | 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;
} | 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);
}
}
}
);
} | 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;
} | 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;
} | 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());
} | 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;
} | java |
public String getAttributeValue(String attributeName)
throws JMException, UnsupportedEncodingException {
String decodedAttributeName = sanitizer.urlDecode(attributeName, encoding);
return sanitizer.escapeValue(mBeanServer.getAttribute(objectName, decodedAttributeName));
} | 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));
} | java |
String urlDecode(String name, String encoding) throws UnsupportedEncodingException {
return URLDecoder.decode(name, encoding);
} | java |
String escapeValue(Object value) {
return HtmlUtils.htmlEscape(value != null ? value.toString() : "<null>");
} | 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());
} | 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;
} | 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;
} | 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);
} | 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());
} | 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;
} | 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());
}
} | 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());
}
} | 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);
}
};
} | 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);
}
};
} | java |
private static String toColumnName(String fieldName) {
int lastDot = fieldName.indexOf('.');
if (lastDot > -1) {
return fieldName.substring(lastDot + 1);
} else {
return fieldName;
}
} | 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);
}
};
} | java |
public static Predicate is(final String sql) {
return new Predicate() {
public String toSql() {
return sql;
}
public void init(AbstractSqlCreator creator) {
}
};
} | 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();
}
};
} | 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;
} | 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);
}
} | java |
public void deleteById(Object id) {
int count = beginDelete().whereEquals(idColumn.getColumnName(), id).delete();
if (count == 0) {
throw new RowNotFoundException(table, id);
}
} | java |
public T findById(Object id) throws RowNotFoundException, TooManyRowsException {
return findWhere(eq(idColumn.getColumnName(), id)).getSingleResult();
} | 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;
} | 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;
} | 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));
}
}
} | java |
public AbstractSqlCreator setParameter(String name, Object value) {
ppsc.setParameter(name, value);
return this;
} | java |
public InsertBuilder set(String column, String value) {
columns.add(column);
values.add(value);
return this;
} | java |
public SelectBuilder orderBy(String name, boolean ascending) {
if (ascending) {
orderBys.add(name + " asc");
} else {
orderBys.add(name + " desc");
}
return this;
} | 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;
} | 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();
} | 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;
}
} | java |
public static <E extends Enum<E>> EnumStringConverter<E> create(Class<E> enumType) {
return new EnumStringConverter<E>(enumType);
} | 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()]);
} | 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);
}
} | 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);
}
} | 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);
}
} | 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));
}
} | 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;
} | 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));
}
} | 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;
} | 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;
} | 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");
}
} | 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");
}
} | 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());
} | 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");
}
} | 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");
}
} | 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");
}
} | 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);
} | 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;
} | 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;
} | 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);
}
} | 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;
} | 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
} | 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);
}
} | 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");
}
} | 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);
}
} | 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");
}
} | 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);
}
} | java |
public HashMap<K2, HashMap<K3, V>> get(final K1 firstKey) {
return map.get(firstKey);
} | 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>();
}
} | 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();
} | 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();
} | 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()));
} | 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);
} | java |
protected List<Object> executeProcessors(final List<Object> processedColumns, final CellProcessor[] processors) {
Util.executeCellProcessors(processedColumns, getColumns(), processors, getLineNumber(), getRowNumber());
return processedColumns;
} | java |
public void stopListenting() {
if (channel != null) {
log.info("closing server channel");
channel.close().syncUninterruptibly();
channel = null;
}
} | 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;
} | 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;
} | 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;
} | 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;
} | 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);
}
}
} | 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);
}
} | 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());
} | 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);
}
} | java |
private Style getRowTotalStyle(DJCrosstabRow crosstabRow) {
return crosstabRow.getTotalStyle() == null ? this.djcross.getRowTotalStyle(): crosstabRow.getTotalStyle();
} | 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);
}
}
} | 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);
}
}
} | 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;
} | java |
protected static JRDesignExpression getExpressionFromVariable(JRDesignVariable var){
JRDesignExpression exp = new JRDesignExpression();
exp.setText("$V{" + var.getName() + "}");
exp.setValueClass(var.getValueClass());
return exp;
} | 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;
} | 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;
} | 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);
} | 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
}
}
}
} | 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);
}
}
}
} | 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;
} | java |
public static JRDesignExpression getReportConnectionExpression() {
JRDesignExpression connectionExpression = new JRDesignExpression();
connectionExpression.setText("$P{" + JRDesignParameter.REPORT_CONNECTION + "}");
connectionExpression.setValueClass(Connection.class);
return connectionExpression;
} | 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();
} | 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;
} | 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);
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.