Clover coverage report -
Coverage timestamp: Sun Nov 1 2009 23:08:24 UTC
file stats: LOC: 107   Methods: 12
NCLOC: 62   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Entry.java 50% 95% 91.7% 88.9%
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: Entry.java 594588 2007-11-13 17:21:25Z vgritsenko $
 18    */
 19   
 20    package org.apache.xindice.core.data;
 21   
 22    import org.w3c.dom.Document;
 23    import org.apache.xindice.xml.XMLSerializable;
 24   
 25    import java.util.Map;
 26    import java.util.HashMap;
 27    import java.util.Collections;
 28   
 29    /**
 30    * Entry is a high-level representation of a database record, that includes
 31    * its internal meta information.
 32    *
 33    * @version $Revision: 594588 $, $Date: 2007-11-13 17:21:25 +0000 (Tue, 13 Nov 2007) $
 34    */
 35    public class Entry {
 36   
 37    public static final byte UNKNOWN = 0;
 38    public static final byte DOCUMENT = 1;
 39    public static final byte BINARY = 2;
 40    public static final byte OBJECT = 3;
 41   
 42    public static final String CREATED = "created";
 43    public static final String MODIFIED = "modified";
 44   
 45    private final byte type;
 46    private final Key key;
 47    private final Object value;
 48    private final Map meta;
 49   
 50   
 51  98840 public Entry(byte type, Key key, Object value, Map meta) {
 52  98840 this.type = type;
 53  98840 this.key = key;
 54  98840 this.value = value;
 55  98840 this.meta = meta;
 56    }
 57   
 58  53320 public Entry(Key key, Document value, Map meta) {
 59  53320 this(DOCUMENT, key, value, meta);
 60    }
 61   
 62  22 public Entry(Key key, byte[] value, Map meta) {
 63  22 this(BINARY, key, value, meta);
 64    }
 65   
 66  0 public Entry(Key key, XMLSerializable value, Map meta) {
 67  0 this(OBJECT, key, value, meta);
 68    }
 69   
 70  49 public Entry(Key key, Map meta) {
 71  49 this(UNKNOWN, key, null, meta);
 72    }
 73   
 74   
 75  71448 public byte getEntryType() {
 76  71448 return type;
 77    }
 78   
 79  5 public Key getKey() {
 80  5 return key;
 81    }
 82   
 83  71426 public Object getValue() {
 84  71426 return value;
 85    }
 86   
 87  18158 public Map getMeta() {
 88  18158 return meta;
 89    }
 90   
 91  5 public long getCreationTime() {
 92  5 Long date = (Long) meta.get(CREATED);
 93  5 return date != null ? date.longValue() : 0;
 94    }
 95   
 96  5 public long getModificationTime() {
 97  5 Long date = (Long) meta.get(MODIFIED);
 98  5 return date != null ? date.longValue() : 0;
 99    }
 100   
 101  45449 public static Map createMetaMap(Record record) {
 102  45449 Map entryMeta = new HashMap(5);
 103  45449 entryMeta.put(Entry.CREATED, record.getMetaData(Record.CREATED));
 104  45449 entryMeta.put(Entry.MODIFIED, record.getMetaData(Record.MODIFIED));
 105  45449 return Collections.unmodifiableMap(entryMeta);
 106    }
 107    }