Package java.util

Examples of java.util.LinkedHashMap


    /**
     * @see org.andromda.metafacades.uml.FrontEndUseCase#getViewVariables()
     */
    protected List handleGetViewVariables()
    {
        final Map pageVariableMap = new LinkedHashMap();

        // - page variables can occur twice or more in the usecase if their
        //   names are the same for different forms, storing them in a map
        //   solves this issue because those names do not have the action-name prefix
        final Collection views = this.getViews();
        for (final Iterator pageIterator = views.iterator(); pageIterator.hasNext();)
        {
            final FrontEndView view = (FrontEndView)pageIterator.next();
            final Collection variables = view.getVariables();
            for (final Iterator variableIterator = variables.iterator(); variableIterator.hasNext();)
            {
                FrontEndParameter variable = (FrontEndParameter)variableIterator.next();
                final String name = variable.getName();
                if (name != null && name.trim().length() > 0)
                {
                    final FrontEndParameter existingVariable = (FrontEndParameter)pageVariableMap.get(name);
                    if (existingVariable != null)
                    {
                        if (existingVariable.isTable())
                        {
                            variable = existingVariable;
                        }
                    }
                    pageVariableMap.put(
                        name,
                        variable);
                }
            }
        }
        return new ArrayList(pageVariableMap.values());
    }
View Full Code Here


    /**
     * @see org.andromda.metafacades.uml.FrontEndView#getVariables()
     */
    protected List handleGetVariables()
    {
        final Map variablesMap = new LinkedHashMap();
        final Collection incoming = this.getIncoming();
        for (final Iterator iterator = incoming.iterator(); iterator.hasNext();)
        {
            final TransitionFacade transition = (TransitionFacade)iterator.next();
            final EventFacade trigger = transition.getTrigger();
            if (trigger != null)
            {
                for (final Iterator parameterIterator = trigger.getParameters().iterator();
                    parameterIterator.hasNext();)
                {
                    final ModelElementFacade modelElement = (ModelElementFacade)parameterIterator.next();
                    variablesMap.put(
                        modelElement.getName(),
                        modelElement);
                }
            }
        }
        return new ArrayList(variablesMap.values());
    }
