Examples of Convertor


Examples of org.apache.cocoon.woody.datatype.convertor.Convertor

            Element updateWrapElement =
                DomHelper.getChildElement(bindingElm, BindingManager.NAMESPACE, "on-update");
            JXPathBindingBase[] updateBindings = assistant.makeChildBindings(updateWrapElement);

            Convertor convertor = null;
            Locale convertorLocale = Locale.US;
            Element convertorEl = DomHelper.getChildElement(bindingElm, Constants.WD_NS, "convertor");
            if (convertorEl != null) {
                String datatype = DomHelper.getAttribute(convertorEl, "datatype");
                String localeStr = convertorEl.getAttribute("datatype");
View Full Code Here

Examples of org.apache.cocoon.woody.datatype.convertor.Convertor

        return selectionList;
    }
  
    private  SelectionList buildStaticList(Element selectionListElement, Datatype datatype) throws Exception {
        StaticSelectionList selectionList = new StaticSelectionList(datatype);
        Convertor convertor = null;
        Convertor.FormatCache formatCache = new DefaultFormatCache();

        NodeList children = selectionListElement.getChildNodes();
        for (int i = 0; children.item(i) != null; i++) {
            Node node = children.item(i);
            if (convertor == null && node instanceof Element && Constants.WD_NS.equals(node.getNamespaceURI()) && "convertor".equals(node.getLocalName())) {
                Element convertorConfigElement = (Element)node;
                try {
                    convertor = datatype.getBuilder().buildConvertor(convertorConfigElement);
                } catch (Exception e) {
                    throw new SAXException("Error building convertor from convertor configuration embedded in selection list XML.", e);
                }
            } else if (node instanceof Element && Constants.WD_NS.equals(node.getNamespaceURI()) && "item".equals(node.getLocalName())) {
                if (convertor == null) {
                    convertor = datatype.getConvertor();
                }
                Element element = (Element)node;
                String stringValue = element.getAttribute("value");
                Object value = convertor.convertFromString(stringValue, Locale.US, formatCache);
                if (value == null)
                    throw new Exception("Could not convert the value \"" + stringValue + "\" to the type " + datatype.getDescriptiveName() + ", defined at " + DomHelper.getLocation(element));

                Object label = null;
                Element labelEl = DomHelper.getChildElement(element, Constants.WD_NS, "label");
View Full Code Here

Examples of org.apache.cocoon.woody.datatype.convertor.Convertor

*/
public class SelectionListBuilder {

    public static SelectionList build(Element selectionListElement, Datatype datatype) throws Exception {
        StaticSelectionList selectionList = new StaticSelectionList(datatype);
        Convertor convertor = null;
        Convertor.FormatCache formatCache = new DefaultFormatCache();

        NodeList children = selectionListElement.getChildNodes();
        for (int i = 0; children.item(i) != null; i++) {
            Node node = children.item(i);
            if (convertor == null && node instanceof Element && Constants.WD_NS.equals(node.getNamespaceURI()) && "convertor".equals(node.getLocalName())) {
                Element convertorConfigElement = (Element)node;
                try {
                    convertor = datatype.getBuilder().buildConvertor(convertorConfigElement);
                } catch (Exception e) {
                    throw new SAXException("Error building convertor from convertor configuration embedded in selection list XML.", e);
                }
            } else if (node instanceof Element && Constants.WD_NS.equals(node.getNamespaceURI()) && "item".equals(node.getLocalName())) {
                if (convertor == null) {
                    convertor = datatype.getConvertor();
                }
                Element element = (Element)node;
                String stringValue = element.getAttribute("value");
                Object value = convertor.convertFromString(stringValue, Locale.US, formatCache);
                if (value == null)
                    throw new Exception("Could not convert the value \"" + stringValue + "\" to the type " + datatype.getDescriptiveName() + ", defined at " + DomHelper.getLocation(element));

                Object label = null;
                Element labelEl = DomHelper.getChildElement(element, Constants.WD_NS, "label");
View Full Code Here

Examples of org.apache.cocoon.woody.datatype.convertor.Convertor

            Element updateWrapElement =
                DomHelper.getChildElement(bindingElm, BindingManager.NAMESPACE, "on-update");
            JXPathBindingBase[] updateBindings = assistant.makeChildBindings(updateWrapElement);

            Convertor convertor = null;
            Locale convertorLocale = Locale.US;
            Element convertorEl = DomHelper.getChildElement(bindingElm, Constants.WD_NS, "convertor");
            if (convertorEl != null) {
                String datatype = DomHelper.getAttribute(convertorEl, "datatype");
                String localeStr = convertorEl.getAttribute("datatype");
View Full Code Here

Examples of org.apache.cocoon.woody.datatype.convertor.Convertor

        }
    }

    public void buildConvertor(Element datatypeEl, AbstractDatatype datatype) throws Exception {
        Element convertorEl = DomHelper.getChildElement(datatypeEl, Constants.WD_NS, "convertor", false);
        Convertor convertor = buildConvertor(convertorEl);
        datatype.setConvertor(convertor);
    }
View Full Code Here

Examples of org.eclipse.jetty.util.ajax.JSON.Convertor

    _presence = (PresenceEventPackage) getServletContext().getAttribute(PresenceEventPackage.class.getName());
    _locationService = (LocationService) getServletContext().getAttribute(LocationService.class.getName());
    _xcapPolicyManager = (XcapPolicyManager) getServletContext().getAttribute(PolicyManager.class.getName());
    _watcherInfo = (WatcherInfoEventPackage) getServletContext().getAttribute(WatcherInfoEventPackage.class.getName());
   
    JSON.getDefault().addConvertor(Resource.class, new Convertor()
    {
      public void toJSON(Object obj, Output out)
      {
        Resource resource = (Resource) obj;
        out.add("uri", resource.getUri());
      }
      public Object fromJSON(Map object)  { return null; }
    });
    JSON.getDefault().addConvertor(EventResource.class, new Convertor()
    {
      public void toJSON(Object obj, Output out)
      {
        EventResource resource = (EventResource) obj;
        out.add("uri", resource.getUri());
        out.add("subscriptions", resource.getSubscriptions());
      }
      public Object fromJSON(Map object)  { return null; }
    });
    JSON.getDefault().addConvertor(Subscription.class, new Convertor()
    {
      public void toJSON(Object obj, Output out)
      {
        Subscription subscription = (Subscription) obj;
        out.add("uri", subscription.getUri());
        out.add("state", subscription.getState().toString());
        out.add("authorized", subscription.isAuthorized());
      }
      public Object fromJSON(Map object)  { return null; }
    });
   
    JSON.getDefault().addConvertor(Registration.class, new Convertor()
    {
      public void toJSON(Object obj, Output out)
      {
        Registration record = (Registration) obj;
        out.add("aor", record.getUri());
        out.add("bindings", record.getBindings());
      }
      public Object fromJSON(Map object)  { return null; }
    });
    JSON.getDefault().addConvertor(Binding.class, new Convertor()
    {
      public void toJSON(Object obj, Output out)
      {
        Binding binding = (Binding) obj;
        out.add("contact", binding.getContact());
        out.add("expiration", new Date(binding.getExpirationTime()));
      }
      public Object fromJSON(Map object)  { return null; }
    });
   
    JSON.getDefault().addConvertor(XcapPolicy.class, new Convertor()
    {
      public void toJSON(Object obj, Output out)
      {
        XcapPolicy policy = (XcapPolicy) obj;
        out.add("Resource", policy.getResourceUri());
        out.add("XcapResources", policy.getXcapResources());
      }
      public Object fromJSON(Map object)  { return null; }
    });
   
    JSON.getDefault().addConvertor(ResourceHolder.class, new Convertor()
    {
      public void toJSON(Object obj, Output out)
      {
        ResourceHolder holder = (ResourceHolder) obj;
        out.add("lock", holder.getHoldCount());
View Full Code Here

Examples of org.eclipse.jetty.util.ajax.JSON.Convertor

   
    /* ------------------------------------------------------------ */
    public void toJSON(Object obj, Output out)
    {
        String clsName=obj.getClass().getName();
        Convertor convertor=_json.getConvertorFor(clsName);
        if (convertor==null)
        {
            try
            {
                Class cls=Loader.loadClass(JSON.class,clsName);
                convertor=new JSONPojoConvertor(cls,_fromJson);
                _json.addConvertorFor(clsName, convertor);
             }
            catch (ClassNotFoundException e)
            {
                JSON.LOG.warn(e);
            }
        }
        if (convertor!=null)
        {
            convertor.toJSON(obj, out);
        }
    }
View Full Code Here

Examples of org.eclipse.jetty.util.ajax.JSON.Convertor

    {
        Map map=object;
        String clsName=(String)map.get("class");
        if (clsName!=null)
        {
            Convertor convertor=_json.getConvertorFor(clsName);
            if (convertor==null)
            {
                try
                {
                    Class cls=Loader.loadClass(JSON.class,clsName);
                    convertor=new JSONPojoConvertor(cls,_fromJson);
                    _json.addConvertorFor(clsName, convertor);
                }
                catch (ClassNotFoundException e)
                {
                    JSON.LOG.warn(e);
                }
            }
            if (convertor!=null)
            {
                return convertor.fromJSON(object);
            }
        }
        return map;
    }
View Full Code Here

Examples of org.eclipse.jetty.util.ajax.JSON.Convertor

   
    /* ------------------------------------------------------------ */
    public void toJSON(Object obj, Output out)
    {
        String clsName=obj.getClass().getName();
        Convertor convertor=_json.getConvertorFor(clsName);
        if (convertor==null)
        {
            try
            {
                Class cls=Loader.loadClass(JSON.class,clsName);
                convertor=new JSONPojoConvertor(cls,_fromJson);
                _json.addConvertorFor(clsName, convertor);
             }
            catch (ClassNotFoundException e)
            {
                JSON.LOG.warn(e);
            }
        }
        if (convertor!=null)
        {
            convertor.toJSON(obj, out);
        }
    }
View Full Code Here

Examples of org.eclipse.jetty.util.ajax.JSON.Convertor

    {
        Map map=object;
        String clsName=(String)map.get("class");
        if (clsName!=null)
        {
            Convertor convertor=_json.getConvertorFor(clsName);
            if (convertor==null)
            {
                try
                {
                    Class cls=Loader.loadClass(JSON.class,clsName);
                    convertor=new JSONPojoConvertor(cls,_fromJson);
                    _json.addConvertorFor(clsName, convertor);
                }
                catch (ClassNotFoundException e)
                {
                    JSON.LOG.warn(e);
                }
            }
            if (convertor!=null)
            {
                return convertor.fromJSON(object);
            }
        }
        return map;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.