Package nexj.core.util

Examples of nexj.core.util.IdentityHashTab


      attribute.setCompatible(XMLUtil.getBooleanAttr(attributeElement, "compatible", false));
      attribute.setStatic(XMLUtil.getBooleanAttr(attributeElement, "static", false));
      attribute.setReadOnly(XMLUtil.getBooleanAttr(attributeElement, "readOnly", false));
      attribute.setCached(XMLUtil.getBooleanObjAttr(attributeElement, "cached"));

      Lookup posMap = new IdentityHashTab();

      attribute.setValue(m_helper.parse(XMLUtil.getStringAttr(attributeElement, "value"),
         false, sURLPrefix + "$value", posMap, Undefined.VALUE, m_metadata.getGlobalEnvironment()));
      attribute.setInitializer(m_helper.parse(XMLUtil.getStringAttr(attributeElement, "initializer"),
         false, sURLPrefix + "$initializer", posMap, Undefined.VALUE, m_metadata.getGlobalEnvironment()));
View Full Code Here


               action.setNextAction(sRelativeName);
            }
         });
      }

      Lookup posMap = new IdentityHashTab();

      action.setCondition(m_helper.parse(XMLUtil.getStringAttr(actionElement, "condition"),
         false, posMap, Boolean.TRUE, m_metadata.getGlobalEnvironment()));

      String sMethodName = XMLUtil.getStringAttr(actionElement, "method");
