Java Doc for ArchiveUtils.java in  » Web-Crawler » heritrix » org » archive » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Crawler » heritrix » org.archive.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.archive.util.ArchiveUtils

ArchiveUtils
public class ArchiveUtils (Code)
Miscellaneous useful methods.
author:
   gojomo & others


Field Summary
public static  intMAX_INT_CHAR_WIDTH
    


Method Summary
public static  StringaddImpliedHttpIfNecessary(String u)
     Given a string that may be a plain host or host/path (without URI scheme), add an implied http:// if necessary.
public static  booleanbyteArrayEquals(byte[] lhs, byte[] rhs)
     check that two byte arrays are equal.
public static  longbyteArrayIntoLong(byte[] bytearray)
    
public static  longbyteArrayIntoLong(byte[] bytearray, int offset)
     Byte array into long.
Parameters:
  bytearray - Array to convert to a long.
Parameters:
  offset - Offset into array at which we start decoding the long.
public static  longclassnameBasedUID(Class class1, int version)
     Generate a long UID based on the given class and version number.
public static  StringdoubleToString(double val, int maxFractionDigits)
     Converts a double to a string.
public static  StringformatBytesForDisplay(long amount)
     Takes a byte size and formats it for display with 'friendly' units.
public static  StringformatMillisecondsToConventional(long time)
    
public static  StringformatMillisecondsToConventional(long time, boolean toMs)
    
public static  Stringget12DigitDate()
     Utility function for creating arc-style date stamps in the format yyyMMddHHmm.
public static  Stringget12DigitDate(long date)
     Utility function for creating arc-style date stamps in the format yyyyMMddHHmm.
public static  Stringget12DigitDate(Date d)
    
public static  Stringget14DigitDate()
     Utility function for creating arc-style date stamps in the format yyyMMddHHmmss.
public static  Stringget14DigitDate(long date)
     Utility function for creating arc-style date stamps in the format yyyyMMddHHmmss.
public static  Stringget14DigitDate(Date d)
    
public static  Stringget17DigitDate()
     Utility function for creating arc-style date stamps in the format yyyMMddHHmmssSSS.
public static  Stringget17DigitDate(long date)
     Utility function for creating arc-style date stamps in the format yyyyMMddHHmmssSSS.
public static  Stringget17DigitDate(Date date)
    
public static  DategetDate(String d)
     Parses an ARC-style date.
public static  StringgetLog14Date()
     Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC.
public static  StringgetLog14Date(long date)
     Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC.
public static  StringgetLog14Date(Date date)
     Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC.
public static  StringgetLog17Date()
     Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC.
public static  StringgetLog17Date(long date)
     Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC.
public static  DategetSecondsSinceEpoch(String timestamp)
    
Parameters:
  timestamp - A 14-digit timestamp or the suffix for a 14-digittimestamp: E.g.
public static  voidlongIntoByteArray(long l, byte[] array, int offset)
     Copy the raw bytes of a long into a byte array, starting at the specified offset.
public static  StringpadTo(int i, int pad)
     Convert an int to a String, and pad it to pad spaces.
Parameters:
  i - the int
Parameters:
  pad - the width to pad to.
public static  StringpadTo(String s, int pad)
     Pad the given String to pad characters wide by pre-pending spaces.
public static  StringpadTo(String s, int pad, char padChar)
     Pad the given String to pad characters wide by pre-pending padChar. s should not be null.
public static  Dateparse12DigitDate(String date)
     Utility function for parsing arc-style date stamps in the format yyyMMddHHmm. Date stamps are in the UTC time zone.
public static  Dateparse14DigitDate(String date)
     Utility function for parsing arc-style date stamps in the format yyyMMddHHmmss. Date stamps are in the UTC time zone.
public static  Dateparse17DigitDate(String date)
     Utility function for parsing arc-style date stamps in the format yyyMMddHHmmssSSS. Date stamps are in the UTC time zone.
public static  StringsecondsSinceEpoch(String timestamp)
    
Parameters:
  timestamp - A 14-digit timestamp or the suffix for a 14-digittimestamp: E.g.
public static  StringsingleLineReport(Reporter rep)
    
public static  booleanstartsWith(byte[] array, byte[] prefix)
     Verify that the array begins with the prefix.
public static  Calendartimestamp17ToCalendar(String timestamp17String)
     Convert 17-digit date format timestamps (as found in crawl.log, for example) into a GregorianCalendar object.
public static  StringwriteReportToString(Reporter rep, String name)
     Compose the requested report into a String.
public static  StringzeroPadInteger(int i)
    
Parameters:
  i - Integer to add prefix of zeros too.

Field Detail
MAX_INT_CHAR_WIDTH
public static int MAX_INT_CHAR_WIDTH(Code)





Method Detail
addImpliedHttpIfNecessary
public static String addImpliedHttpIfNecessary(String u)(Code)
Given a string that may be a plain host or host/path (without URI scheme), add an implied http:// if necessary.
Parameters:
  u - string to evaluate string with http:// added if no scheme already present



