1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package org.apache.openoffice.ooxml.schema.model.complex; 23 24 import org.apache.openoffice.ooxml.schema.model.base.INodeVisitor; 25 import org.apache.openoffice.ooxml.schema.model.base.Location; 26 import org.apache.openoffice.ooxml.schema.model.base.Node; 27 import org.apache.openoffice.ooxml.schema.model.base.NodeType; 28 29 /** Representation of the 'all' XML schema element. All its children are 30 * expected to occur in any order. By default each child is optional but with 31 * a min=1 attribute the children can be made mandatory. 32 */ 33 public class All 34 extends Node 35 { All( final Node aParent, final Location aLocation)36 public All ( 37 final Node aParent, 38 final Location aLocation) 39 { 40 super(aParent, null, aLocation); 41 42 assert(CheckParent(aParent)); 43 } 44 45 46 47 48 /** Occurrence values of an 'all' node must be 49 * min=(0,1) 50 * max=1. 51 */ CheckParent(final Node aParent)52 private static boolean CheckParent (final Node aParent) 53 { 54 if (aParent == null) 55 return false; 56 if (aParent.GetNodeType() != NodeType.OccurrenceIndicator) 57 // Missing occurrence parent means that min and max have the default 58 // values of 0 and 1, which is valid. 59 return true; 60 61 final OccurrenceIndicator aIndicator = (OccurrenceIndicator)aParent; 62 if (aIndicator.GetMinimum() > 1) 63 return false; 64 else if (aIndicator.GetMaximum() != 1) 65 return false; 66 else 67 return true; 68 } 69 70 71 72 73 @Override AcceptVisitor(final INodeVisitor aVisitor)74 public void AcceptVisitor (final INodeVisitor aVisitor) 75 { 76 aVisitor.Visit(this); 77 } 78 79 80 81 82 @Override GetNodeType()83 public NodeType GetNodeType() 84 { 85 return NodeType.All; 86 } 87 88 89 90 91 @Override toString()92 public String toString () 93 { 94 return "all"; 95 } 96 } 97