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.simple; 23 24 import java.util.Map; 25 26 import org.apache.openoffice.ooxml.schema.misc.Log; 27 import org.apache.openoffice.ooxml.schema.model.simple.BuiltInType; 28 import org.apache.openoffice.ooxml.schema.model.simple.Restriction; 29 30 public class BlobNode 31 implements ISimpleTypeNode 32 { BlobNode(final BuiltInType eType)33 public BlobNode (final BuiltInType eType) 34 { 35 meType = eType; 36 mbIsList = false; 37 mnLengthRestriction = null; 38 } 39 40 41 42 GetBlobType()43 public BuiltInType GetBlobType () 44 { 45 return meType; 46 } 47 48 49 50 51 @Override ApplyRestriction( final Restriction aRestriction, final Map<String,Integer> aValueToIdMap)52 public void ApplyRestriction ( 53 final Restriction aRestriction, 54 final Map<String,Integer> aValueToIdMap) 55 { 56 if (aRestriction.GetFeatureBits() == 0) 57 return; 58 59 if (aRestriction.GetFeatureBits() != Restriction.LengthBit) 60 throw new RuntimeException("unsupported restriction on blob: "+aRestriction); 61 62 mnLengthRestriction = aRestriction.GetLength(); 63 } 64 65 66 67 68 @Override Print(final Log aLog)69 public void Print (final Log aLog) 70 { 71 aLog.printf("blob of type %s\n", meType); 72 } 73 74 75 76 77 @Override IsList()78 public boolean IsList () 79 { 80 return mbIsList; 81 } 82 83 84 85 86 @Override SetIsList()87 public void SetIsList () 88 { 89 mbIsList = true; 90 } 91 92 93 94 95 @Override AcceptVisitor(final ISimpleTypeNodeVisitor aVisitor)96 public void AcceptVisitor (final ISimpleTypeNodeVisitor aVisitor) 97 { 98 aVisitor.Visit(this); 99 } 100 101 102 103 104 public enum RestrictionType 105 { 106 Length, 107 None; 108 } GetRestrictionType()109 public RestrictionType GetRestrictionType () 110 { 111 if (mnLengthRestriction != null) 112 return RestrictionType.Length; 113 else 114 return RestrictionType.None; 115 } 116 117 118 119 GetLengthRestriction()120 public int GetLengthRestriction () 121 { 122 return mnLengthRestriction; 123 } 124 125 126 127 128 private final BuiltInType meType; 129 private boolean mbIsList; 130 private Integer mnLengthRestriction; 131 } 132