Util.java revision 54
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * CDDL HEADER START
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * The contents of this file are subject to the terms of the
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * Common Development and Distribution License (the "License").
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * You may not use this file except in compliance with the License.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * See LICENSE.txt included in this distribution for the specific
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * language governing permissions and limitations under the License.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * When distributing Covered Code, include this CDDL HEADER in each
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * file and include the License file at LICENSE.txt.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * If applicable, add the following below this CDDL HEADER, with the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * fields enclosed by brackets "[]" replaced with your own identifying
565c6b62913edd14704b060e3172bba10b1fe12evboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * CDDL HEADER END
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync * Use is subject to license terms.
3dc9141e9dc45634498a9b543477bec0bcf5dab8vboxsync * ident "@(#)Util.java 1.2 05/12/01 SMI"
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync * File for useful functions
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsyncpublic class Util {
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync StringBuilder sb = new StringBuilder(q.length() * 2);
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync if (c == '&') {
3dc9141e9dc45634498a9b543477bec0bcf5dab8vboxsync } else if(c == '>') {
3dc9141e9dc45634498a9b543477bec0bcf5dab8vboxsync } else if(c == '<') {
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync } else if(c == '\n') {
3dc9141e9dc45634498a9b543477bec0bcf5dab8vboxsync public static void Htmlize(char[] cs, int length, Writer out) throws IOException {
66cd15f94910b1afc64c42375d40e01d5d33ad2fvboxsync if (c == '&') {
fa8e26644bdce3fe8590a2fd82433dc8bdf55414vboxsync } else if(c == '>') {
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync } else if(c == '<') {
e7aa635d70dd0cdf083287ec896fe8cca2775466vboxsync } else if(c == '\n') {
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync public static String breadcrumbPath(String urlPrefix, String l) {
2043260aa6abeee8eb8cf0309cebb97ede45851evboxsync public static String breadcrumbPath(String urlPrefix, String l, char sep) {
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync if (s < l.length()) {
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync float l = (float) num;
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync NumberFormat formatter = new DecimalFormat("#,###,###,###.#");
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync if ( l < 1024 ) {
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync } else if ( l < 1048576 ) {
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync return ("<b>" + formatter.format(l / 1048576)+ "M</b>");
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync public static void readableLine(int num, Writer out) throws IOException {
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync out.write((num > 999 ? " " : (num > 99 ? " " : (num > 9 ? " " : " "))));
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync * Append path and date into a string in such a way that lexicographic
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync * sorting gives the same results as a walk of the file hierarchy. Thus
df409c2a6d13641b0586a36103d015cc8d76da53vboxsync * null (\u0000) is used both to separate directory components and to
df409c2a6d13641b0586a36103d015cc8d76da53vboxsync * separate the path from the date.
df409c2a6d13641b0586a36103d015cc8d76da53vboxsync public static String uid(String path, String date) {
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync return path.replace(File.separatorChar, '\u0000') + "\u0000" + date;
9868c07279330f31ed91aa986bec707b7e8635a3vboxsync String url = uid.replace('\u0000', '/'); // replace nulls with slashes
df409c2a6d13641b0586a36103d015cc8d76da53vboxsync return url.substring(0, url.lastIndexOf('/')); // remove date from end
df409c2a6d13641b0586a36103d015cc8d76da53vboxsync private static char[] hexdigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync if(c == '"') {
d2c66e0925a76b3636d86b2afb2487fd6f956aebvboxsync return getRCSFile(file.getParent(), file.getName());
2043260aa6abeee8eb8cf0309cebb97ede45851evboxsync public static File getRCSFile(String parent, String name) {
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync BufferedReader rootReader = new BufferedReader(new FileReader(root));
f1630a6818621238c9c2338394b44995e318e108vboxsync BufferedReader repoReader = new BufferedReader(new FileReader(repository));
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync File atticFile = new File(dir + File.separatorChar + "Attic", filename);
13fdd42f1fc3e519650037a920e6a54c24973866vboxsync } catch (Exception e) {
b1fd0840de05fc2e189d4ea55ba33c2d6b09a4d8vboxsync return getSCCSFile(file.getParent(), file.getName());
7a006aff4af0ac1eaed18e272ecc9aeeaf41e4efvboxsync public static File getSCCSFile(String parent, String name) {