KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > common > beans > ProbeFactory


1 /*
2  * Copyright 2004 Clinton Begin
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 package com.ibatis.common.beans;
17
18 /**
19  * An abstract factory for getting Probe implementations.
20  */

21 public class ProbeFactory {
22
23   private static final Probe DOM = new DomProbe();
24   private static final Probe BEAN = new ComplexBeanProbe();
25   private static final Probe GENERIC = new GenericProbe();
26
27   /**
28    * Factory method for getting a Probe object
29    *
30    * @return An implementation of the Probe interface
31    */

32   public static Probe getProbe() {
33     return GENERIC;
34   }
35
36   /**
37    * Factory method for getting a Probe object that is
38    * the best choice for the type of object supplied
39    * by the object parameter.
40    *
41    * @param object The object to get a Probe for
42    * @return An implementation of the Probe interface
43    */

44   public static Probe getProbe(Object JavaDoc object) {
45     if (object instanceof org.w3c.dom.Document JavaDoc) {
46       return DOM;
47     } else {
48       return BEAN;
49     }
50   }
51
52 }
53
Popular Tags