001    package org.apache.jcs.admin;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import org.apache.jcs.engine.control.CompositeCache;
023    
024    /**
025     * Stores info on a cache region for the template
026     */
027    public class CacheRegionInfo
028    {
029        /** The cache region we are getting info on. */
030        CompositeCache<?,?> cache = null;
031    
032        /** number of bytes counted so far, will be a total of all items. */
033        long byteCount = 0;
034    
035        /**
036         * @return the underlying region
037         */
038        public CompositeCache<?, ?> getCache()
039        {
040            return this.cache;
041        }
042    
043        /**
044         * @return total byte count
045         */
046        public long getByteCount()
047        {
048            return this.byteCount;
049        }
050    
051        /**
052         * @return a status string
053         */
054        public String getStatus()
055        {
056            return this.cache.getStatus().toString();
057        }
058    
059        /**
060         * Return the stats for the region.
061         * <p>
062         * @return String
063         */
064        public String getStats()
065        {
066            return this.cache.getStats();
067        }
068    
069        /**
070         * @return string info on the region
071         */
072        @Override
073        public String toString()
074        {
075            StringBuffer buf = new StringBuffer();
076            buf.append( "\nCacheRegionInfo " );
077            if ( getCache() != null )
078            {
079                buf.append( "\n CacheName [" + getCache().getCacheName() + "]" );
080                buf.append( "\n Status [" + getStatus() + "]" );
081            }
082            buf.append( "\n ByteCount [" + getByteCount() + "]" );
083    
084            return buf.toString();
085        }
086    }