Package nexj.core.meta

Examples of nexj.core.meta.Type


    * @param arg The argument for which to unmarshal the value (not null).
    * @throws IOException If an input error occurs.
    */
   protected Object unmarshal(Argument arg)
   {
      Type type = arg.getType();

      // Primitive types know how to convert from String
      if (type instanceof Primitive && type != Primitive.ANY)
      {
         if (!arg.isCollection())
         {
            return type.convert(getParameter(arg.getName()));
         }

         String[] sValueArray = getParameters(arg.getName()); // get all values of collection

         if (sValueArray == null)
         {
            return null;
         }

         Object[] valueArray = new Object[sValueArray.length];

         for (int i = 0; i < valueArray.length; ++i)
         {
            valueArray[i] = type.convert(sValueArray[i]);
         }

         return valueArray;
      }
      else if (type instanceof Metaclass) // Metaclass types use OID to pass instance
      {
         if (!arg.isCollection())
         {
            String sValue = getParameter(arg.getName());

            if (sValue == null)
            {
               return null;
            }

            TransferObject value = new TransferObject(type.getName(), 0);

            value.setOID(OID.fromBinary(Binary.parse(sValue)));

            return value;
         }

         String[] sValueArray = getParameters(arg.getName()); // get all values of collection

         if (sValueArray == null)
         {
            return null;
         }

         String sMetaclass = type.getName();
         TransferObject[] valueArray = new TransferObject[sValueArray.length];

         for (int i = 0; i < valueArray.length; ++i)
         {
            valueArray[i] = new TransferObject(sMetaclass, 0);
View Full Code Here


         m_writer.startElement("request");

            for (int i = 0, nCount = event.getArgumentCount(); i < nCount; ++i)
            {
               Argument arg = event.getArgument(i);
               Type type = arg.getType();
               boolean bVarArg = event.isVarArg() && i == nCount - 1;

               if (type instanceof Metaclass)
               {
                  type = Primitive.STRING; // OID parameter
View Full Code Here

         }

         for (int k = 0, nArgCount = event.getArgumentCount(); k < nArgCount; ++k)
         {
            Argument arg = event.getArgument(k);
            Type type = arg.getType();

            setRequiredType(type, arg.isCollection());

            if (event.isVarArg() && k == nArgCount - 1) //varArg args might require arrays e.g. WSDL
            {
View Full Code Here

         request.addInvocation(
            m_instance, m_event.getName(), (m_argList == null) ? null : m_argList.toArray(), null);
      }

      Argument result = m_event.getResult();
      Type resultType = (result == null) ? null : result.getType();
      Object resultObj = server.invoke(request).getResult(0);

      if (m_resultElement == null)
      {
         return resultObj; // no defined result element tag
View Full Code Here

      }

      // check that all argument types are supported, otherwise will not have valid event arguments
      for (int i = 0, nCount = event.getArgumentCount(); i < nCount; ++i)
      {
         Type type = event.getArgument(i).getType();

         if (type instanceof Metaclass && !isSupportedMetaclass((Metaclass)type))
         {
            return false;
         }
View Full Code Here

   /**
    * @see nexj.core.rpc.xml.WSDLGenerator#isExportedEventResult(nexj.core.meta.Event)
    */
   protected boolean isExportedEventResult(Event event)
   {
      Type type = (event.getResult() == null) ? null : event.getResult().getType();

      return type != null && // untyped result not supported
             type != Primitive.ANY && // polymorphic result type not supported
             !(type instanceof Metaclass && !isSupportedMetaclass((Metaclass)type));
   }
View Full Code Here

                     }

                     for (int k = 0, nArgCount = event.getArgumentCount(); k < nArgCount; ++k)
                     {
                        Argument arg = event.getArgument(k);
                        Type type = arg.getType();
                        boolean bVarArg = event.isVarArg() && k == nArgCount - 1;
                        QName qType = getQualifiedTypeCached(type, bVarArg);

                        // don't use nillable="true" as that will automatically set minOccurs="1"
                        // in MS.NET
                        writeElement(
                           arg.getName(), null, qType,
                           (arg.isRequired()) ? 1 : 0, (arg.isCollection()) ? -1 : 1, false,
                           arg.getDescription());
                     }

                  m_writer.endElement("sequence");
               m_writer.endElement("complexType");

            m_writer.endElement("element");

            if (!isExportedEventResult(event))
            {
               continue; // skip result types that are not exported e.g. for WSDL Basic
            }

            Argument result = event.getResult();
            Type type = (result == null) ? null : result.getType();
            boolean bTyped = type != null;

            // NOTE: MS.NET requires the result to be wrapped if the arguments are wrapped
            //       hence must place result inside a complexType
            // @see http://servicefactory.codeplex.com/Thread/View.aspx?ThreadId=21981
View Full Code Here

         op.setParent(m_parent);

         return op;
      }

      Type thenType = m_then.getType();
      Type elseType = m_else.getType();

      m_source = null;

      if (thenType == null)
      {
         m_type = elseType;
      }
      else if (elseType == null)
      {
         m_type = thenType;
      }
      else if (!thenType.isPrimitive() || !elseType.isPrimitive())
      {
         if (thenType.isPrimitive() == elseType.isPrimitive())
         {
            m_type = thenType;

            while (!m_type.isUpcast(elseType))
            {
View Full Code Here

      if ((nFlags & NORMALIZE_NORECUR) == 0)
      {
         m_operand = m_operand.normalize(nFlags);
      }

      Type type = m_operand.getType();

      if (type == null)
      {
         setConstantValue(null);
      }
      else if (type.isPrimitive())
      {
         setSource(m_operand.getSource(), nFlags);
         m_function = ((Primitive)m_type).getConverter((Primitive)type);

         if (m_operand.isConstant())
View Full Code Here

      assertEquals((event.getResult() == null) ? 1 : 2, response.getChildNodes().getLength());

      if (event.getResult() != null)
      {
         Node representation = XMLUtil.findChildElement(response, "representation");
         Type type = event.getResult().getType();

         assertNotNull(representation);
         assertEquals(2, representation.getAttributes().getLength());
         assertEquals("text/xml", XMLUtil.getStringAttr(representation, "mediaType"));
         assertEquals(0, representation.getChildNodes().getLength()); // test data lacks <doc/>
View Full Code Here

TOP

Related Classes of nexj.core.meta.Type

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.