byteArrayEquals
public static boolean byteArrayEquals(byte[] lhs, byte[] rhs)(Code)
check that two byte arrays are equal. They may be null.
Parameters:
  lhs - a byte array
Parameters:
  rhs - another byte array. true if they are both equal (or bothnull)



byteArrayIntoLong
public static long byteArrayIntoLong(byte[] bytearray)(Code)



byteArrayIntoLong
public static long byteArrayIntoLong(byte[] bytearray, int offset)(Code)
Byte array into long.
Parameters:
  bytearray - Array to convert to a long.
Parameters:
  offset - Offset into array at which we start decoding the long. Long made of the bytes of array beginning atoffset offset.
See Also:   ArchiveUtils.longIntoByteArray(long,byte[],int)



classnameBasedUID
public static long classnameBasedUID(Class class1, int version)(Code)
Generate a long UID based on the given class and version number. Using this instead of the default will assume serialization compatibility across class changes unless version number is intentionally bumped.
Parameters:
  class1 -
Parameters:
  version - UID based off class and version number.



doubleToString
public static String doubleToString(double val, int maxFractionDigits)(Code)
Converts a double to a string.
Parameters:
  val - The double to convert
Parameters:
  precision - How many characters to include after '.' the double as a string.



formatBytesForDisplay
public static String formatBytesForDisplay(long amount)(Code)
Takes a byte size and formats it for display with 'friendly' units.

This involves converting it to the largest unit (of B, KB, MB, GB, TB) for which the amount will be > 1.

Additionally, at least 2 significant digits are always displayed.

Displays as bytes (B): 0-1023 Displays as kilobytes (KB): 1024 - 2097151 (~2Mb) Displays as megabytes (MB): 2097152 - 4294967295 (~4Gb) Displays as gigabytes (GB): 4294967296 - infinity

Negative numbers will be returned as '0 B'.
Parameters:
  amount - the amount of bytes A string containing the amount, properly formated.




formatMillisecondsToConventional
public static String formatMillisecondsToConventional(long time)(Code)
Convert milliseconds value to a human-readable duration
Parameters:
  time - Human readable string version of passed time



formatMillisecondsToConventional
public static String formatMillisecondsToConventional(long time, boolean toMs)(Code)
Convert milliseconds value to a human-readable duration
Parameters:
  time -
Parameters:
  toMs - whether to print to the ms Human readable string version of passed time



get12DigitDate
public static String get12DigitDate()(Code)
Utility function for creating arc-style date stamps in the format yyyMMddHHmm. Date stamps are in the UTC time zone the date stamp



get12DigitDate
public static String get12DigitDate(long date)(Code)
Utility function for creating arc-style date stamps in the format yyyyMMddHHmm. Date stamps are in the UTC time zone
Parameters:
  date - milliseconds since epoc the date stamp



get12DigitDate
public static String get12DigitDate(Date d)(Code)



get14DigitDate
public static String get14DigitDate()(Code)
Utility function for creating arc-style date stamps in the format yyyMMddHHmmss. Date stamps are in the UTC time zone the date stamp



get14DigitDate
public static String get14DigitDate(long date)(Code)
Utility function for creating arc-style date stamps in the format yyyyMMddHHmmss. Date stamps are in the UTC time zone
Parameters:
  date - milliseconds since epoc the date stamp



get14DigitDate
public static String get14DigitDate(Date d)(Code)



get17DigitDate
public static String get17DigitDate()(Code)
Utility function for creating arc-style date stamps in the format yyyMMddHHmmssSSS. Date stamps are in the UTC time zone the date stamp



get17DigitDate
public static String get17DigitDate(long date)(Code)
Utility function for creating arc-style date stamps in the format yyyyMMddHHmmssSSS. Date stamps are in the UTC time zone
Parameters:
  date - milliseconds since epoc the date stamp



get17DigitDate
public static String get17DigitDate(Date date)(Code)



getDate
public static Date getDate(String d) throws ParseException(Code)
Parses an ARC-style date. If passed String is < 12 characters in length, we pad. At a minimum, String should contain a year (>=4 characters). Parse will also fail if day or month are incompletely specified. Depends on the above getXXDigitDate methods.
Parameters:
  A - 4-17 digit date in ARC style (yyyy toyyyyMMddHHmmssSSS) formatting. A Date object representing the passed String.
throws:
  ParseException -



getLog14Date
public static String getLog14Date()(Code)
Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC. Use current time. Format is yyyy-MM-dd'T'HH:mm:ss'Z' the date stamp



getLog14Date
public static String getLog14Date(long date)(Code)
Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC. Format is yyyy-MM-dd'T'HH:mm:ss'Z'
Parameters:
  date - long timestamp to format. the date stamp



getLog14Date
public static String getLog14Date(Date date)(Code)
Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC. Format is yyyy-MM-dd'T'HH:mm:ss'Z'
Parameters:
  date - Date to format. the date stamp



getLog17Date
public static String getLog17Date()(Code)
Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC. Use current time. Format is yyyy-MM-dd'T'HH:mm:ss.SSS'Z' the date stamp



