PolicyModelUnmarshaller.java revision 524:dcaa586ab756
1/*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.xml.internal.ws.policy.sourcemodel;
27
28import com.sun.xml.internal.ws.policy.PolicyException;
29
30/**
31 * Abstract class defines interface for policy model unmarshaller implementations that are specific to underlying
32 * persistence layer.
33 *
34 * Code that depends on JAX-WS should use com.sun.xml.internal.ws.api.policy.ModelUnmarshaller
35 * instead of this class.
36 *
37 * @author Marek Potociar
38 * @author Fabian Ritzmann
39 */
40public abstract class PolicyModelUnmarshaller {
41    private static final PolicyModelUnmarshaller xmlUnmarshaller = new XmlPolicyModelUnmarshaller();
42
43    /**
44     * Default constructor to ensure we have a common model unmarshaller base, but only our API classes implemented in this
45     * package will be able to extend this abstract class. This is to restrict attempts of extending the class from
46     * a client code.
47     */
48    PolicyModelUnmarshaller() {
49        // nothing to intitialize
50    }
51
52    /**
53     * Unmarshalls single policy source model from provided storage reference. Method expects that the storage
54     * cursor to be alread placed on the start of a policy expression. Inner comments and whitespaces are skipped
55     * in processing. Any other cursor position results in a PolicyException being thrown.
56     *
57     * @param storage reference to underlying storage that should be used for model unmarshalling
58     * @return unmarshalled policy source model. If no policies are found, returns {@code null}.
59     * @throws PolicyException in case of the unmarshalling problems
60     */
61    public abstract PolicySourceModel unmarshalModel(Object storage) throws PolicyException;
62
63    /**
64     * Factory method that returns policy model unmarshaller able to unmarshal
65     * policy expressions from XML source.
66     *
67     * Code that depends on JAX-WS should use com.sun.xml.internal.ws.api.policy.ModelUnmarshaller.getUnmarshaller()
68     * instead of this method.
69     *
70     * @return policy model unmarshaller able to unmarshal policy expressions from XML source.
71     */
72    public static PolicyModelUnmarshaller getXmlUnmarshaller() {
73        return xmlUnmarshaller;
74    }
75}
76