Package org.nasutekds.messages

Examples of org.nasutekds.messages.Message


        if (a.hasOption(OPTION_PENDING_VALUES))
        {
          if (pendingUnit != null)
          {
            // We cannot have multiple pending value sets.
            Message message =
                ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(a.getName());
            throw new ConfigException(message);
          }


          if (a.isEmpty())
          {
            // This is illegal -- it must have a value.
            Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName());
            throw new ConfigException(message);
          }
          else
          {
            Iterator<AttributeValue> iterator = a.iterator();

            String valueString = iterator.next().getValue().toString();

            if (iterator.hasNext())
            {
              // This is illegal -- the attribute is single-valued.
              Message message =
                  ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getName());
              throw new ConfigException(message);
            }

            try
            {
              int spacePos = valueString.indexOf(' ');
              pendingIntValue =
                   Long.parseLong(valueString.substring(0, spacePos));
              pendingUnit = valueString.substring(spacePos+1).trim();
            }
            catch (Exception e)
            {
              Message message = ERR_CONFIG_ATTR_COULD_NOT_PARSE_INT_COMPONENT.
                  get(valueString, a.getName(), String.valueOf(e));
              throw new ConfigException(message);
            }


            // Get the unit and use it to determine the corresponding
            // multiplier.
            if (! units.containsKey(pendingUnit))
            {
              Message message =
                  ERR_CONFIG_ATTR_INVALID_UNIT.get(pendingUnit, a.getName());
              throw new ConfigException(message);
            }

            double multiplier = units.get(activeUnit);
            pendingCalculatedValue = (long) (multiplier * pendingIntValue);


            // Check the bounds set for this attribute.
            if (hasLowerBound && (pendingCalculatedValue < lowerBound))
            {
              Message message = ERR_CONFIG_ATTR_INT_BELOW_LOWER_BOUND.get(
                  a.getName(), pendingCalculatedValue, lowerBound);
              throw new ConfigException(message);
            }

            if (hasUpperBound && (pendingCalculatedValue > upperBound))
            {
              Message message = ERR_CONFIG_ATTR_INT_ABOVE_UPPER_BOUND.get(
                  a.getName(), pendingCalculatedValue, upperBound);
              throw new ConfigException(message);
            }
          }
        }
        else
        {
          // This is illegal -- only the pending option is allowed for
          // configuration attributes.
          Message message =
              ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(a.getName());
          throw new ConfigException(message);
        }
      }
      else
      {
        // This must be the active value.
        if (activeUnit != null)
        {
          // We cannot have multiple active value sets.
          Message message =
              ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(a.getName());
          throw new ConfigException(message);
        }


        if (a.isEmpty())
        {
          // This is illegal -- it must have a value.
          Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName());
          throw new ConfigException(message);
        }
        else
        {
          Iterator<AttributeValue> iterator = a.iterator();

          String valueString = iterator.next().getValue().toString();

          if (iterator.hasNext())
          {
            // This is illegal -- the attribute is single-valued.
            Message message =
                ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getName());
            throw new ConfigException(message);
          }

          try
          {
            int spacePos = valueString.indexOf(' ');
            activeIntValue =
                 Long.parseLong(valueString.substring(0, spacePos));
            activeUnit = valueString.substring(spacePos+1).trim();
          }
          catch (Exception e)
          {
            Message message = ERR_CONFIG_ATTR_COULD_NOT_PARSE_INT_COMPONENT.get(
                valueString, a.getName(), String.valueOf(e));
            throw new ConfigException(message);
          }


          // Get the unit and use it to determine the corresponding multiplier.
          if (! units.containsKey(activeUnit))
          {
            Message message =
                ERR_CONFIG_ATTR_INVALID_UNIT.get(activeUnit, a.getName());
            throw new ConfigException(message);
          }

          double multiplier = units.get(activeUnit);
          activeCalculatedValue = (long) (multiplier * activeIntValue);


          // Check the bounds set for this attribute.
          if (hasLowerBound && (activeCalculatedValue < lowerBound))
          {
            Message message = ERR_CONFIG_ATTR_INT_BELOW_LOWER_BOUND.get(
                a.getName(), activeCalculatedValue, lowerBound);
            throw new ConfigException(message);
          }

          if (hasUpperBound && (activeCalculatedValue > upperBound))
          {
            Message message = ERR_CONFIG_ATTR_INT_ABOVE_UPPER_BOUND.get(
                a.getName(), activeCalculatedValue, upperBound);
            throw new ConfigException(message);
          }
        }
      }
    }

    if (activeUnit == null)
    {
      // This is not OK.  The value set must contain an active value.
      Message message = ERR_CONFIG_ATTR_NO_ACTIVE_VALUE_SET.get(getName());
      throw new ConfigException(message);
    }

    if (pendingUnit == null)
    {
View Full Code Here


    {
      setValue((String) value);
    }
    else
    {
      Message message = ERR_CONFIG_ATTR_INT_WITH_UNIT_INVALID_TYPE.get(
          String.valueOf(value), getName(), value.getClass().getName());
      throw new ConfigException(message);
    }
  }
