summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/testing/itest/databindings/jaxb-top-down/src/main/java/org/apache/tuscany/sca/itest/databindings/jaxb/impl/StandardTypesServiceImpl.java
blob: 1fa525a0eeaa39a0f53d3594ebb455db9dd9da80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.    
 */

package org.apache.tuscany.sca.itest.databindings.jaxb.impl;

import java.awt.Image;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
import java.util.Calendar;
import java.util.Date;
import java.util.UUID;

import javax.activation.DataHandler;
import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;

import org.apache.tuscany.sca.itest.databindings.jaxb.StandardTypesService;
import org.oasisopen.sca.annotation.Service;

/**
 * An implementation of StandardTypesService.
 * 
 * @version $Rev$ $Date$
 */
@Service(StandardTypesService.class)
public class StandardTypesServiceImpl implements StandardTypesService {
    public BigInteger getNewBigInteger(BigInteger bi) {
        return bi.negate();
    }

    public BigInteger[] getNewBigIntegerArray(BigInteger[] bia) {
        BigInteger[] resp = new BigInteger[bia.length];
        for(int i = 0; i < bia.length; ++i) {
            resp[i] = bia[i].negate();
        }
        return resp;
    }

    public BigDecimal getNewBigDecimal(BigDecimal bd) {
        return bd.negate();
    }

    public BigDecimal[] getNewBigDecimalArray(BigDecimal[] bda) {
        BigDecimal[] resp = new BigDecimal[bda.length];
        for(int i = 0; i < bda.length; ++i) {
            resp[i] = bda[i].negate();
        }
        return resp;
    }

    public Calendar getNewCalendar(Calendar c) {
        Calendar resp = (Calendar)c.clone();
        resp.add(Calendar.DAY_OF_MONTH, 5);
        return resp;
    }

    public Calendar[] getNewCalendarArray(Calendar[] ca) {
        Calendar[] resp = new Calendar[ca.length];
        for(int i = 0; i < ca.length; ++i) {
            resp[i] = getNewCalendar(ca[i]);
        }
        return resp;
    }

    public Date getNewDate(Date d) {
        return new Date(d.getTime() + 5*24*60*60*1000);
    }

    public Date[] getNewDateArray(Date[] da) {
        Date[] resp = new Date[da.length];
        for(int i = 0; i < da.length; ++i) {
            resp[i] = getNewDate(da[i]);
        }
        return resp;
    }

    public QName getNewQName(QName qname) {
        return new QName(qname.getNamespaceURI()+"q", qname.getLocalPart()+"q", qname.getPrefix()+"q");
        
    }

    public QName[] getNewQNameArray(QName[] qnames) {
        QName[] resp = new QName[qnames.length];
        for(int i = 0; i < qnames.length; ++i) {
            resp[i] = getNewQName(qnames[i]);
        }
        return resp;
    }

    public URI getNewURI(URI uri) {
        return uri.resolve("uri");
    }

    public URI[] getNewURIArray(URI[] uris) {
        URI[] resp = new URI[uris.length];
        for(int i = 0; i < uris.length; ++i) {
            resp[i] = getNewURI(uris[i]);
        }
        return resp;
    }

    public XMLGregorianCalendar getNewXMLGregorianCalendar(XMLGregorianCalendar xgcal) {
        xgcal = (XMLGregorianCalendar)xgcal.clone();
        xgcal.setDay(xgcal.getDay()+5);
        return xgcal;
    }

    public XMLGregorianCalendar[] getNewXMLGregorianCalendarArray(XMLGregorianCalendar[] xgcals) {
        XMLGregorianCalendar[] resp = new XMLGregorianCalendar[xgcals.length];
        for(int i = 0; i < xgcals.length; ++i) {
            resp[i] = getNewXMLGregorianCalendar(xgcals[i]);
        }
        return resp;
    }

    public Duration getNewDuration(Duration d) {
        return d.negate();
    }

    public Duration[] getNewDurationArray(Duration[] da) {
        Duration[] resp = new Duration[da.length];
        for(int i = 0; i < da.length; ++i) {
            resp[i] = da[i].negate();
        }
        return resp;
    }

    public Object getNewObject(Object obj) {
        return StandardTypesTransformer.getNewObject(obj);
    }

    public Object[] getNewObjectArray(Object[] objs) {
        Object[] resp = new Object[objs.length];
        for(int i = 0; i < objs.length; ++i) {
            resp[i] = getNewObject(objs[i]);
        }
        return resp;
    }

    public Image getNewImage(Image img) {
        return StandardTypesTransformer.getNewImage(img);
    }

    public Image[] getNewImageArray(Image[] imgs) {
        Image[] resp = new Image[imgs.length];
        for(int i = 0; i < imgs.length; ++i) {
            resp[i] = getNewImage(imgs[i]);
        }
        return resp;
    }

    public DataHandler getNewDataHandler(DataHandler dh) {
        // FIXME: transform the input
        return dh;
    }

    public DataHandler[] getNewDataHandlerArray(DataHandler[] dha) {
        DataHandler[] resp = new DataHandler[dha.length];
        for(int i = 0; i < dha.length; ++i) {
            resp[i] = dha[i];
        }
        return resp;
    }
    
    public Source getNewSource(Source src) {
        return StandardTypesTransformer.getNewSource(src);
    }

    public Source[] getNewSourceArray(Source[] srcs) {
        Source[] resp = new Source[srcs.length];
        for(int i = 0; i < srcs.length; ++i) {
            resp[i] = getNewSource(srcs[i]);
        }
        return resp;
    }

    public UUID getNewUUID(UUID uuid) {
        return UUID.fromString(uuid.toString()+"AAA");
    }

    public UUID[] getNewUUIDArray(UUID[] uuids) {
        UUID[] resp = new UUID[uuids.length];
        for(int i = 0; i < uuids.length; ++i) {
            resp[i] = getNewUUID(uuids[i]);
        }
        return resp;
    }
}