Clover coverage report -
Coverage timestamp: Sun Nov 1 2009 23:08:24 UTC
file stats: LOC: 130   Methods: 5
NCLOC: 52   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
XMLCompressedOutput.java 83.3% 74.2% 100% 78.6%
coverage coverage
 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: XMLCompressedOutput.java 541508 2007-05-25 01:54:12Z vgritsenko $
 18    */
 19   
 20    package org.apache.xindice.xml;
 21   
 22    import java.io.DataOutputStream;
 23    import java.io.IOException;
 24    import java.io.OutputStream;
 25   
 26    /**
 27    * XMLCompressedInput is an OutputStream extension that provides functions for
 28    * writing types to a Xindice Compressed XML Stream.
 29    *
 30    * @version $Revision: 541508 $, $Date: 2007-05-24 18:54:12 -0700 (Thu, 24 May 2007) $
 31    */
 32    public class XMLCompressedOutput extends DataOutputStream {
 33   
 34    protected SymbolTable st;
 35   
 36   
 37  225916 public XMLCompressedOutput(OutputStream os, SymbolTable st) {
 38  225916 super(os);
 39  225916 this.st = st;
 40    }
 41   
 42    /**
 43    * getSizeType returns the optimal size type for the specifed
 44    * length value.
 45    *
 46    * @see org.apache.xindice.xml.Signatures
 47    *
 48    * @param length The length to evaluate
 49    * @return The optimal size
 50    */
 51  628444 protected final byte getSizeType(long length) {
 52  628444 if (length > Short.MAX_VALUE) {
 53  0 return Signatures.SIZE_INT;
 54  628444 } else if (length > Byte.MAX_VALUE) {
 55  14782 return Signatures.SIZE_SHORT;
 56  613662 } else if (length > 0) {
 57  484964 return Signatures.SIZE_BYTE;
 58    } else {
 59  128694 return Signatures.SIZE_NONE;
 60    }
 61    }
 62   
 63    /**
 64    * getSizeSize returns the size (in bytes) of the specified
 65    * size type.
 66    *
 67    * @see org.apache.xindice.xml.Signatures
 68    *
 69    * @param sizeType The size type
 70    * @return The size in bytes
 71    */
 72  318148 protected final int getSizeSize(int sizeType) {
 73  318148 switch (sizeType) {
 74  0 case Signatures.SIZE_INT:
 75  0 return 4;
 76  14782 case Signatures.SIZE_SHORT:
 77  14782 return 2;
 78  303366 case Signatures.SIZE_BYTE:
 79  303366 return 1;
 80  0 default:
 81  0 return 0;
 82    }
 83    }
 84   
 85    /**
 86    * Writes the size to the output stream. Size type is determined
 87    * based on the passed size value.
 88    *
 89    *
 90    * @see org.apache.xindice.xml.Signatures
 91    *
 92    * @param size The size
 93    * @return The size in bytes written
 94    * @throws IOException If the write failed
 95    */
 96  155149 protected final int writeSize(int size) throws IOException {
 97  155149 return writeSize(getSizeType(size), size);
 98    }
 99   
 100    /**
 101    * writeSize writes the size to the output stream based on the
 102    * specified sizeType.
 103    *
 104    * @see org.apache.xindice.xml.Signatures
 105    *
 106    * @param sizeType The size type
 107    * @param size The size
 108    * @return The size in bytes written
 109    * @throws IOException If the write failed
 110    */
 111  473295 protected final int writeSize(int sizeType, int size) throws IOException {
 112  473295 switch (sizeType) {
 113   
 114  0 case Signatures.SIZE_INT:
 115  0 writeInt(size);
 116  0 return 4;
 117   
 118  14782 case Signatures.SIZE_SHORT:
 119  14782 writeShort((short) size);
 120  14782 return 2;
 121   
 122  394166 case Signatures.SIZE_BYTE:
 123  394166 writeByte((byte) size);
 124  394168 return 1;
 125   
 126  64347 default:
 127  64347 return 0;
 128    }
 129    }
 130    }