| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.jcs.engine.CacheElementSerialized |
|
|
| 1 | package org.apache.jcs.engine; |
|
| 2 | ||
| 3 | /* |
|
| 4 | * Licensed to the Apache Software Foundation (ASF) under one |
|
| 5 | * or more contributor license agreements. See the NOTICE file |
|
| 6 | * distributed with this work for additional information |
|
| 7 | * regarding copyright ownership. The ASF licenses this file |
|
| 8 | * to you under the Apache License, Version 2.0 (the |
|
| 9 | * "License"); you may not use this file except in compliance |
|
| 10 | * with the License. You may obtain a copy of the License at |
|
| 11 | * |
|
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 13 | * |
|
| 14 | * Unless required by applicable law or agreed to in writing, |
|
| 15 | * software distributed under the License is distributed on an |
|
| 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
| 17 | * KIND, either express or implied. See the License for the |
|
| 18 | * specific language governing permissions and limitations |
|
| 19 | * under the License. |
|
| 20 | */ |
|
| 21 | ||
| 22 | import java.io.Serializable; |
|
| 23 | ||
| 24 | import org.apache.jcs.engine.behavior.ICacheElementSerialized; |
|
| 25 | import org.apache.jcs.engine.behavior.IElementAttributes; |
|
| 26 | ||
| 27 | ||
| 28 | /** |
|
| 29 | * Either serialized value or the value should be null; |
|
| 30 | */ |
|
| 31 | public class CacheElementSerialized |
|
| 32 | implements ICacheElementSerialized |
|
| 33 | { |
|
| 34 | private static final long serialVersionUID = -7265084818647601874L; |
|
| 35 | ||
| 36 | /** The name of the cache region. This is a namespace. */ |
|
| 37 | private final String cacheName; |
|
| 38 | ||
| 39 | /** This is the cache key by which the value can be referenced. */ |
|
| 40 | private final Serializable key; |
|
| 41 | ||
| 42 | private final byte[] serializedValue; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * These attributes hold information about the element and what it is |
|
| 46 | * allowed to do. |
|
| 47 | */ |
|
| 48 | private IElementAttributes elementAttributes; |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Constructs a usable wrapper. |
|
| 52 | * <p> |
|
| 53 | * @param cacheNameArg |
|
| 54 | * @param keyArg |
|
| 55 | * @param serializedValueArg |
|
| 56 | * @param elementAttributesArg |
|
| 57 | */ |
|
| 58 | 1 | public CacheElementSerialized( String cacheNameArg, Serializable keyArg, byte[] serializedValueArg, |
| 59 | IElementAttributes elementAttributesArg ) |
|
| 60 | 756 | { |
| 61 | 757 | this.cacheName = cacheNameArg; |
| 62 | 757 | this.key = keyArg; |
| 63 | 757 | this.serializedValue = serializedValueArg; |
| 64 | 757 | this.elementAttributes = elementAttributesArg; |
| 65 | 757 | } |
| 66 | ||
| 67 | /** |
|
| 68 | * Returns the name of the cache. This is the name of the region. |
|
| 69 | */ |
|
| 70 | public String getCacheName() |
|
| 71 | { |
|
| 72 | 786 | return this.cacheName; |
| 73 | } |
|
| 74 | ||
| 75 | /* |
|
| 76 | * (non-Javadoc) |
|
| 77 | * @see org.apache.jcs.engine.behavior.ICacheElement#getKey() |
|
| 78 | */ |
|
| 79 | public Serializable getKey() |
|
| 80 | { |
|
| 81 | 4328 | return this.key; |
| 82 | } |
|
| 83 | ||
| 84 | /* |
|
| 85 | * (non-Javadoc) |
|
| 86 | * @see org.apache.jcs.engine.behavior.ICacheElementSerialized#getSerializedValue() |
|
| 87 | */ |
|
| 88 | public byte[] getSerializedValue() |
|
| 89 | { |
|
| 90 | 51 | return this.serializedValue; |
| 91 | } |
|
| 92 | ||
| 93 | /* |
|
| 94 | * (non-Javadoc) |
|
| 95 | * @see org.apache.jcs.engine.behavior.ICacheElement#getElementAttributes() |
|
| 96 | */ |
|
| 97 | public IElementAttributes getElementAttributes() |
|
| 98 | { |
|
| 99 | 800 | return this.elementAttributes; |
| 100 | } |
|
| 101 | ||
| 102 | /* |
|
| 103 | * (non-Javadoc) |
|
| 104 | * @see org.apache.jcs.engine.behavior.ICacheElement#setElementAttributes(org.apache.jcs.engine.behavior.IElementAttributes) |
|
| 105 | */ |
|
| 106 | public void setElementAttributes( IElementAttributes attr ) |
|
| 107 | { |
|
| 108 | 0 | this.elementAttributes = attr; |
| 109 | 0 | } |
| 110 | ||
| 111 | /** |
|
| 112 | * Backward compatibility. |
|
| 113 | */ |
|
| 114 | public Serializable getVal() |
|
| 115 | { |
|
| 116 | 721 | return null; |
| 117 | } |
|
| 118 | ||
| 119 | /** |
|
| 120 | * For debugging only. |
|
| 121 | */ |
|
| 122 | public String toString() |
|
| 123 | { |
|
| 124 | 8 | StringBuffer buf = new StringBuffer(); |
| 125 | 8 | buf.append( "\n CacheElementSerialized: " ); |
| 126 | 8 | buf.append( "\n CacheName = [" + getCacheName() + "]" ); |
| 127 | 8 | buf.append( "\n Key = [" + getKey() + "]" ); |
| 128 | 8 | buf.append( "\n SerializedValue = " + getSerializedValue() ); |
| 129 | 8 | buf.append( "\n ElementAttributes = " + getElementAttributes() ); |
| 130 | 8 | return buf.toString(); |
| 131 | } |
|
| 132 | ||
| 133 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |