Package nexj.core.meta

Examples of nexj.core.meta.Primitive


               {
                  Object original = list.get(i);

                  if (convertedList == null)
                  {
                     Primitive primitive = Primitive.primitiveOf(original);

                     if (type != primitive)
                     {
                        convertedList = new ArrayList(list.size());
View Full Code Here


   /**
    * Gets a default MSH value.
    */
   protected Object getDefaultMSHValue(MessagePart part)
   {
      Primitive primitive = null;
      TransferObject tobj;

      if (part instanceof PrimitiveMessagePart)
      {
         primitive = ((PrimitiveMessagePart)part).getType();
      }

      switch (((HL7MessagePartMapping)part.getMapping()).getSeq())
      {
         case 7: // Message time
            if (primitive != null)
            {
               return primitive.convert(new Timestamp(System.currentTimeMillis()));
            }

            break;

         case 9: // Message type
            String sType = ((HL7MessagePartMapping)m_message.getRoot().getMapping()).getName();
            String sEvent = null;

            int i = sType.indexOf('^');

            if (i >= 0)
            {
               sEvent = sType.substring(i + 1);
               sType = sType.substring(0, i);
            }

            if (primitive != null)
            {
               return sType;
            }

            tobj = new TransferObject(2);
            setValue(tobj, (CompositeMessagePart)part, 1, sType);
            setValue(tobj, (CompositeMessagePart)part, 2, sEvent);

            return tobj;

         case 10: // Control Id
            if (primitive != null)
            {
               return primitive.convert(getControlId());
            }

            break;

         case 11: // Processing Id
View Full Code Here

         return null;
      }

      if (m_sType != null)
      {
         Primitive type = (Primitive)s_typePrimitiveMap.get(m_sType);

         if (type != null)
         {
            switch (type.getOrdinal())
            {
               case Primitive.BINARY_ORDINAL:
                  try
                  {
                     if (m_sType.charAt(0) == 'b'// base64Binary
                     {
                        return Binary.fromBase64(sValue);
                     }

                     return Binary.parse(sValue)// hexBinary
                  }
                  catch (IOException ex)
                  {
                     throw ObjUtil.rethrow(ex);
                  }

               case Primitive.TIMESTAMP_ORDINAL:
                  if (m_sType.length() == 8// dateTime
                  {
                     return SOAPUtil.parseDateTime(sValue, true, true, null);
                  }

                  if (m_sType.charAt(0) == 'd'// date
                  {
                     return SOAPUtil.parseDateTime(sValue, true, false, null);
                  }

                  return SOAPUtil.parseDateTime(sValue, false, true, null)// time

               default:
                  return type.convert(sValue);
            }
         }
      }

      return sValue;
View Full Code Here

            String sTypeName = rs.getString("TYPE_NAME");
            int nType = rs.getInt("DATA_TYPE");
            int nPrecision = rs.getInt("COLUMN_SIZE");
            int nScale = rs.getInt("DECIMAL_DIGITS");
            byte nAllocation = Column.FIXED;
            Primitive type = null;
           
            switch (nType)
            {
               case Types.BIGINT:
                  type = Primitive.LONG;
                  nPrecision = 0;
                  nScale = 0;
                  break;
              
               case Types.BINARY:
                  type = Primitive.BINARY;
                  nScale = 0;
                  break;
              
               case Types.BIT:
               case Types.BOOLEAN:
                  type = Primitive.BOOLEAN;
                  nPrecision = 0;
                  nScale = 0;
                  break;

               case Types.BLOB:
               case Types.LONGVARBINARY:
                  type = Primitive.BINARY;
                 
                  if (nPrecision <= 0x4000)
                  {
                     nPrecision = Integer.MAX_VALUE;
                  }

                  nScale = 0;
                  nAllocation = (nType == Types.BLOB) ? Column.LOCATOR : Column.VARYING;
                  break;

               case Types.CHAR:
                  sTypeName = sTypeName.toLowerCase(Locale.ENGLISH);

                  if (sTypeName.equals("uniqueidentifier"))
                  {
                     type = Primitive.BINARY;
                     nPrecision = 16;
                     nScale = 0;
                  }
                  else
                  {
                     type = Primitive.STRING;
                     nScale = 0;
                  }

                  break;

               case Types.CLOB:
               case Types.LONGVARCHAR:
                  type = Primitive.STRING;
                    
                  if (nPrecision <= 0x4000)
                  {
                     nPrecision = Integer.MAX_VALUE;
                  }
  
                  nScale = 0;
                  nAllocation = (nType == Types.CLOB) ? Column.LOCATOR : Column.VARYING;
                  break;
              
               case Types.DATE:
               case Types.TIME:
               case Types.TIMESTAMP:
                  type = Primitive.TIMESTAMP;
                  nPrecision = 0;
                  nScale = 0;
                  break;
              
               case Types.DECIMAL:
               case Types.NUMERIC:
                  type = Primitive.DECIMAL;
                 
                  if (nScale == 0 && nPrecision <= 20)
                  {
                     if (nPrecision <= 10)
                     {
                        type = Primitive.INTEGER;

                        if (nPrecision <= 3)
                        {
                           nPrecision = 1;
                        }
                        else if (nPrecision <= 5)
                        {
                           nPrecision = 2;
                        }
                        else
                        {
                           nPrecision = 0;
                        }
                     }
                     else
                     {
                        type = Primitive.LONG;
                        nPrecision = 0;
                     }
                  }

                  break;

               case Types.DOUBLE:
               case Types.FLOAT:
                  type = Primitive.DOUBLE;
                  nPrecision = 0;
                  nScale = 0;
                  break;

               case Types.INTEGER:
                  type = Primitive.INTEGER;
                  nPrecision = 0;
                  nScale = 0;
                  break;

               case Types.SMALLINT:
                  type = Primitive.INTEGER;
                  nPrecision = 2;
                  nScale = 0;
                  break;

               case Types.TINYINT:
                  type = Primitive.INTEGER;
                  nPrecision = 1;
                  nScale = 0;
                  break;

               case Types.REAL:
                  type = Primitive.FLOAT;
                  nPrecision = 0;
                  nScale = 0;
                  break;
              
               case Types.VARBINARY:
                  type = Primitive.BINARY;
                  nScale = 0;
                  nAllocation = Column.VARYING;
                  break;

               case Types.VARCHAR:
                  type = Primitive.STRING;
                  nScale = 0;
                  nAllocation = Column.VARYING;
                  break;

               default:
                  sTypeName = sTypeName.toLowerCase(Locale.ENGLISH);

                  if (sTypeName.equals("nchar"))
                  {
                     type = Primitive.STRING;
                     nPrecision >>= 1;
                     nScale = 0;
                  }
                  else if (sTypeName.equals("nvarchar2") || sTypeName.equals("nvarchar"))
                  {
                     type = Primitive.STRING;
                     nPrecision >>= 1;
                     nScale = 0;
                     nAllocation = Column.VARYING;
                  }
                  else if (sTypeName.equals("binary_double"))
                  {
                     type = Primitive.DOUBLE;
                     nPrecision = 0;
                     nScale = 0;
                  }
                  else if (sTypeName.equals("binary_float"))
                  {
                     type = Primitive.FLOAT;
                     nPrecision = 0;
                     nScale = 0;
                  }
                  else if (sTypeName.startsWith("timestamp"))
                  {
                     type = Primitive.TIMESTAMP;
                     nPrecision = 0;
                     nScale = 0;
                  }
                  else if (sTypeName.equals("nclob") || sTypeName.equals("clob"))
                  {
                     type = Primitive.STRING;
                    
                     if (nPrecision <= 0x4000)
                     {
                        nPrecision = Integer.MAX_VALUE;
                     }
  
                     nScale = 0;
                     nAllocation = Column.LOCATOR;
                  }
                  else if (sTypeName.equals("blob"))
                  {
                     type = Primitive.BINARY;
                       
                     if (nPrecision <= 0x4000)
                     {
                        nPrecision = Integer.MAX_VALUE;
                     }
     
                     nScale = 0;
                     nAllocation = Column.LOCATOR;
                  }
              
                  break;
            }

            if (nPrecision < 0)
            {
               nPrecision = 0;
            }

            if (s_logger.isDebugEnabled())
            {
               s_logger.debug("Read column \"" + table.getName() + "." + column.getName() + "\" " +
                  sTypeName + "(" + rs.getInt("COLUMN_SIZE") + "," + rs.getInt("DECIMAL_DIGITS") +
                  "), SQLType=" + nType + " -> " + ((type == null) ? "ignored: unsupported type" : type.getName() +
                  "(" + nPrecision + "," + nScale + "), allocation=" + nAllocation));
            }

            if (type != null)
            {
View Full Code Here

            m_attributeGenerationList.add(new ContextFixup(m_helper)
            {
               public void fixup()
               {
                  Primitive type = null;

                  for (Metaclass base = ((metaclass == null) ?
                     m_metadata.getMetaclass(sEnumerationName) : metaclass).getBase();
                     base != null; base = base.getBase())
                  {
                     Attribute attribute = base.findAttribute("value");

                     if (attribute != null)
                     {
                        if (!attribute.getType().isPrimitive())
                        {
                           throw new MetadataException("err.meta.enumBaseValueType",
                              new Object[]{base.getName(), sEnumerationName});
                        }

                        if (attribute.isStatic())
                        {
                           throw new MetadataException("err.meta.enumBaseValueScope",
                              new Object[]{base.getName(), sEnumerationName});
                        }

                        type = (Primitive)attribute.getType();

                        break;
                     }
                  }

                  if (type == null)
                  {
                     throw new MetadataException("err.meta.enumBaseValue", new Object[]{sEnumerationName});
                  }

                  for (int i = 0, n = fixupList.size(); i != n; i += 3)
                  {
                     Object value = fixupList.get(i + 1);

                     if (type != Primitive.STRING)
                     {
                        value = type.convert(value);
                     }

                     if (!valueSet.add(value))
                     {
                        throw new MetadataException("err.meta.enumValueDup",
View Full Code Here

       * @return The coerced type.
       * @throws TypeMismatchException if the coercion is not supported.
       */
      protected Primitive getCoercedType(Primitive left, Primitive right)
      {
         Primitive type = COERCION_ARRAY[left.getOrdinal() * Primitive.MAX_COUNT + right.getOrdinal()];

         if (type == null)
         {
            throw new TypeMismatchException(getSymbol());
         }
View Full Code Here

            RelationalPrimitiveMapping[] mappings = (RelationalPrimitiveMapping[])itr.next();
            RelationalPrimitiveMapping mapping = mappings[m_nOrdinal];

            if (mapping != null)
            {
               Primitive type = (Primitive)mapping.getAttribute().getType();

               if (type != Primitive.ANY)
               {
                  if (attribute != null && m_type != type)
                  {
View Full Code Here

      {
         m_writer.startElement("KeyParts");

         for (int i = 0; i < nCount; i++)
         {
            Primitive type = key.getPartType(i);

            m_writer.openElement("KeyPart");
            m_writer.writeAttribute("type", type.getName());

            for (int k = 0, nAttrCount = metaclass.getInstanceAttributeCount(); k < nAttrCount; k++)
            {
               Attribute attribute = metaclass.getInstanceAttribute(k);
               AttributeMapping attributeMapping = mapping.getAttributeMapping(attribute);
View Full Code Here

         {
            Object left = machine.getArg(0, nArgCount);

            if (left != null)
            {
               Primitive leftType = Primitive.primitiveOf(left);
               Primitive rightType, resultType;
               BinaryFunction fun;
               Object right;

               for (int i = 1; i < nArgCount; ++i)
               {
View Full Code Here

      {
         verifyMinArgCount(nArgCount, 2);

         Object left = machine.getArg(0, nArgCount);

         Primitive leftType = Primitive.primitiveOf(left);
         Primitive rightType, coercedType = null;
         BinaryFunction fun;
         Object right;

         for (int i = 1; i < nArgCount; ++i)
         {
View Full Code Here

TOP

Related Classes of nexj.core.meta.Primitive

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.