Search in sources :

Example 21 with DatatypeFactory

use of javax.xml.datatype.DatatypeFactory in project cxf by apache.

the class XsDateTimeFormat method parseObject.

public Object parseObject(String pString, ParsePosition pParsePosition) {
    if (pString == null) {
        throw new NullPointerException("The String argument must not be null.");
    }
    if (pParsePosition == null) {
        throw new NullPointerException("The ParsePosition argument must not be null.");
    }
    int offset = pParsePosition.getIndex();
    int idxSpc = pString.indexOf(' ', offset);
    int idxCom = pString.indexOf(',', offset);
    if (idxCom != -1 && idxCom < idxSpc) {
        idxSpc = idxCom;
    }
    String newVal = null;
    if (idxSpc == -1) {
        newVal = pString.substring(offset);
    } else {
        newVal = pString.substring(offset, idxSpc);
    }
    DatatypeFactory factory;
    try {
        factory = DatatypeFactory.newInstance();
        XMLGregorianCalendar cal = factory.newXMLGregorianCalendar(newVal);
        pParsePosition.setIndex(idxSpc);
        return cal.toGregorianCalendar();
    } catch (DatatypeConfigurationException e) {
        pParsePosition.setErrorIndex(offset);
    }
    return null;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) DatatypeFactory(javax.xml.datatype.DatatypeFactory)

Example 22 with DatatypeFactory

use of javax.xml.datatype.DatatypeFactory in project Payara by payara.

the class ScheduledTimerNode method writeDescriptor.

@Override
public Node writeDescriptor(Node parent, String nodeName, ScheduledTimerDescriptor desc) {
    Node timerNode = super.writeDescriptor(parent, nodeName, descriptor);
    Node scheduleNode = appendChild(timerNode, EjbTagNames.TIMER_SCHEDULE);
    appendTextChild(scheduleNode, EjbTagNames.TIMER_SECOND, desc.getSecond());
    appendTextChild(scheduleNode, EjbTagNames.TIMER_MINUTE, desc.getMinute());
    appendTextChild(scheduleNode, EjbTagNames.TIMER_HOUR, desc.getHour());
    appendTextChild(scheduleNode, EjbTagNames.TIMER_DAY_OF_MONTH, desc.getDayOfMonth());
    appendTextChild(scheduleNode, EjbTagNames.TIMER_MONTH, desc.getMonth());
    appendTextChild(scheduleNode, EjbTagNames.TIMER_DAY_OF_WEEK, desc.getDayOfWeek());
    appendTextChild(scheduleNode, EjbTagNames.TIMER_YEAR, desc.getYear());
    try {
        DatatypeFactory dFactory = DatatypeFactory.newInstance();
        GregorianCalendar cal = new GregorianCalendar();
        if (desc.getStart() != null) {
            cal.setTime(desc.getStart());
            XMLGregorianCalendar xmlGreg = dFactory.newXMLGregorianCalendar(cal);
            appendTextChild(timerNode, EjbTagNames.TIMER_START, xmlGreg.toXMLFormat());
        }
        if (desc.getEnd() != null) {
            cal.setTime(desc.getEnd());
            XMLGregorianCalendar xmlGreg = dFactory.newXMLGregorianCalendar(cal);
            appendTextChild(timerNode, EjbTagNames.TIMER_END, xmlGreg.toXMLFormat());
        }
    } catch (Exception e) {
        DOLUtils.getDefaultLogger().log(Level.WARNING, e.getMessage(), e);
    }
    MethodNode methodNode = new MethodNode();
    methodNode.writeJavaMethodDescriptor(timerNode, EjbTagNames.TIMEOUT_METHOD, desc.getTimeoutMethod());
    appendTextChild(timerNode, EjbTagNames.TIMER_PERSISTENT, Boolean.toString(desc.getPersistent()));
    String tz = desc.getTimezone();
    if (tz != null) {
        appendTextChild(timerNode, EjbTagNames.TIMER_TIMEZONE, tz);
    }
    String info = desc.getInfo();
    if (info != null) {
        appendTextChild(timerNode, EjbTagNames.TIMER_INFO, info);
    }
    return timerNode;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeFactory(javax.xml.datatype.DatatypeFactory) MethodNode(com.sun.enterprise.deployment.node.MethodNode) Node(org.w3c.dom.Node) MethodNode(com.sun.enterprise.deployment.node.MethodNode) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Aggregations

DatatypeFactory (javax.xml.datatype.DatatypeFactory)22 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)17 GregorianCalendar (java.util.GregorianCalendar)10 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)9 Date (java.util.Date)7 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)5 SubscriptionFilterVisitor (ddf.catalog.pubsub.internal.SubscriptionFilterVisitor)5 ContentTypePredicate (ddf.catalog.pubsub.predicate.ContentTypePredicate)5 GeospatialPredicate (ddf.catalog.pubsub.predicate.GeospatialPredicate)5 Predicate (ddf.catalog.pubsub.predicate.Predicate)5 HashMap (java.util.HashMap)5 FilterTransformer (org.geotools.filter.FilterTransformer)5 Test (org.junit.Test)5 Filter (org.opengis.filter.Filter)5 Event (org.osgi.service.event.Event)5 ArrayList (java.util.ArrayList)3 FreeBusyResponseType (com.microsoft.schemas.exchange.services._2006.messages.FreeBusyResponseType)1 GetUserAvailabilityRequestType (com.microsoft.schemas.exchange.services._2006.messages.GetUserAvailabilityRequestType)1 GetUserAvailabilityResponseType (com.microsoft.schemas.exchange.services._2006.messages.GetUserAvailabilityResponseType)1 ArrayOfMailboxData (com.microsoft.schemas.exchange.services._2006.types.ArrayOfMailboxData)1