Package nexj.core.util

Examples of nexj.core.util.StringId


   public DuplicateKeyException(LazyLocation location, Pair keys, Throwable cause)
   {
      super((keys == null) ? "err.persistence.duplicateKeyClass" : "err.persistence.duplicateKey",
         new Object[]
         {
            new StringId((location == null) ? "Object" : location.getLazyCaption()),
            join(keys, ", ")
         }, cause);

      if (location instanceof ContextHolder)
      {
View Full Code Here


   public OptimisticLockException(LazyLocation location)
   {
      super("err.persistence.optimisticLock",
         new Object[]
         {
            new StringId((location == null) ? "Object" : location.getLazyCaption())
         });

      setLocation(location);
   }
View Full Code Here

      Timestamp ts = (Timestamp) m_unmarshaller.deserialize(new StringReader(m_writer.toString()));
      assertEquals(new Timestamp(12345), ts);

      clear();
      m_marshaller.serialize(new StringId("Stri,ng\"Id"), m_writer);
      assertEquals("{\":id\":\"Stri,ng\\\"Id\"}", m_writer.toString());

      StringId sID = (StringId) m_unmarshaller.deserialize(new StringReader(m_writer.toString()));
      assertEquals((new StringId("Stri,ng\"Id")).toString(), sID.toString());

      clear();
      m_marshaller.serialize(new Character('c'), m_writer);
      assertEquals("{\":char\":\"c\"}", m_writer.toString());
View Full Code Here

               if (bMissing)
               {
                  e = createValidationException(e);

                  ValidationException x = new ValidationException("err.validation.requiredAttribute",
                     new Object[]{new StringId(attribute.getCaption()), new StringId(m_metaclass.getCaption())});

                  x.setClassName(m_metaclass.getName());
                  x.setOIDHolder(this);
                  e.addException(attribute.getName(), x);
               }
            }

            if (attribute.getMaxLength() > 0)
            {
               int nLength = 0;

               if (value instanceof String)
               {
                  nLength = ((String)value).length();
               }
               else if (value instanceof Binary)
               {
                  nLength = ((Binary)value).getData().length;
               }

               if (nLength > attribute.getMaxLength())
               {
                  e = createValidationException(e);

                  ValidationException x = new ValidationException("err.validation.maxDataLength",
                     new Object[]{Primitive.createInteger(attribute.getMaxLength()),
                        new StringId(attribute.getCaption()), new StringId(m_metaclass.getCaption())});

                  x.setClassName(m_metaclass.getName());
                  x.setOIDHolder(this);
                  e.addException(attribute.getName(), x);
               }
            }

            if (bFull)
            {
               if (attribute.isConstrained() &&
                  attribute.getEnumeration() != type &&
                  value != null && e == null)
               {
                  if (((InstanceList)attribute.getEnumeration().invoke("read",
                     new Object[]{null, (type.isPrimitive()) ?
                        Pair.attribute(Metaclass.ENUMERATION_VALUE).eq(value) :
                        new Pair(Symbol.AT).eq(value), null, Primitive.createInteger(-1),
                        Primitive.ZERO_INTEGER, Boolean.FALSE})).isEmpty())
                  {
                     e = createValidationException(e);

                     ValidationException x = new ValidationException("err.validation.enumerationValue",
                        new Object[]{new StringId(attribute.getEnumeration().getCaption()),
                           new StringId(attribute.getCaption()), new StringId(m_metaclass.getCaption())});

                     x.setClassName(m_metaclass.getName());
                     x.setOIDHolder(this);
                     e.addException(attribute.getName(), x);
                  }
               }

               if (attribute.getValidationFunction() != null && e == null)
               {
                  Object result = m_context.getMachine().invoke(attribute.getValidationFunction(), this, value, null);

                  if (result != null)
                  {
                     ValidationException x = null;

                     if (result instanceof Boolean)
                     {
                        if (!((Boolean)result).booleanValue())
                        {
                           x = new ValidationException("err.validation.valueRange",
                              new Object[]{new StringId(attribute.getCaption()), new StringId(m_metaclass.getCaption())});
                        }
                     }
                     else if (result instanceof String)
                     {
                        x = new ValidationException((String)result);
View Full Code Here

   private ValidationException createValidationException(ValidationException e)
   {
      if (e == null)
      {
         e = new ValidationException("err.validation.invalidInstance",
            new Object[]{new StringId(m_metaclass.getCaption())});
         e.setClassName(m_metaclass.getName());
         e.setOIDHolder(this);
      }

      return e;
View Full Code Here

                  if (bCancel)
                  {
                     ConstraintViolationException e = new ConstraintViolationException(
                        "err.persistence.cascadeCancel",
                        new Object[]{new StringId(m_metaclass.getCaption()),
                           getName(), new StringId(attribute.getCaption())});

                     e.setClassName(getClassName());
                     e.setOIDHolder(this);

                     throw e;
View Full Code Here

                     if (nValue < 0 || nValue > 255)
                     {
                        throw new ValidationException("err.validation.numberRange",
                           new Object[]
                           {
                              new StringId(mapping.getAttribute().getCaption()),
                              new StringId(mapping.getAttribute().getMetaclass().getCaption()),
                              Primitive.ZERO_INTEGER,
                              Primitive.createInteger(255)
                           });
                     }

                     break;

                  case 2:
                     nValue = ((Number)toBind(column, column.getValueType().convert(value))).intValue();

                     if (nValue < Short.MIN_VALUE || nValue > Short.MAX_VALUE)
                     {
                        throw new ValidationException("err.validation.numberRange",
                           new Object[]
                           {
                              new StringId(mapping.getAttribute().getCaption()),
                              new StringId(mapping.getAttribute().getMetaclass().getCaption()),
                              Primitive.createInteger(Short.MIN_VALUE),
                              Primitive.createInteger(Short.MAX_VALUE)
                           });
                     }

                     break;
               }

               break;

            case Primitive.DECIMAL_ORDINAL:
               nPrecision = column.getPrecision(getMaxDecimalPrecision());

               int nScale = column.getScale(getMaxDecimalPrecision());
               BigDecimal decMax = BigDecimal.TEN.pow(nPrecision - nScale);

               if (((BigDecimal)toBind(column, column.getValueType().convert(value))).abs().setScale(nScale,
                  RoundingMode.HALF_UP).compareTo(decMax) >= 0)
               {
                  if (nScale > 0)
                  {
                     decMax = decMax.subtract(BigDecimal.ONE.divide(BigDecimal.TEN.pow(nScale)));
                  }

                  throw new ValidationException("err.validation.numberRange",
                     new Object[]
                     {
                        new StringId(mapping.getAttribute().getCaption()),
                        new StringId(mapping.getAttribute().getMetaclass().getCaption()),
                        decMax.negate(),
                        decMax
                     });
               }

               break;

            case Primitive.TIMESTAMP_ORDINAL:
               long lTime = ((Timestamp)toBind(column, column.getValueType().convert(value))).getTime();

               if (lTime < getMinTime() || lTime > getMaxTime())
               {
                  throw new ValidationException("err.validation.dateRange",
                     new Object[]
                     {
                        new StringId(mapping.getAttribute().getCaption()),
                        new StringId(mapping.getAttribute().getMetaclass().getCaption()),
                        new Timestamp(getMinTime()),
                        new Timestamp(getMaxTime())
                     });
               }
View Full Code Here

TOP

Related Classes of nexj.core.util.StringId

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.