jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dtd/models/CMNode.java
author joehw
Mon, 13 Oct 2014 14:09:03 -0700
changeset 27111 7a491d709b83
parent 25868 686eef1e7a79
permissions -rw-r--r--
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
27111
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
     2
 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
/*
27111
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
     5
 * Licensed to the Apache Software Foundation (ASF) under one or more
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
     6
 * contributor license agreements.  See the NOTICE file distributed with
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
     7
 * this work for additional information regarding copyright ownership.
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
     8
 * The ASF licenses this file to You under the Apache License, Version 2.0
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
     9
 * (the "License"); you may not use this file except in compliance with
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    10
 * the License.  You may obtain a copy of the License at
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 *
27111
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    12
 *      http://www.apache.org/licenses/LICENSE-2.0
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *
27111
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    17
 * See the License for the specific language governing permissions and
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    18
 * limitations under the License.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
package com.sun.org.apache.xerces.internal.impl.dtd.models;
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
 * A content model node.
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
 * @xerces.internal
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
public abstract class CMNode
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
    // -------------------------------------------------------------------
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
    //  Constructors
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
    // -------------------------------------------------------------------
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
    public CMNode(int type)
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
        fType = type;
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
    // -------------------------------------------------------------------
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
    //  Package, abstract methods
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
    // -------------------------------------------------------------------
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
    // made this public so it could be implemented and used outside this package -neilg.
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
    public abstract boolean isNullable() ;
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
    // -------------------------------------------------------------------
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
    //  Package final methods
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
    // -------------------------------------------------------------------
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
    public final int type()
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
        return fType;
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
    // made this public so it could be implemented and used outside this package -neilg.
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
    public final CMStateSet firstPos()
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
        if (fFirstPos == null)
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
            fFirstPos = new CMStateSet(fMaxStates);
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
            calcFirstPos(fFirstPos);
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
        return fFirstPos;
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
    // made this public so it could be implemented and used outside this package -neilg.
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
    public final CMStateSet lastPos()
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
        if (fLastPos == null)
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
        {
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
            fLastPos = new CMStateSet(fMaxStates);
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
            calcLastPos(fLastPos);
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
        return fLastPos;
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
    final void setFollowPos(CMStateSet setToAdopt)
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
        fFollowPos = setToAdopt;
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
    public final void setMaxStates(int maxStates)
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
        fMaxStates = maxStates;
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
27111
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    87
    public boolean isCompactedForUPA() {
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    88
        return fCompactedForUPA;
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    89
    }
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    90
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    91
    public void setIsCompactUPAModel(boolean value) {
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    92
        fCompactedForUPA = value;
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    93
    }
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
    94
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
     * Allows the user to set arbitrary data on this content model
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
     * node. This is used by the a{n,m} optimization that runs
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
     * in constant space.
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
    public void setUserData(Object userData) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
        fUserData = userData;
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
     * Allows the user to get arbitrary data set on this content
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
     * model node. This is used by the a{n,m} optimization that runs
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
     * in constant space.
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
    public Object getUserData() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
        return fUserData;
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
    // -------------------------------------------------------------------
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
    //  Protected, abstract methods
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
    // -------------------------------------------------------------------
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
    protected abstract void calcFirstPos(CMStateSet toSet) ;
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
    protected abstract void calcLastPos(CMStateSet toSet) ;
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
    // -------------------------------------------------------------------
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
    //  Private data members
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
    //  fType
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
    //      The type of node. This indicates whether its a leaf or an
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
    //      operation. Though we also do derived classes for these types,
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
    //      it is too expensive to use runtime typing to find this out.
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
    //      This is one of the ContentSpecNode.NODE_XXX types.
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
    //  fFirstPos
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
    //      The set of NFA states that represent the entry states of this
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
    //      node in the DFA.
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
    //  fFollowPos
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
    //      The set of NFA states that can be gotten to from from this
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
    //      node in the DFA.
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
    //  fLastPos
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
    //      The set of NFA states that represent the final states of this
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
    //      node in the DFA.
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
    //
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
    //  fMaxStates
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
    //      The maximum number of states that the NFA has, which means the
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
    //      max number of NFA states that have to be traced in the state
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
    //      sets during the building of the DFA. Its unfortunate that it
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
    //      has to be stored redundantly, but we need to fault in the
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
    //      state set members and they have to be sized to this size. We
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
    //      init to to -1 so it will cause an error if its used without
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
    //      being initialized.
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
    // -------------------------------------------------------------------
27111
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   151
    private final int  fType;
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   152
    private CMStateSet fFirstPos   = null;
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   153
    private CMStateSet fFollowPos  = null;
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   154
    private CMStateSet fLastPos    = null;
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   155
    private int        fMaxStates  = -1;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
    private Object      fUserData   = null;
27111
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   157
    /*
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   158
     * This boolean is true if the model represented by the CMNode does not represent
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   159
     * the true model from the schema, but has had its min/maxOccurs modified for a
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   160
     * more compact representation (for purposes of UPA).
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   161
     */
7a491d709b83 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents: 25868
diff changeset
   162
    private boolean fCompactedForUPA = false;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
};