001    /**
002     * Copyright 2007-2008 Arthur Blake
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *    http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package net.sf.log4jdbc;
017    
018    /**
019     * Static utility methods for use throughout the project.
020     */
021    public class Utilities {
022      /**
023       * Right justify a field within a certain number of spaces.
024       * @param fieldSize field size to right justify field within.
025       * @param field contents to right justify within field.
026       * @return the field, right justified within the requested size.
027       */
028      public static String rightJustify(int fieldSize, String field)
029      {
030        if (field==null)
031        {
032          field="";
033        }
034        StringBuffer output = new StringBuffer();
035        for (int i=0, j = fieldSize-field.length(); i < j; i++)
036        {
037          output.append(' ');
038        }
039        output.append(field);
040        return output.toString();
041      }
042    
043    }