View Full Code Here

   * resulting formatted text.
   * @return the plain text representation of an error for the given text.
   */
  public Message getFormattedError(Message text, boolean applyMargin)
  {
    Message result;
    if (applyMargin)
    {
      result = new MessageBuilder().append(Constants.LINE_SEPARATOR)
              .append(text).toMessage();
    } else
View Full Code Here

   * resulting formatted text.
   * @return the plain text representation of a warning for the given text.
   */
  public Message getFormattedWarning(Message text, boolean applyMargin)
  {
    Message result;
    if (applyMargin)
    {
      result = new MessageBuilder(Constants.LINE_SEPARATOR)
              .append(text).toMessage();
    } else
View Full Code Here

    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    Insets pInsets = UIFactory.getCurrentStepPanelInsets();
    gbc.insets.left = 0;
    gbc.fill = GridBagConstraints.BOTH;
    Message msg = INFO_ERROR_BROWSER_DISPLAY_MSG.get(url);
    JTextComponent tf =
        UIFactory.makeHtmlPane(msg,
            UIFactory.ERROR_DIALOG_FONT);
    tf.setOpaque(false);
    tf.setEditable(false);
View Full Code Here

    this.description      = description;
    this.isValueSetByProperty = false ;

    if ((shortIdentifier == null) && (longIdentifier == null))
    {
      Message message = ERR_ARG_NO_IDENTIFIER.get(name);
      throw new ArgumentException(message);
    }

    if (needsValue && (valuePlaceholder == null))
    {
      Message message = ERR_ARG_NO_VALUE_PLACEHOLDER.get(name);
      throw new ArgumentException(message);
    }

    values    = new LinkedList<String>();
    isPresent = false;
View Full Code Here

  public int getIntValue()
         throws ArgumentException
  {
    if (values.isEmpty())
    {
      Message message = ERR_ARG_NO_INT_VALUE.get(name);
      throw new ArgumentException(message);
    }

    Iterator<String> iterator = values.iterator();
    String valueString = iterator.next();

    int intValue;
    try
    {
      intValue = Integer.parseInt(valueString);
    }
    catch (Exception e)
    {
      Message message = ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, name);
      throw new ArgumentException(message, e);
    }

    if (iterator.hasNext())
    {
      Message message = ERR_ARG_INT_MULTIPLE_VALUES.get(name);
      throw new ArgumentException(message);
    }
    else
    {
      return intValue;
View Full Code Here

      {
        intList.add(Integer.valueOf(valueString));
      }
      catch (Exception e)
      {
        Message message = ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, name);
        throw new ArgumentException(message, e);
      }
    }

    return intList;
View Full Code Here

                  ERR_CONFIRMATION_TRIES_LIMIT_REACHED.get(
                      CONFIRMATION_MAX_TRIES));
            }
          }
          System.out.println();
          Message cont = INFO_CONTINUE_BUTTON_LABEL.get();
          Message cancel = INFO_CANCEL_BUTTON_LABEL.get();
          UserInteraction ui = new CliUserInteraction();
          if (cancel.equals(ui.confirm(
              INFO_UPGRADE_CONFIRM_TITLE.get(),
              INFO_UPGRADE_CONFIRM_PROMPT.get(
                      uud.getInstallPackage().getAbsolutePath()),
              INFO_REVERT_CONFIRM_TITLE.get(),
              UserInteraction.MessageType.WARNING,
View Full Code Here

  public boolean getBooleanValue()
         throws ArgumentException
  {
    if (values.isEmpty())
    {
      Message message = ERR_ARG_NO_BOOLEAN_VALUE.get(name);
      throw new ArgumentException(message);
    }

    Iterator<String> iterator = values.iterator();
    String valueString = toLowerCase(iterator.next());

    boolean booleanValue;
    if (valueString.equals("true") || valueString.equals("yes") ||
        valueString.equals("on") || valueString.equals("1"))
    {
      booleanValue = true;
    }
    else if (valueString.equals("false") || valueString.equals("no") ||
             valueString.equals("off") || valueString.equals("0"))
    {
      booleanValue = false;
    }
    else
    {
      Message message = ERR_ARG_CANNOT_DECODE_AS_BOOLEAN.get(valueString, name);
      throw new ArgumentException(message);
    }

    if (iterator.hasNext())
    {
      Message message = ERR_ARG_BOOLEAN_MULTIPLE_VALUES.get(name);
      throw new ArgumentException(message);
    }
    else
    {
      return booleanValue;
View Full Code Here

TOP

Related Classes of org.nasutekds.messages.Message

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.