|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
BinaryResourceImpl.java | - | 80% | 75% | 77.8% |
|
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 | * contributor license agreements. See the NOTICE file distributed with | |
4 | * this work for additional information regarding copyright ownership. | |
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 | * (the "License"); you may not use this file except in compliance with | |
7 | * the License. You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | * | |
17 | * $Id: BinaryResourceImpl.java 541508 2007-05-25 01:54:12Z vgritsenko $ | |
18 | */ | |
19 | ||
20 | package org.apache.xindice.client.xmldb.resources; | |
21 | ||
22 | import org.xmldb.api.base.Collection; | |
23 | import org.xmldb.api.base.XMLDBException; | |
24 | import org.xmldb.api.modules.BinaryResource; | |
25 | ||
26 | /** | |
27 | * BinaryResourceImpl provides an implementation to handle XML:DB binary | |
28 | * resource. | |
29 | * | |
30 | * As per XML:DB spec, binary resource supports only byte[] data. | |
31 | * | |
32 | * @version $Revision: 541508 $, $Date: 2007-05-24 18:54:12 -0700 (Thu, 24 May 2007) $ | |
33 | */ | |
34 | public class BinaryResourceImpl implements BinaryResource { | |
35 | ||
36 | private String id; | |
37 | private byte[] content; | |
38 | private Collection collection; | |
39 | ||
40 | ||
41 | 0 | public BinaryResourceImpl(String id, byte[] content) { |
42 | 0 | this(id, null, content); |
43 | } | |
44 | ||
45 | 18 | public BinaryResourceImpl(String id, Collection collection, byte[] content) { |
46 | 18 | this.id = id; |
47 | 18 | this.content = content; |
48 | 18 | this.collection = collection; |
49 | } | |
50 | ||
51 | /** | |
52 | * @see org.xmldb.api.base.Resource#getContent() | |
53 | */ | |
54 | 30 | public Object getContent() throws XMLDBException { |
55 | 30 | return this.content; |
56 | } | |
57 | ||
58 | /** | |
59 | * @see org.xmldb.api.base.Resource#getId() | |
60 | */ | |
61 | 50 | public String getId() throws XMLDBException { |
62 | 50 | return this.id; |
63 | } | |
64 | ||
65 | /** | |
66 | * @see org.xmldb.api.base.Resource#getParentCollection() | |
67 | */ | |
68 | 0 | public Collection getParentCollection() throws XMLDBException { |
69 | 0 | return this.collection; |
70 | } | |
71 | ||
72 | /** | |
73 | * @see org.xmldb.api.base.Resource#getResourceType() | |
74 | */ | |
75 | 3 | public String getResourceType() throws XMLDBException { |
76 | 3 | return "BinaryResource"; |
77 | } | |
78 | ||
79 | /** | |
80 | * @see org.xmldb.api.base.Resource#setContent(Object) | |
81 | */ | |
82 | 12 | public void setContent(Object content) throws XMLDBException { |
83 | 12 | this.content = (byte[])content; |
84 | } | |
85 | ||
86 | 4 | public void setId(String id) { |
87 | 4 | this.id = id; |
88 | } | |
89 | } |
|