View Full Code Here

   public void serialize(Object obj, Writer writer) throws IOException
   {
      // Initialize
      m_nFixupCount = 0;
      m_fixupArray = new Object[48];
      m_idMap = new IdentityHashTab();
      m_writer = (writer instanceof XMLWriter) ? (XMLWriter)writer : new XMLWriter(writer);

      // Write out the header
      m_writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
      m_writer.setNamespace(SOAP.ENV_NS);
View Full Code Here

    * @see nexj.core.rpc.CharacterStreamMarshaller#serialize(java.lang.Object, java.io.Writer)
    */
   public void serialize(Object obj, Writer writer) throws IOException, MarshallerException
   {
      m_writer = (writer instanceof XMLWriter) ? (XMLWriter)writer : new XMLWriter(writer);
      m_idMap = new IdentityHashTab();
      m_nNextMarshalledObjectId = 0;
      m_bDynamicTypeEnabled = true;
      m_sDefaultNS = XML.NS_URI_TNS;

      // load all header attributes for first element
View Full Code Here

    */
   public List exportData(Set dataSourceSet, Lookup whereMap, boolean bExclusive)
   {
      Metadata metadata = m_context.getMetadata();
      List resultList = new ArrayList();
      Lookup identityMap = new IdentityHashTab();
      Lookup classMap = new HashTab();

      for (Iterator itr = metadata.getMetaclassIterator(); itr.hasNext();)
      {
         Metaclass metaclass = (Metaclass)itr.next();
View Full Code Here

    * @param specItr Read specification iterator: (class attributes where)
    * @return List of transfer object.
    */
   public List exportData(Iterator specItr)
   {
      Lookup identityMap = new IdentityHashTab(128);

      while (specItr.hasNext())
      {
         Object spec = specItr.next();
         Metaclass metaclass;
         Pair attributes = null;
         Object where = null;
         Object obj;
         Pair pair;

         if (spec instanceof Pair)
         {
            pair = (Pair)spec;
            obj = pair.getHead();
            pair = pair.getNext();
         }
         else
         {
            obj = spec;
            pair = null;
         }

         if (obj instanceof Metaclass)
         {
            metaclass = (Metaclass)obj;
         }
         else if (obj instanceof Symbol || obj instanceof String)
         {
            metaclass = m_context.getMetadata().getMetaclass(obj.toString());
         }
         else
         {
            throw new IllegalArgumentException("Invalid class specification");
         }

         if (pair != null)
         {
            attributes = (Pair)pair.getHead();
            pair = pair.getNext();
         }

         if (pair != null)
         {
            where = pair.getHead();

            if (pair.getTail() != null)
            {
               throw new IllegalArgumentException("Invalid query specification");
            }
         }

         RPCUtil.transfer(read(metaclass, attributes, where), attributes,
            identityMap, RPCUtil.TF_ALL | RPCUtil.TF_LAZY);
      }

      Lookup whereMap = new HashTab();

      for (Iterator itr = identityMap.iterator(); itr.hasNext();)
      {
         Object obj = itr.next();

         if (obj instanceof Instance)
         {
View Full Code Here

    */
   private final ExceptionHolder compile(Machine machine, ExceptionHolder eh)
   {
      verifyNotReadOnly();

      Lookup urlMap = (m_textPosMap == null) ? null : new IdentityHashTab(m_textPosMap.size() * 2);

      eh = resolveInheritance2(urlMap, eh);
      m_logger = Logger.getLogger(LOG_CATEGORY_PREFIX + getName());
      setCurrent();

View Full Code Here

      else
      {
         int nActionCount = getActionCount();
         final int nArgOffset = 7; // number of non-vararg arguments
         Object[] args = new Object[Math.max(nActionCount, 1) + nArgOffset];
         Lookup posMap = new IdentityHashTab(64);
         Lookup urlMap = new IdentityHashTab(64);
         String sEventURL = getURL(m_metaclass);
         String sURLPrefix = sEventURL + "$";

         // When updating the event generator invocation code,
         // also update the plugin action compilation validation
         args[0] = this;
         args[1] = getArguments(true);
         args[2] = getVariables();
         args[3] = getPrivilege();

         if (m_accessAttribute == null)
         {
            args[4] = null;
         }
         else if (m_bStatic)
         {
            if (m_accessAttribute.isStatic())
            {
               args[4] = Primitive.createInteger(m_accessAttribute.getOrdinal());
            }
            else
            {
               args[4] = null;
            }
         }
         else
         {
            args[4] = Primitive.createInteger(
               (m_accessAttribute.isStatic()) ?
                  -1 -m_accessAttribute.getOrdinal() :
                  m_accessAttribute.getOrdinal());
         }

         args[5] = Boolean.valueOf(getArgumentCount() == 0 && "delete".equals(m_sName));

         byte nTransactionMode = ((getSymbol() == Symbol.CREATE || getSymbol() == Symbol.UPDATE) &&
            getArgumentCount() == 0) ? TX_SUPPORTED : getTransactionMode();

         args[6] = Primitive.createInteger(nTransactionMode);
         m_bTransient = (nTransactionMode != TX_SUPPORTED);

         for (int i = 0; i < nActionCount; ++i)
         {
            Action action = getAction(i);
            Object condition = action.getCondition();
            String sURL;
            Object body;

            if (action.getDeclarator() != null)
            {
               sURL = getURL(action.getDeclarator()) + "$" + action.getFullName();
            }
            else
            {
               sURL = sURLPrefix + action.getFullName();
            }

            if (action.getMethod() == null)
            {
               body = action.getBody();

               if (body == null)
               {
                  body = EMPTY_BODY;
               }
            }
            else
            {
               body = Pair.list(Pair.list(Pair.quote(new JavaAction(action)),
                  (action.getType() == Action.AROUND) ? Symbol.CALL_NEXT : EMPTY_CLOSURE));
            }

            Lookup map = action.getTextPositionMap();

            if (map != null)
            {
               for (Lookup.Iterator itr = map.iterator(); itr.hasNext();)
               {
                  itr.next();
                  posMap.put(itr.getKey(), itr.getValue());
                  urlMap.put(itr.getValue(), sURL);
               }
            }

            if (condition != null)
            {
               Compiler.setPosURLs(condition, sURL + "$condition", posMap, urlMap);
            }

            Boolean grouped = Boolean.FALSE;

            // Set grouped for all but the first action in a group
            if (action.getGroupName() != null)
            {
               if (action.getType() == Action.BEFORE)
               {
                  for (int k = i - 1; k >= 0; --k)
                  {
                     if (action.getGroupName().equals(getAction(k).getGroupName()))
                     {
                        grouped = Boolean.TRUE;
                        break;
                     }
                  }
               }
               else
               {
                  for (int k = i + 1; k < nActionCount; ++k)
                  {
                     if (action.getGroupName().equals(getAction(k).getGroupName()))
                     {
                        grouped = Boolean.TRUE;
                        break;
                     }
                  }
               }
            }
           
            args[i + nArgOffset] = new Pair(action.getTypeSymbol(), new Pair(grouped, new Pair(condition, body)));

            action.setBody(null);
            action.setTextPositionMap(null);
         }

         // Ensure there is a main action
         if (nActionCount == 0 || ((Pair)args[args.length - 1]).getHead() != Symbol.MAIN)
         {
            if (nActionCount > 0)
            {
               Object[] argsSaved = args;

               args = new Object[args.length + 1];
               System.arraycopy(argsSaved, 0, args, 0, argsSaved.length);
            }

            args[args.length - 1] new Pair(Symbol.MAIN, new Pair(Boolean.FALSE, new Pair(Boolean.TRUE, EMPTY_BODY)));
         }

         try
         {
            // Invoke the sys:generate-event macro that generates the ECA code and compile the result
            Pair code = (Pair)machine.invoke((Function)machine.getGlobalEnvironment().getVariable(Symbol.SYS_GENERATE_EVENT), args);
            TextPosition pos = new TextPosition(0, 0);

            posMap.put(code, pos);
            urlMap.put(pos, sEventURL);

            for (Pair pair = code; pair != null; pair = pair.getNext())
            {
               if (pair.getHead() instanceof Pair && !posMap.contains(pair.getHead()))
               {
                  pos = new TextPosition(0, 0);
                  posMap.put(pair.getHead(), pos);
                  urlMap.put(pos, sEventURL);
               }
            }
           
            m_function = new Compiler().compile(code, posMap, urlMap, machine, false);
         }
View Full Code Here

TOP

Related Classes of nexj.core.util.IdentityHashTab

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.