本文整理汇总了Java中ro.nextreports.engine.queryexec.IdName类的典型用法代码示例。如果您正苦于以下问题:Java IdName类的具体用法?Java IdName怎么用?Java IdName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IdName类属于ro.nextreports.engine.queryexec包,在下文中一共展示了IdName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setValues
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
private void setValues(JComponent component, List<IdName> values) {
if (component instanceof JComboBox) {
JComboBox combo = ((JComboBox) component);
combo.removeAllItems();
for (int j = 0, len = values.size(); j < len; j++) {
combo.addItem(values.get(j));
}
} else if (component instanceof JList) {
JList list = ((JList)component);
DefaultListModel model = new DefaultListModel();
int[] selection = new int[values.size()];
for (int j = 0, len = values.size(); j < len; j++) {
model.addElement(values.get(j));
selection[j] = j;
}
list.setModel(model);
list.setSelectedIndices(selection);
}
}
示例2: getListCellRendererComponent
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
if (value != null) {
if (!(value instanceof String)) {
IdName in = (IdName) value;
if (in.getName() != null) {
value = in.getName();
} else {
value = in.getId();
}
}
if (value instanceof Date) {
value = sdf.format((Date)value);
} else if (value instanceof Time) {
value = sdf.format(new Date(((Time)value).getTime()));
} else if (value instanceof Timestamp) {
value = sdf.format(new Date(((Timestamp)value).getTime()));
}
}
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
示例3: createRuntimeModel
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
private NextRuntimeParameterModel createRuntimeModel(QueryParameter parameter) {
boolean isMultipleSelection = parameter.getSelection().equalsIgnoreCase(QueryParameter.MULTIPLE_SELECTION);
NextRuntimeParameterModel runtimeModel = new NextRuntimeParameterModel(parameter.getName(), getParameterName(parameter), isMultipleSelection);
runtimeModel.setMandatory(parameter.isMandatory());
List<IdName> values = new ArrayList<IdName>();
// set in the model only the values for parameters which are not dependent
if ((errorMessage == null) && (parameter.getSource() != null) && (parameter.getSource().trim().length() > 0)
&& !parameter.isDependent()) {
try {
values = dataSourceService.getParameterValues(getDataSource(), parameter);
} catch (Exception e) {
e.printStackTrace();
errorMessage = "Get parameter values for : " + parameter.getName() + " > " + e.getMessage();
LOG.error(errorMessage, e);
error(e.getMessage());
}
}
runtimeModel.setParameterValues(values);
if (errorMessage == null) {
initDefaultValues(runtimeModel, parameter, values);
}
return runtimeModel;
}
示例4: getSelectedValues
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
private List<Serializable> getSelectedValues(List<IdName> values, List<Serializable> defaultValues) {
List<Serializable> selectedValues = new ArrayList<Serializable>();
if (defaultValues == null) {
return selectedValues;
}
for (Serializable s : defaultValues) {
for (IdName in : values) {
if (s instanceof IdName) {
if ((in.getId() != null) && in.getId().equals( ((IdName)s).getId())) {
selectedValues.add(in);
break;
}
} else if ((in.getId() != null) && in.getId().equals(s)) {
selectedValues.add(in);
break;
}
}
}
return selectedValues;
}
示例5: getIdValue
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
public String getIdValue(Object object, int index) {
if (object == null) {
return "";
}
if (!(object instanceof IdName)) {
return object.toString();
}
IdName value = (IdName) object;
if (value.getId() == null) {
return Integer.toString(index);
}
Object returnValue = value.getId();
if (returnValue == null) {
return "";
}
// IMPORTANT : if values start or end with space , on submit first rawValue will be ignored!
// so we assure that the id never starts or ends with space!
//
// replace comma with other character (otherwise values with comma will be interpreted as two
// values and no selection will be done for them)
return "@" + returnValue.toString().replace(",", "-") + "@";
}
示例6: getParameter
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
public Serializable getParameter(ExternalParameter parameter) {
QueryParameter qp = new QueryParameter(parameter.getName(), parameter.getDescription(),
parameter.getValueClassName());
qp.setRuntimeName(parameter.getRuntimeName());
if (ExternalParameter.COMBO_TYPE.equals(parameter.getType())) {
qp.setSelection(QueryParameter.SINGLE_SELECTION);
} else {
qp.setSelection(QueryParameter.MULTIPLE_SELECTION);
}
List<String> list = new ArrayList<String>();
for (IdName in : parameter.getValues()) {
// TODO resolve
// list.add(in.getName());
}
qp.setValues(list);
return qp;
}
示例7: getParameterValueAsString
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
public static String getParameterValueAsString(Object value) {
StringBuilder buffer = new StringBuilder();
if (value instanceof Object[]) {
buffer.append("[");
for (Object obj : (Object[]) value) {
if (obj instanceof IdName) {
buffer.append(((IdName) obj).getId());
} else {
buffer.append(obj);
}
buffer.append(";");
}
if (buffer.toString().endsWith(";")) {
buffer.deleteCharAt(buffer.length() - 1);
}
buffer.append("]");
} else if (value instanceof IdName) {
buffer.append(((IdName) value).getId());
} else {
buffer.append(value);
}
return buffer.toString();
}
示例8: getDisplayParameterValueAsString
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
public static String getDisplayParameterValueAsString(Object value) {
StringBuilder buffer = new StringBuilder();
if (value instanceof Object[]) {
buffer.append("[");
for (Object obj : (Object[]) value) {
if (obj instanceof IdName) {
buffer.append(((IdName) obj).getName());
} else {
buffer.append(obj);
}
buffer.append(";");
}
if (buffer.toString().endsWith(";")) {
buffer.deleteCharAt(buffer.length() - 1);
}
buffer.append("]");
} else if (value instanceof IdName) {
buffer.append(((IdName) value).getName());
} else {
buffer.append(value);
}
return buffer.toString();
}
示例9: setName
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
private static void setName(String shownColumnName, IdName in, ResultSet rs, int typeCode)
throws SQLException {
if (shownColumnName == null) {
return;
}
switch (typeCode) {
case Types.INTEGER:
in.setName(rs.getInt(2));
break;
case Types.DOUBLE:
in.setName(rs.getDouble(2));
break;
case Types.DATE:
in.setName(rs.getDate(2));
break;
case Types.VARCHAR:
in.setName(rs.getString(2));
break;
default:
//in.setName(rs.getObject(2));
//break;
throw new SQLException("setName -> getColumnValues: type for rawValue cannot be Serialized.");
}
}
示例10: findIdName
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
private IdName findIdName(List list, Serializable id) {
for (int i = 0, size = list.size(); i < size; i++) {
IdName in = (IdName) list.get(i);
if (in.getId() == null) {
LOG.error("A value from select used in default values is null! and it is ignored");
} else {
if (in.getId().equals(id)) {
return in;
}
}
}
return null;
}
示例11: getParameterValues
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
/**
* Get values for a parameter from a database
* If a parameter is dependent of another parameter(s) his values will not be loaded
*
* @param con connection to database
* @param parameter parameter
* @return a list of parameter values
* @throws SQLException if an error to sql execution appears
* @throws DialectException if dialect not found
*/
public static List<IdName> getParameterValues(Connection con, QueryParameter parameter)
throws SQLException, DialectException {
List<IdName> values = new ArrayList<IdName>();
if (parameter == null) {
return values;
}
String source = parameter.getSource();
if (parameter.isManualSource()) {
if (!parameter.isDependent()) {
values = getSelectValues(con, source, true, parameter.getOrderBy());
}
} else {
int index = source.indexOf(".");
int index2 = source.lastIndexOf(".");
String tableName = source.substring(0, index);
String columnName;
String shownColumnName = null;
if (index == index2) {
columnName = source.substring(index + 1);
} else {
columnName = source.substring(index + 1, index2);
shownColumnName = source.substring(index2 + 1);
}
values = getColumnValues(con, parameter.getSchema(), tableName, columnName, shownColumnName, parameter.getOrderBy());
}
return values;
}
示例12: setName
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
private static void setName(String shownColumnName, IdName in, ResultSet rs, int typeCode) throws SQLException {
if (shownColumnName == null) {
return;
}
switch (typeCode) {
case Types.INTEGER:
in.setName(rs.getInt(2));
break;
case Types.BIGINT:
in.setName(rs.getBigDecimal(2));
break;
case Types.DOUBLE:
in.setName(rs.getDouble(2));
break;
case Types.DATE:
in.setName(rs.getDate(2));
break;
case Types.TIME:
in.setName(rs.getTime(2));
break;
case Types.TIMESTAMP:
in.setName(rs.getTimestamp(2));
break;
case Types.VARCHAR:
in.setName(rs.getString(2));
break;
default:
throw new SQLException("NEXTREPORTS -> getColumnValues/setName: type for value cannot be Serialized.");
}
}
示例13: initAllRuntimeParameterValues
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
/**
* Init parameter values map with all the values
*
* @param param parameter
* @param values all parameter values
* @param parameterValues map of parameter values
* @throws QueryException if could not get parameter values
*/
public static void initAllRuntimeParameterValues(QueryParameter param,
List<IdName> values, Map<String, Object> parameterValues) throws QueryException {
if (param.getSelection().equals(QueryParameter.SINGLE_SELECTION)) {
parameterValues.put(param.getName(), values.get(0));
} else {
Object[] val = new Object[values.size()];
for (int k = 0, size = values.size(); k < size; k++) {
val[k] = values.get(k);
}
parameterValues.put(param.getName(), val);
}
}
示例14: load
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
@Override
protected List<IdName> load() {
String parameterName = parameter.getName();
List<IdName> list = runtimeModel.getParameters().get(parameterName).getValues();
return list.size() > 0 ? list : new ArrayList<IdName>();
}
示例15: createRuntimeModel
import ro.nextreports.engine.queryexec.IdName; //导入依赖的package包/类
private JasperRuntimeParameterModel createRuntimeModel(QueryParameter parameter) {
boolean isMultipleSelection = parameter.getSelection().equalsIgnoreCase(QueryParameter.MULTIPLE_SELECTION);
JasperRuntimeParameterModel runtimeModel = new JasperRuntimeParameterModel(parameter.getName(), getParameterName(parameter), isMultipleSelection);
runtimeModel.setMandatory(parameter.isMandatory());
List<IdName> values = new ArrayList<IdName>();
// set in the model only the values for parameters which are not dependent
//System.out.println("*** param="+parameter.getName() + " source="+parameter.getSource()+ " dep="+parameter.isDependent() + " selection="+parameter.getSelection());
if ((parameter.getSource() != null) && (parameter.getSource().trim().length() > 0)
&& !parameter.isDependent()) {
if (QueryParameter.SINGLE_SELECTION.equals(parameter.getSelection())) {
runtimeModel.setCombo(true);
}
try {
values = dataSourceService.getParameterValues(report.getDataSource(), parameter);
//System.out.println("values="+values);
} catch (Exception e) {
//System.out.println(e.getMessage());
info(e.getMessage());
}
}
runtimeModel.setParameterValues(values);
boolean populateDependent = false;
if (USER_PARAM.equals(parameter.getName())) {
runtimeModel.setRawValue(ServerUtil.getUsernameWithoutRealm());
populateDependent = true;
}
// mark the dependent parameters that must be populated after initilize the default values
if (populateDependent) {
this.runtimeModel.getParameters().put(parameter.getName(), runtimeModel);
depParameters.add(parameter);
}
return runtimeModel;
}