|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
NullReader.java | 0% | 0% | 0% | 0% |
|
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 | * contributor license agreements. See the NOTICE file distributed with | |
4 | * this work for additional information regarding copyright ownership. | |
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 | * (the "License"); you may not use this file except in compliance with | |
7 | * the License. You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | * | |
17 | * $Id: NullReader.java 541508 2007-05-25 01:54:12Z vgritsenko $ | |
18 | */ | |
19 | ||
20 | package org.apache.xindice.core.meta.inline; | |
21 | ||
22 | import org.apache.xindice.core.FaultCodes; | |
23 | import org.apache.xindice.core.data.Value; | |
24 | ||
25 | /** | |
26 | * Read metadata of length zero. Handy for comparing performance | |
27 | * of the metadata-free database with a database using the metadata | |
28 | * machinery but containing no metadata. | |
29 | * | |
30 | * @version $Revision: 541508 $, $Date: 2007-05-24 18:54:12 -0700 (Thu, 24 May 2007) $ | |
31 | */ | |
32 | public class NullReader implements InlineMetaReader { | |
33 | ||
34 | /** | |
35 | * @see org.apache.xindice.core.meta.inline.InlineMetaReader#getVersion() | |
36 | */ | |
37 | 0 | public int getVersion() { |
38 | 0 | return 0; |
39 | } | |
40 | ||
41 | /** | |
42 | * @see org.apache.xindice.core.meta.inline.InlineMetaReader#read(Value) | |
43 | */ | |
44 | 0 | public InlineMetaMap read(Value data) throws InlineMetaException { |
45 | 0 | if (data.getLength() != 0) { |
46 | 0 | throw new InlineMetaException(FaultCodes.COL_DOCUMENT_MALFORMED, |
47 | "Expecting header length of 0"); | |
48 | } | |
49 | ||
50 | 0 | return new NullMap(); |
51 | } | |
52 | ||
53 | /** | |
54 | * A VERY simple and efficient InlineMetaMap implementation | |
55 | * that holds precisely nothing. | |
56 | */ | |
57 | public static class NullMap implements InlineMetaMap { | |
58 | ||
59 | private static String[] keys = new String[]{}; | |
60 | ||
61 | /** | |
62 | * @see org.apache.xindice.core.meta.inline.InlineMetaMap#containsKey(String) | |
63 | */ | |
64 | 0 | public boolean containsKey(String key) { |
65 | 0 | return false; |
66 | } | |
67 | ||
68 | /** | |
69 | * @see org.apache.xindice.core.meta.inline.InlineMetaMap#get(String) | |
70 | */ | |
71 | 0 | public Object get(String key) throws InlineMetaException { |
72 | 0 | throw new InlineMetaException(FaultCodes.GEN_CRITICAL_ERROR, |
73 | "NullMap does not accept key '" + key + "'"); | |
74 | } | |
75 | ||
76 | /** | |
77 | * @see org.apache.xindice.core.meta.inline.InlineMetaMap#keys() | |
78 | */ | |
79 | 0 | public String[] keys() { |
80 | 0 | return keys; |
81 | } | |
82 | ||
83 | /** | |
84 | * @see org.apache.xindice.core.meta.inline.InlineMetaMap#put(String,Object) | |
85 | */ | |
86 | 0 | public void put(String key, Object value) throws InlineMetaException { |
87 | 0 | throw new InlineMetaException(FaultCodes.GEN_CRITICAL_ERROR, |
88 | "NullMap does not accept key '" + key + "'"); | |
89 | } | |
90 | } | |
91 | } |
|