1 /* ***************************************************************************
2 * Copyright (c) 2008 Brabenetz Harald, Austria.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 *****************************************************************************/
17 package org.settings4j.connector;
18
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.List;
22
23 import org.settings4j.Connector;
24 import org.settings4j.ContentResolver;
25 import org.settings4j.ObjectResolver;
26
27 /**
28 * Basic Connector implementations like getter and Setter of contentResolver, objectResolver.
29 *
30 * @author Harald.Brabenetz
31 *
32 */
33 public abstract class AbstractConnector implements Connector {
34
35 private String name;
36 private ContentResolver contentResolver;
37 private ObjectResolver objectResolver;
38 private final List<Connector> connectors = Collections.synchronizedList(new ArrayList<Connector>());
39
40 public List<Connector> getConnectors() {
41 return Collections.unmodifiableList(this.connectors);
42 }
43
44 /** {@inheritDoc} */
45 public void addConnector(final Connector connector) {
46 this.connectors.add(connector);
47 }
48
49 protected ContentResolver getContentResolver() {
50 return this.contentResolver;
51 }
52
53 public void setContentResolver(final ContentResolver contentResolver) {
54 this.contentResolver = contentResolver;
55 }
56
57 protected ObjectResolver getObjectResolver() {
58 return this.objectResolver;
59 }
60
61 public void setObjectResolver(final ObjectResolver objectResolver) {
62 this.objectResolver = objectResolver;
63 }
64
65 public String getName() {
66 return this.name;
67 }
68
69 public void setName(final String name) {
70 this.name = name;
71 }
72
73 /** {@inheritDoc} */
74 public void init() {
75 // Overwrite this methode if you want do something after all properties are set.
76 // by default there is nothing to do
77 }
78
79 }