Coverage report

  %line %branch
org.apache.jetspeed.idgenerator.JetspeedIdGenerator
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  
 package org.apache.jetspeed.idgenerator;
 18  
 
 19  
 
 20  
 
 21  
 import org.apache.commons.logging.Log;
 22  
 import org.apache.commons.logging.LogFactory;
 23  
 
 24  
 /**
 25  
  * Simple implementation of the IdGeneratorService.
 26  
  *
 27  
  * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
 28  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 29  
  * @version $Id: JetspeedIdGenerator.java 516448 2007-03-09 16:25:47Z ate $
 30  
  */
 31  
 public class JetspeedIdGenerator implements IdGenerator
 32  
 {
 33  0
     private final static Log log = LogFactory.getLog(JetspeedIdGenerator.class);
 34  
 
 35  
     // default configuration values
 36  
     private final static long DEFAULT_CONFIG_COUNTER_START = 0x10000;
 37  
     private final static String DEFAULT_CONFIG_PEID_PREFIX = "P-";
 38  
     private final static String DEFAULT_CONFIG_PEID_SUFFIX = "";
 39  
 
 40  
     // configuration parameters
 41  0
     private String peidPrefix = null;
 42  0
     private String peidSuffix = null;
 43  
     protected long idCounter;
 44  
 
 45  
     public JetspeedIdGenerator()
 46  0
     {
 47  0
         this.idCounter = DEFAULT_CONFIG_COUNTER_START;
 48  0
         this.peidPrefix = DEFAULT_CONFIG_PEID_PREFIX;
 49  0
         this.peidSuffix = DEFAULT_CONFIG_PEID_SUFFIX;         
 50  0
     }
 51  
 
 52  
     public JetspeedIdGenerator(long counterStart)
 53  0
     {
 54  0
         this.idCounter = counterStart;
 55  0
         this.peidPrefix = DEFAULT_CONFIG_PEID_PREFIX;
 56  0
         this.peidSuffix = DEFAULT_CONFIG_PEID_SUFFIX; 
 57  0
     }
 58  
 
 59  
     public JetspeedIdGenerator(long counterStart, String prefix, String suffix)
 60  0
     {
 61  0
         this.idCounter = counterStart;
 62  0
         this.peidPrefix = prefix;
 63  0
         this.peidSuffix = suffix; 
 64  0
     }
 65  
     
 66  
     public void start() 
 67  
     {
 68  0
         log.info( "Start JetspeedIdGenerator");        
 69  0
      }
 70  
 
 71  
     public void stop() 
 72  
     {
 73  0
         log.info( "Shutdown for JetspeedIdGenerator called. idCounter = "
 74  
              + idCounter + " (" + Long.toHexString(idCounter) + ")" ); 
 75  0
     }
 76  
 
 77  
     /**
 78  
      * Generate a Unique PEID
 79  
      * @return Unique PEID
 80  
      */
 81  
     public String getNextPeid()
 82  
     {
 83  
         long newid;
 84  
 
 85  0
         synchronized(JetspeedIdGenerator.class)
 86  
         {
 87  0
             newid = idCounter++;
 88  0
         }
 89  
         
 90  0
         return peidPrefix + Long.toHexString(System.currentTimeMillis()) + "-" 
 91  
                + Long.toHexString(newid) + peidSuffix;
 92  
     }
 93  
     
 94  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.