getLog17Date
public static String getLog17Date(long date)(Code)
Utility function for creating log timestamps, in W3C/ISO8601 format, assuming UTC. Format is yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
Parameters:
  date - Date to format. the date stamp



getSecondsSinceEpoch
public static Date getSecondsSinceEpoch(String timestamp) throws ParseException(Code)

Parameters:
  timestamp - A 14-digit timestamp or the suffix for a 14-digittimestamp: E.g. '20010909014640' or '20010101' or '1970'. A date.
See Also:   ArchiveUtils.secondsSinceEpoch(String)
throws:
  ParseException -



longIntoByteArray
public static void longIntoByteArray(long l, byte[] array, int offset)(Code)
Copy the raw bytes of a long into a byte array, starting at the specified offset.
Parameters:
  l -
Parameters:
  array -
Parameters:
  offset -



padTo
public static String padTo(int i, int pad)(Code)
Convert an int to a String, and pad it to pad spaces.
Parameters:
  i - the int
Parameters:
  pad - the width to pad to. String w/ padding.



padTo
public static String padTo(String s, int pad)(Code)
Pad the given String to pad characters wide by pre-pending spaces. s should not be null. If s is already wider than pad no change is done.
Parameters:
  s - the String to pad
Parameters:
  pad - the width to pad to. String w/ padding.



padTo
public static String padTo(String s, int pad, char padChar)(Code)
Pad the given String to pad characters wide by pre-pending padChar. s should not be null. If s is already wider than pad no change is done.
Parameters:
  s - the String to pad
Parameters:
  pad - the width to pad to.
Parameters:
  padChar - The pad character to use. String w/ padding.



parse12DigitDate
public static Date parse12DigitDate(String date) throws ParseException(Code)
Utility function for parsing arc-style date stamps in the format yyyMMddHHmm. Date stamps are in the UTC time zone. The whole string will not be parsed, only the first 12 digits.
Parameters:
  date - an arc-style formatted date stamp the Date corresponding to the date stamp string
throws:
  ParseException - if the inputstring was malformed



parse14DigitDate
public static Date parse14DigitDate(String date) throws ParseException(Code)
Utility function for parsing arc-style date stamps in the format yyyMMddHHmmss. Date stamps are in the UTC time zone. The whole string will not be parsed, only the first 14 digits.
Parameters:
  date - an arc-style formatted date stamp the Date corresponding to the date stamp string
throws:
  ParseException - if the inputstring was malformed



parse17DigitDate
public static Date parse17DigitDate(String date) throws ParseException(Code)
Utility function for parsing arc-style date stamps in the format yyyMMddHHmmssSSS. Date stamps are in the UTC time zone. The whole string will not be parsed, only the first 17 digits.
Parameters:
  date - an arc-style formatted date stamp the Date corresponding to the date stamp string
throws:
  ParseException - if the inputstring was malformed



secondsSinceEpoch
public static String secondsSinceEpoch(String timestamp) throws ParseException(Code)

Parameters:
  timestamp - A 14-digit timestamp or the suffix for a 14-digittimestamp: E.g. '20010909014640' or '20010101' or '1970'. Seconds since the epoch as a string zero-pre-padded so alwaysInteger.MAX_VALUE wide (Makes it so sorting of resultant string worksproperly).
throws:
  ParseException -



singleLineReport
public static String singleLineReport(Reporter rep)(Code)
Utility method to get a String singleLineReport from Reporter
Parameters:
  rep - Reporter to get singleLineReport from String of report



startsWith
public static boolean startsWith(byte[] array, byte[] prefix)(Code)
Verify that the array begins with the prefix.
Parameters:
  array -
Parameters:
  prefix - true if array is identical to prefix for the first prefix.lengthpositions



timestamp17ToCalendar
public static Calendar timestamp17ToCalendar(String timestamp17String)(Code)
Convert 17-digit date format timestamps (as found in crawl.log, for example) into a GregorianCalendar object. + * Useful so you can convert into milliseconds-since-epoch. Note: it is possible to compute milliseconds-since-epoch + * using ArchiveUtils.parse17DigitDate .UTC(), but that method is deprecated in favor of using Calendar.getTimeInMillis(). + *

I probably should have dug into all the utility methods in DateFormat.java to parse the timestamp, but this was + * easier. If someone wants to fix this to use those methods, please have at it!

Mike Schwartz, schwartz at CodeOnTheRoad dot com.
Parameters:
  timestamp17String - Calendar set to timestamp17String.




writeReportToString
public static String writeReportToString(Reporter rep, String name)(Code)
Compose the requested report into a String. DANGEROUS IF REPORT CAN BE LARGE.
Parameters:
  rep - Reported
Parameters:
  name - String name of report to compose String of report



zeroPadInteger
public static String zeroPadInteger(int i)(Code)

Parameters:
  i - Integer to add prefix of zeros too. If passed2005, will return the String 0000002005. Stringwidth is the width of Integer.MAX_VALUE as a string (10digits). Padded String version of i.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.