List of usage examples for org.apache.commons.lang ArrayUtils toString
public static String toString(Object array)
Outputs an array as a String, treating null
as an empty array.
From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java
/** * <p>//from w ww . j a v a 2s . c o m * Creates a new {@link OperationCallExp} for a static operation. The * <code>referredOperationPathName</code> must not be <code>null</code>, the * arguments are optional. The owning type must exist in the associated * {@link IModel model} and the specified operation must be static. * </p> * * @param referredOperationPathName * The fully qualified name of the operation (i.e., including the * fully qualified name of its owning {@link Type}). * @param argument * An optional list of arguments as {@link OclExpression}s. * * @return An {@link OperationCallExp} instance. * * @throws EssentialOclFactoryException * If the expression cannot be created. */ public OperationCallExp createOperationCallExp(List<String> pathName, OclExpression... argument) throws EssentialOclFactoryException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("createOperationCallExp(pathName=" + pathName //$NON-NLS-1$ + ", argument=" + ArrayUtils.toString(argument) + ") - enter"); //$NON-NLS-1$ //$NON-NLS-2$ } if (pathName == null || pathName.size() < 2) { throw new IllegalArgumentException("The static operation path name '" + pathName //$NON-NLS-1$ + "' is either null or does not have the required number of at least two segments."); //$NON-NLS-1$ } // split the pathname into the type and operation part String referredOperation = pathName.get(pathName.size() - 1); pathName = pathName.subList(0, pathName.size() - 1); // collect the parameter types List<Type> paramTypes = new ArrayList<Type>(); if (argument != null) { for (int i = 0; i < argument.length; i++) { paramTypes.add(argument[i].getType()); } } // lookup the type Type owningType = findType(pathName); // FIXME Michael: This is wrong, but the parser treats this as a static // operation. A new parser should avoid this, so this code can move to // another place (non-static operation) // lookup the operation on OclType first (allInstances, probably more) Operation operation = oclLibrary.getOclType().lookupOperation(referredOperation, paramTypes); if (operation == null) { operation = owningType.lookupOperation(referredOperation, paramTypes); if (operation == null || !operation.isStatic()) { throw new IllegalArgumentException("Unable to find a static operation '" + referredOperation //$NON-NLS-1$ + "' with argument types " + paramTypes + "' in type " //$NON-NLS-1$ //$NON-NLS-2$ + owningType.getQualifiedName() + "."); //$NON-NLS-1$ } } // no else. // create the expression OperationCallExp operationCallExp = ExpressionsFactory.INSTANCE.createOperationCallExp(); operationCallExp.setSourceType(owningType); operationCallExp.setReferredOperation(operation); if (argument != null) { operationCallExp.getArgument().addAll(Arrays.asList(argument)); } // a property call expression needs access to the OCL library for // determining its type operationCallExp.setOclLibrary(oclLibrary); if (LOGGER.isDebugEnabled()) { LOGGER.debug("createOperationCallExp() - exit - return value=" //$NON-NLS-1$ + operationCallExp); } return operationCallExp; }
From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java
/** * @author Lars Schuetze/*from w w w. j a va 2 s .c o m*/ * @param source * The source {@link OclExpression} of the {@link PropertyCallExp}. * @param referredProperty * The referred {@link Property property} * @param qualifier * qualifier {@link OclExpression} as an Array. * @return A {@link PropertyCallExp} instance. * @throws EssentialOclFactoryException */ public PropertyCallExp createPropertyCallExp(OclExpression source, Property referredProperty, OclExpression... qualifier) throws EssentialOclFactoryException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("createPropertyCallExp(source=" + source + ", refferedProperty=" + referredProperty + ", qualifier=" + ArrayUtils.toString(qualifier)); } if (source == null || referredProperty == null) { throw new IllegalArgumentException("Parameters must not be null: source=" + source //$NON-NLS-1$ + ", referredProperty=" + referredProperty + "."); //$NON-NLS-1$//$NON-NLS-2$ } // create the expression PropertyCallExp propertyCallExp = ExpressionsFactory.INSTANCE.createPropertyCallExp(); propertyCallExp.setSource(source); propertyCallExp.setSourceType(referredProperty.getOwningType()); propertyCallExp.setReferredProperty(referredProperty); // a property call expression needs access to the OCL library propertyCallExp.setOclLibrary(oclLibrary); // set the qualifiers if existing if (qualifier != null) { propertyCallExp.getQualifier().addAll(Arrays.asList(qualifier)); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("createPropertyCallExp() - exit - return value=" //$NON-NLS-1$ + propertyCallExp); } return propertyCallExp; }
From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java
/** * <p>//from w w w . java 2 s .c o m * Creates a {@link PropertyCallExp}. * </p> * * @param source * The source {@link OclExpression} of the {@link PropertyCallExp}. * @param referredPropertyName * The referred property's name as a {@link String}. * @param qualifier * qualifier {@link OclExpression} as an Array. * * @return A {@link PropertyCallExp} instance. * @throws EssentialOclFactoryException */ public PropertyCallExp createPropertyCallExp(OclExpression source, String referredPropertyName, OclExpression... qualifier) throws EssentialOclFactoryException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("createPropertyCallExp(source=" + source //$NON-NLS-1$ + ", referredPropertyName=" + referredPropertyName + ", qualifier=" //$NON-NLS-1$ //$NON-NLS-2$ + ArrayUtils.toString(qualifier) + ") - enter"); //$NON-NLS-1$ } if (source == null || StringUtils.isEmpty(referredPropertyName)) { throw new IllegalArgumentException("Parameters must not be null or empty: source=" + source //$NON-NLS-1$ + ", referredPropertyName=" + referredPropertyName + "."); //$NON-NLS-1$//$NON-NLS-2$ } // lookup the property Type sourceType = source.getType(); Property property = sourceType.lookupProperty(referredPropertyName); // invalid and undefined conform to all types, so we ignore if we // haven't found a property if (property == null) { throw new EssentialOclFactoryException("Unable to find property '" + referredPropertyName //$NON-NLS-1$ + "' in type '" + source.getType().getQualifiedName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ } // create the expression PropertyCallExp propertyCallExp = ExpressionsFactory.INSTANCE.createPropertyCallExp(); propertyCallExp.setSource(source); propertyCallExp.setSourceType(sourceType); propertyCallExp.setReferredProperty(property); // a property call expression needs access to the OCL library propertyCallExp.setOclLibrary(oclLibrary); // set the qualifiers if existing if (qualifier != null) { propertyCallExp.getQualifier().addAll(Arrays.asList(qualifier)); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("createPropertyCallExp() - exit - return value=" //$NON-NLS-1$ + propertyCallExp); } return propertyCallExp; }
From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java
/** * <p>/*from w w w. j ava2s . c om*/ * Creates a {@link PropertyCallExp}. * </p> * * @param referredPropertyPathName * The referred property's name as a {@link String}. * @param qualifier * qualifier {@link OclExpression} as an Array. * @return A {@link PropertyCallExp} instance. * @throws EssentialOclFactoryException * Thrown, if the creation fails. */ public PropertyCallExp createPropertyCallExp(List<String> pathName, OclExpression... qualifier) throws EssentialOclFactoryException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("createPropertyCallExp(pathName=" + pathName //$NON-NLS-1$ + ", qualifier=" + ArrayUtils.toString(qualifier) + ") - enter"); //$NON-NLS-1$ //$NON-NLS-2$ } if (pathName == null || pathName.size() < 2) { throw new IllegalArgumentException("The static property path name '" + pathName //$NON-NLS-1$ + "' is either null or does not have the required number of at least two segments."); //$NON-NLS-1$ } // split the path name into the type name and the property name String referredProperty = pathName.get(pathName.size() - 1); pathName = pathName.subList(0, pathName.size() - 1); // lookup the type Type owningType = findType(pathName); // lookup the property Property property = owningType.lookupProperty(referredProperty); if (property == null || !property.isStatic()) { throw new IllegalArgumentException("Unable to find a static property '" + referredProperty //$NON-NLS-1$ + "' in type " + owningType.getQualifiedName() + "."); //$NON-NLS-1$ //$NON-NLS-2$ } // create the expression PropertyCallExp propertyCallExp = ExpressionsFactory.INSTANCE.createPropertyCallExp(); propertyCallExp.setSourceType(owningType); propertyCallExp.setReferredProperty(property); // add qualifiers if (qualifier != null) { propertyCallExp.getQualifier().addAll(Arrays.asList(qualifier)); } // set reference to OCL library propertyCallExp.setOclLibrary(oclLibrary); if (LOGGER.isDebugEnabled()) { LOGGER.debug("createPropertyCallExp() - exit - return value=" //$NON-NLS-1$ + propertyCallExp); } return propertyCallExp; }
From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java
/** * <p>/* w ww . ja va 2 s. c om*/ * Creates a {@link TupleLiteralExp}. * </p> * * @param parts * The {@link TupleLiteralPart}s of the {@link TupleLiteralExp}. * @return A {@link TupleLiteralExp} instance. */ public TupleLiteralExp createTupleLiteralExp(TupleLiteralPart... parts) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("createTupleLiteralExp(parts=" + ArrayUtils.toString(parts) //$NON-NLS-1$ + ") - enter"); //$NON-NLS-1$ } TupleLiteralExp tupleLiteralExp; // create new expression and add parts tupleLiteralExp = ExpressionsFactory.INSTANCE.createTupleLiteralExp(); if (parts != null) { tupleLiteralExp.getPart().addAll(Arrays.asList(parts)); } // set reference to OCL library tupleLiteralExp.setOclLibrary(oclLibrary); if (LOGGER.isDebugEnabled()) { LOGGER.debug("createTupleLiteralExp() - exit - return value=" //$NON-NLS-1$ + tupleLiteralExp); } return tupleLiteralExp; }
From source file:org.eclipse.dirigible.runtime.services.MemoryTest.java
@Test public void testMemoryLog() { try {/*from w ww .ja v a2s. c o m*/ MemoryLogRecordDAO.insert(); String memoryLogs = MemoryLogRecordDAO.getMemoryLogRecords(); assertNotNull(memoryLogs); System.out.println(ArrayUtils.toString(memoryLogs)); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:org.eclipse.wb.internal.core.eval.evaluators.InvocationEvaluator.java
/** * @return {@link String} presentation of given argument values, safely. *//* w w w . jav a2 s.co m*/ public static String getArguments_toString(final Object[] arguments) { return ExecutionUtils.runObjectIgnore(new RunnableObjectEx<String>() { public String runObject() throws Exception { return ArrayUtils.toString(arguments); } }, "<Exception during arguments.toString()>"); }
From source file:org.eclipse.wb.tests.utils.StringUtilitiesTest.java
/** * Asserts that two given int's arrays are equals. *///from w ww.j a v a 2s . co m private static void assertIntervals(int[] expected, int[] actual) { assertTrue(ArrayUtils.toString(expected) + " != " + ArrayUtils.toString(actual), ArrayUtils.isEquals(expected, actual)); }
From source file:org.eobjects.analyzer.configuration.JaxbConfigurationReaderTest.java
public void testReadComplexDataInPojoDatastore() throws Exception { AnalyzerBeansConfiguration configuration = reader .create(new File("src/test/resources/example-configuration-pojo-datastore-with-complex-data.xml")); Datastore datastore = configuration.getDatastoreCatalog().getDatastore("pojo"); assertNotNull(datastore);/* www. j a v a 2s . c o m*/ DatastoreConnection con = datastore.openConnection(); DataContext dc = con.getDataContext(); Table table = dc.getDefaultSchema().getTable(0); Column[] columns = table.getColumns(); assertEquals("[Column[name=Foo,columnNumber=0,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], " + "Column[name=Bar,columnNumber=1,type=MAP,nullable=true,nativeType=null,columnSize=null], " + "Column[name=Baz,columnNumber=2,type=LIST,nullable=true,nativeType=null,columnSize=null], " + "Column[name=bytes,columnNumber=3,type=BINARY,nullable=true,nativeType=null,columnSize=null]]", Arrays.toString(columns)); DataSet ds = dc.query().from(table).select(columns).execute(); assertTrue(ds.next()); assertEquals("Hello", ds.getRow().getValue(0).toString()); assertEquals("{greeting=hello, person=world}", ds.getRow().getValue(1).toString()); assertEquals("[hello, world]", ds.getRow().getValue(2).toString()); assertEquals("{1,2,3,4,5}", ArrayUtils.toString(ds.getRow().getValue(3))); assertTrue(ds.getRow().getValue(1) instanceof Map); assertTrue(ds.getRow().getValue(2) instanceof List); assertTrue(ds.getRow().getValue(3) instanceof byte[]); assertTrue(ds.next()); assertEquals("There", ds.getRow().getValue(0).toString()); assertEquals("{greeting=hi, there you!, person={Firstname=Kasper, Lastname=Srensen}}", ds.getRow().getValue(1).toString()); assertEquals(null, ds.getRow().getValue(2)); assertEquals(null, ds.getRow().getValue(3)); assertTrue(ds.getRow().getValue(1) instanceof Map); assertTrue(ds.next()); assertEquals("World", ds.getRow().getValue(0).toString()); assertEquals(null, ds.getRow().getValue(1)); assertEquals("[Srensen, Kasper]", ds.getRow().getValue(2).toString()); assertEquals("{-1,-2,-3,-4,-5}", ArrayUtils.toString(ds.getRow().getValue(3))); assertTrue(ds.getRow().getValue(2) instanceof List); assertTrue(ds.getRow().getValue(3) instanceof byte[]); }
From source file:org.eobjects.datacleaner.widgets.properties.MultipleMappedEnumsPropertyWidgetTest.java
public void testRestoreEnumValuesFromFile() throws Exception { final DCModule dcModule = new DCModule(); final FileObject file = VFS.getManager().resolveFile("src/test/resources/mapped_columns_job.analysis.xml"); final Injector injector1 = Guice.createInjector(dcModule); final AnalyzerBeansConfiguration configuration = injector1.getInstance(AnalyzerBeansConfiguration.class); final Injector injector2 = OpenAnalysisJobActionListener.open(file, configuration, injector1); final List<AnalyzerJobBuilder<?>> analyzers; if (GraphicsEnvironment.isHeadless()) { analyzers = injector2.getInstance(AnalysisJobBuilder.class).getAnalyzerJobBuilders(); } else {// w w w . j av a 2s.co m final AnalysisJobBuilderWindow window = injector2.getInstance(AnalysisJobBuilderWindow.class); analyzers = window.getAnalysisJobBuilder().getAnalyzerJobBuilders(); } assertEquals(2, analyzers.size()); final AnalyzerJobBuilder<?> completenessAnalyzer = analyzers.get(0); assertEquals("Completeness analyzer", completenessAnalyzer.getDescriptor().getDisplayName()); final Set<ConfiguredPropertyDescriptor> enumProperties = completenessAnalyzer.getDescriptor() .getConfiguredPropertiesByType(CompletenessAnalyzer.Condition[].class, false); assertEquals(1, enumProperties.size()); final Set<ConfiguredPropertyDescriptor> inputProperties = completenessAnalyzer.getDescriptor() .getConfiguredPropertiesForInput(false); assertEquals(1, inputProperties.size()); final ConfiguredPropertyDescriptor enumProperty = enumProperties.iterator().next(); final Enum<?>[] enumValue = (Enum<?>[]) completenessAnalyzer.getConfiguredProperty(enumProperty); assertEquals("{NOT_NULL,NOT_BLANK_OR_NULL}", ArrayUtils.toString(enumValue)); final ConfiguredPropertyDescriptor inputProperty = inputProperties.iterator().next(); final InputColumn<?>[] inputValue = (InputColumn<?>[]) completenessAnalyzer .getConfiguredProperty(inputProperty); final MultipleMappedEnumsPropertyWidget<Enum<?>> inputWidget = new MultipleMappedEnumsPropertyWidget<Enum<?>>( completenessAnalyzer, inputProperty, enumProperty); final PropertyWidget<Enum<?>[]> enumWidget = inputWidget.getMappedEnumsPropertyWidget(); enumWidget.initialize(enumValue); inputWidget.initialize(inputValue); inputWidget.onValueTouched(inputValue); enumWidget.onValueTouched(enumValue); assertEquals("{NOT_NULL,NOT_BLANK_OR_NULL}", ArrayUtils.toString(enumWidget.getValue())); }