source: FCSSimpleClient/trunk/src/main/java/eu/clarin/sru/client/fcs/Resource.java @ 7274

Last change on this file since 7274 was 7274, checked in by Oliver Schonefeld, 2 years ago
  • update copyright
File size: 5.3 KB
Line 
1/**
2 * This software is copyright (c) 2012-2022 by
3 *  - Leibniz-Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
4 * This is free software. You can redistribute it
5 * and/or modify it under the terms described in
6 * the GNU General Public License v3 of which you
7 * should have received a copy. Otherwise you can download
8 * it from
9 *
10 *   http://www.gnu.org/licenses/gpl-3.0.txt
11 *
12 * @copyright Leibniz-Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
13 *
14 * @license http://www.gnu.org/licenses/gpl-3.0.txt
15 *  GNU General Public License v3
16 */
17package eu.clarin.sru.client.fcs;
18
19import java.util.Collections;
20import java.util.List;
21
22/**
23 * A CLARIN-FCS resource
24 */
25public class Resource {
26    /**
27     * A CLARIN-FCS resource fragment
28     */
29    public final static class ResourceFragment {
30        private final String pid;
31        private final String ref;
32        private final List<DataView> dataviews;
33
34
35        ResourceFragment(String pid, String ref, List<DataView> dataviews) {
36            this.pid = ((pid != null) && !pid.isEmpty()) ? pid : null;
37            this.ref = ((ref != null) && !ref.isEmpty()) ? ref : null;
38            if ((dataviews != null) && !dataviews.isEmpty()) {
39                this.dataviews = Collections.unmodifiableList(dataviews);
40            } else {
41                this.dataviews = null;
42            }
43        }
44
45
46        /**
47         * Get the persistent identifier for this resource fragment.
48         *
49         * @return a persistent identifier or <code>null</code> of this resource
50         *         fragment has none
51         */
52        public String getPid() {
53            return pid;
54        }
55
56
57        /**
58         * Get the reference URI for this resource fragment.
59         *
60         * @return a reference URI or <code>null</code> of this resource
61         *         fragment has none
62         */
63        public String getRef() {
64            return ref;
65        }
66
67
68        /**
69         * Convenience method to check if this resource fragment has any
70         * data views.
71         *
72         * @return <code>true</code> if this resource fragment has data views,
73         *         <code>false</code> otherwise
74         */
75        public boolean hasDataViews() {
76            return (dataviews != null);
77        }
78
79
80        /**
81         * Get the list of data view objects for this this resource fragment.
82         *
83         * @return a list of {@link DataView} objects or <code>null</code>,
84         *         or <code>null</code> if this resource fragment has
85         *         none
86         */
87        public List<DataView> getDataViews() {
88            return dataviews;
89        }
90    } // inner class ResourceFragment
91    private final String pid;
92    private final String ref;
93    private final List<DataView> dataviews;
94    private final List<ResourceFragment> resourceFragments;
95
96
97    Resource(String pid, String ref, List<DataView> dataviews,
98            List<ResourceFragment> resourceFragments) {
99        this.pid = ((pid != null) && !pid.isEmpty()) ? pid : null;
100        this.ref = ((ref != null) && !ref.isEmpty()) ? ref : null;
101        if ((dataviews != null) && !dataviews.isEmpty()) {
102            this.dataviews = Collections.unmodifiableList(dataviews);
103        } else {
104            this.dataviews = null;
105        }
106        if ((resourceFragments != null) && !resourceFragments.isEmpty()) {
107            this.resourceFragments =
108                    Collections.unmodifiableList(resourceFragments);
109        } else {
110            this.resourceFragments = null;
111        }
112    }
113
114
115    /**
116     * Get the persistent identifier for this resource.
117     *
118     * @return a persistent identifier or <code>null</code> of this resource has
119     *         none
120     */
121    public String getPid() {
122        return pid;
123    }
124
125
126    /**
127     * Get the reference URI for this resource.
128     *
129     * @return a reference URI or <code>null</code> of this resource has
130     *         none
131     */
132    public String getRef() {
133        return ref;
134    }
135
136
137    /**
138     * Convenience method to check if this resource has any dataviews.
139     *
140     * @return <code>true</code> if this resource has dataviews,
141     *         <code>false</code> otherwise
142     */
143    public boolean hasDataViews() {
144        return (dataviews != null);
145    }
146
147
148    /**
149     * Get the list of dataview objects for this this resource.
150     *
151     * @return a list of {@link DataView} objects or <code>null</code>, or
152     *         <code>null</code> if this resource has none
153     */
154    public List<DataView> getDataViews() {
155        return dataviews;
156    }
157
158
159    /**
160     * Convenience method to check if this resource has any resource fragments.
161     *
162     * @return <code>true</code> if this resource has resource fragments,
163     *         <code>false</code> otherwise
164     */
165    public boolean hasResourceFragments() {
166        return (resourceFragments != null);
167    }
168
169
170    /**
171     * Get the list of resource fragment objects for this this resource.
172     *
173     * @return a list of {@link ResourceFragment} objects or <code>null</code>,
174     *         or <code>null</code> if this resource has none
175     */
176    public List<ResourceFragment> getResourceFragments() {
177        return resourceFragments;
178    }
179
180} // class Resource
Note: See TracBrowser for help on using the repository browser.