View Full Code Here

    return this.getResultMap(new HashMap(), queryString, keyMethod);
  }
 
  public Map getResultMap (Map parameters, String queryString, String keyMethod) {
    List results = this.getResults(parameters, queryString, -1, -1);
    Map map = new LinkedHashMap();
    for (Object result : results) {
      try {
        Method method = result.getClass().getMethod(keyMethod);
        String key = String.valueOf( method.invoke(result) );
        map.put(key, result);
      } catch (Exception e) {
        throw new IllegalArgumentException("Could not find field: " + keyMethod, e);
      }
    }
    return map;
View Full Code Here

   * @return A new EMF based on the unit setup
   */
  public static EntityManagerFactory createFactory (PersistenceUnitInfo info) {
    Class<? extends PersistenceProvider> ppc = ReflectionUtil.getClass( info.getPersistenceProviderClassName() );
    PersistenceProvider provider = ReflectionUtil.newInstance(ppc, new Class[0]);
    return provider.createContainerEntityManagerFactory(info, new LinkedHashMap( info.getProperties() ));
  }
View Full Code Here

    /**
     * @see org.andromda.cartridges.jsf.metafacades.JSFView#getForwards()
     */
    protected List handleGetForwards()
    {
        final Map forwards = new LinkedHashMap();
        for (final Iterator iterator = this.getActions().iterator(); iterator.hasNext();)
        {
            final FrontEndAction action = (FrontEndAction)iterator.next();
            if (action != null && !action.isUseCaseStart())
            {
                for (final Iterator forwardIterator = action.getActionForwards().iterator(); forwardIterator.hasNext();)
                {
                    final Object forward = forwardIterator.next();
                    if (forward instanceof JSFForward)
                    {
                        forwards.put(((JSFForward)forward).getName(), forward);
                    }
                    else if (forward instanceof JSFAction)
                    {
                        forwards.put(((JSFAction)forward).getName(), forward);
                    }
                }
            }
        }
        return new ArrayList(forwards.values());
    }
View Full Code Here

    /**
     * @see org.andromda.cartridges.jsf.metafacades.JSFView#getBackingValueVariables()
     */
    protected List handleGetBackingValueVariables()
    {
        final Map variables = new LinkedHashMap();
        for (final Iterator iterator = this.getAllActionParameters().iterator(); iterator.hasNext();)
        {
            final Object object = iterator.next();
            if (object instanceof JSFParameter)
            {
                final JSFParameter parameter = (JSFParameter)object;
                final String parameterName = parameter.getName();
                final Collection attributes = parameter.getAttributes();
                if (attributes.isEmpty())
                {
                    if (parameter.isBackingValueRequired() || parameter.isSelectable())
                    {
                        variables.put(parameterName, parameter);
                    }
                }
                else
                {
                    boolean hasBackingValue = false;
                    for (final Iterator attributeIterator = attributes.iterator(); attributeIterator.hasNext();)
                    {
                        final JSFAttribute attribute = (JSFAttribute)attributeIterator.next();
                        if (attribute.isSelectable(parameter) || attribute.isBackingValueRequired(parameter))
                        {
                            hasBackingValue = true;
                            break;
                        }
                    }
                    if (hasBackingValue)
                    {
                        variables.put(parameterName, parameter);
                    }
                }
            }
        }
        return new ArrayList(variables.values());
    }
View Full Code Here

    public static java.util.Collection getValidatorVars(
        final ModelElementFacade element,
        final ClassifierFacade type,
        final ParameterFacade ownerParameter)
    {
        final Map vars = new LinkedHashMap();
        if (element != null && type != null)
        {
            final String format = JSFUtils.getInputFormat(element);
            if (format != null)
            {
                final boolean isRangeFormat = JSFUtils.isRangeFormat(format);

                if (isRangeFormat)
                {
                    final String min = "min";
                    final String max = "max";
                    vars.put(
                        min,
                        Arrays.asList(new Object[] {min, JSFUtils.getRangeStart(format)}));
                    vars.put(
                        max,
                        Arrays.asList(new Object[] {max, JSFUtils.getRangeEnd(format)}));
                }
                else
                {
                    final Collection formats = element.findTaggedValues(JSFProfile.TAGGEDVALUE_INPUT_FORMAT);
                    for (final Iterator formatIterator = formats.iterator(); formatIterator.hasNext();)
                    {
                        final String additionalFormat = String.valueOf(formatIterator.next());
                        final String minlength = "minlength";
                        final String maxlength = "maxlength";
                        final String mask = "mask";
                        if (JSFUtils.isMinLengthFormat(additionalFormat))
                        {
                            vars.put(
                                minlength,
                                Arrays.asList(new Object[] {minlength, JSFUtils.getMinLengthValue(additionalFormat)}));
                        }
                        else if (JSFUtils.isMaxLengthFormat(additionalFormat))
                        {
                            vars.put(
                                maxlength,
                                Arrays.asList(new Object[] {maxlength, JSFUtils.getMaxLengthValue(additionalFormat)}));
                        }
                        else if (JSFUtils.isPatternFormat(additionalFormat))
                        {
                            vars.put(
                                mask,
                                Arrays.asList(new Object[] {mask, JSFUtils.getPatternValue(additionalFormat)}));
                        }
                    }
                }
            }
            String inputFormat;
            if (element instanceof JSFAttribute)
            {
                inputFormat = ((JSFAttribute)element).getFormat();
            }
            else if (element instanceof JSFParameter)
            {
                inputFormat = ((JSFParameter)element).getFormat();
            }
            else
            {
                throw new RuntimeException("'element' is an invalid type, it must be either an instance of '" +
                    JSFAttribute.class.getName() + "' or '" + JSFParameter.class.getName() + "'");
            }
            if (JSFUtils.isDate(type))
            {
                final String datePatternStrict = "datePatternStrict";
                if (format != null && JSFUtils.isStrictDateFormat(format))
                {
                    vars.put(
                        datePatternStrict,
                        Arrays.asList(new Object[] {datePatternStrict, inputFormat}));
                }
                else
                {
                    final String datePattern = "datePattern";
                    vars.put(
                        datePattern,
                        Arrays.asList(new Object[] {datePattern, inputFormat}));
                }
            }
            if (JSFUtils.isTime(type))
            {
                final String timePattern = "timePattern";
                vars.put(
                    timePattern,
                    Arrays.asList(new Object[] {timePattern, inputFormat}));
            }

            final String validWhen = JSFUtils.getValidWhen(element);
            if (validWhen != null)
            {
                final String test = "test";
                vars.put(
                    test,
                    Arrays.asList(new Object[] {test, validWhen}));
            }
           
            final String equal = JSFUtils.getEqual(element, ownerParameter);
            if (equal != null)
            {
                final String fieldName = "fieldName";
                vars.put(
                    fieldName,
                    Arrays.asList(new Object[] {fieldName, equal}));
            }
        }

        // - custom (parameterized) validators are allowed here
        //   in this case we will reuse the validator arg values
        final Collection taggedValues = element.findTaggedValues(JSFProfile.TAGGEDVALUE_INPUT_VALIDATORS);
        for (final Iterator iterator = taggedValues.iterator(); iterator.hasNext();)
        {
            final String validator = String.valueOf(iterator.next());

            // - guaranteed to be of the same length
            final List validatorVars = JSFUtils.parseValidatorVars(validator);
            final List validatorArgs = JSFUtils.parseValidatorArgs(validator);

            for (int ctr = 0; ctr < validatorVars.size(); ctr++)
            {
                final String validatorVar = (String)validatorVars.get(ctr);
                final String validatorArg = (String)validatorArgs.get(ctr);
                vars.put(
                    validatorVar,
                    Arrays.asList(new Object[] {validatorVar, validatorArg}));
            }
        }
        return vars.values();
    }
View Full Code Here

        final JSFValidator validator)
    {
        Map map = (Map)this.validators.get(type);
        if (map == null)
        {
            map = new LinkedHashMap();
            this.validators.put(
                type,
                map);
        }
        if (id != null)
View Full Code Here

     */
    protected Map handleGetAllMessages()
    {

        final boolean normalize = this.isNormalizeMessages();
        final Map messages = (normalize) ? (Map)new TreeMap() : (Map)new LinkedHashMap();

        // - only retrieve the messages for the entry use case (i.e. the use case
        //   where the application begins)
        if (this.isEntryUseCase())
        {
View Full Code Here

    /**
     * @see org.andromda.cartridges.jsf.metafacades.JSFUseCase#getForwards()
     */
    protected List handleGetForwards()
    {
        final Map forwards = new LinkedHashMap();
        for (final Iterator iterator = this.getActions().iterator(); iterator.hasNext();)
        {
            final FrontEndAction action = (FrontEndAction)iterator.next();
            for (final Iterator forwardIterator = action.getActionForwards().iterator(); forwardIterator.hasNext();)
            {
                final Object forward = forwardIterator.next();
                if (forward instanceof JSFForward)
                {
                    forwards.put(((ModelElementFacade)forward).getName(), forward);
                }
            }
        }
        return new ArrayList(forwards.values());
    }
View Full Code Here

TOP

Related Classes of java.util.LinkedHashMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.