Updated for Lifeblog 1.0.
This commit is contained in:
parent
96154a06c8
commit
3fac476ddf
5 changed files with 396 additions and 273 deletions
136
LifeBlogger.iws
136
LifeBlogger.iws
|
@ -112,19 +112,26 @@
|
|||
<option name="HIDE_WARNINGS" value="false" />
|
||||
</component>
|
||||
<component name="FileEditorManager" split-orientation="vertical" split-proportion="0.5">
|
||||
<first-group selected-file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeFTP.java">
|
||||
<first-group selected-file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/Base64.java">
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeFTP.java" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="57" column="13" selection-start="2224" selection-end="2224" vertical-scroll-proportion="-2.0806916">
|
||||
<state line="57" column="13" selection-start="2224" selection-end="2224" vertical-scroll-proportion="1.0778098">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/Base64.java" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="6" column="51" selection-start="114" selection-end="114" vertical-scroll-proportion="0.2939481">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeBlog.java" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="57" column="23" selection-start="2216" selection-end="2216" vertical-scroll-proportion="0.048991356">
|
||||
<state line="57" column="23" selection-start="2216" selection-end="2216" vertical-scroll-proportion="0.1037464">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -133,7 +140,7 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeBlogger.java" pinned="false">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="402" column="25" selection-start="9606" selection-end="9613" vertical-scroll-proportion="11.0951">
|
||||
<state line="402" column="25" selection-start="9606" selection-end="9613" vertical-scroll-proportion="1.6051873">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -174,15 +181,15 @@
|
|||
<component name="PackagesPane">
|
||||
<expanded_node url="net.thauvin.lifeblogger" module="LifeBlogger" type="package" />
|
||||
<expanded_node url="net.thauvin" module="LifeBlogger" type="package" />
|
||||
<expanded_node url="net" module="LifeBlogger" type="package" />
|
||||
<expanded_node url="" module="LifeBlogger" type="module" />
|
||||
<expanded_node url="net" module="LifeBlogger" type="package" />
|
||||
</component>
|
||||
<component name="ProjectPane">
|
||||
<expanded_node url="file://$PROJECT_DIR$" module="LifeBlogger" type="directory" />
|
||||
<expanded_node url="" module="LifeBlogger" type="module" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="PackagesPane" splitterProportion="0.5">
|
||||
<navigator currentView="ProjectPane" splitterProportion="0.5">
|
||||
<flattenPackages />
|
||||
<showMembers />
|
||||
<showModules />
|
||||
|
@ -206,13 +213,6 @@
|
|||
</component>
|
||||
<component name="RunManager">
|
||||
<activeType name="Application" />
|
||||
<configuration selected="false" default="true" type="Application" factoryName="Application">
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<module name="" />
|
||||
</configuration>
|
||||
<configuration selected="false" default="true" type="JUnit" factoryName="JUnit">
|
||||
<module name="" />
|
||||
<option name="PACKAGE_NAME" />
|
||||
|
@ -234,6 +234,23 @@
|
|||
<option name="HOST" value="localhost" />
|
||||
<option name="PORT" value="5005" />
|
||||
</configuration>
|
||||
<configuration selected="false" default="true" type="Application" factoryName="Application">
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<module name="" />
|
||||
</configuration>
|
||||
<configuration selected="false" default="true" type="Applet" factoryName="Applet">
|
||||
<module name="" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="HTML_FILE_NAME" />
|
||||
<option name="HTML_USED" value="false" />
|
||||
<option name="WIDTH" value="400" />
|
||||
<option name="HEIGHT" value="300" />
|
||||
<option name="POLICY_FILE" value="C:/IntelliJ-IDEA/bin/appletviewer.policy" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
</configuration>
|
||||
<configuration selected="false" default="true" type="WebLogic Instance" factoryName="Local">
|
||||
<option name="WORKING_DIRECTORY" />
|
||||
<option name="HOST" value="localhost" />
|
||||
|
@ -248,16 +265,6 @@
|
|||
<option name="SERVER_NAME" value="myserver" />
|
||||
<option name="DOMAIN_NAME" value="mydomain" />
|
||||
</configuration>
|
||||
<configuration selected="false" default="true" type="Applet" factoryName="Applet">
|
||||
<module name="" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="HTML_FILE_NAME" />
|
||||
<option name="HTML_USED" value="false" />
|
||||
<option name="WIDTH" value="400" />
|
||||
<option name="HEIGHT" value="300" />
|
||||
<option name="POLICY_FILE" value="C:/IntelliJ-IDEA/bin/appletviewer.policy" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
</configuration>
|
||||
<configuration selected="true" default="false" name="LifeBlogger" type="Application" factoryName="Application">
|
||||
<option name="MAIN_CLASS_NAME" value="net.thauvin.lifeblogger.LifeBlogger" />
|
||||
<option name="VM_PARAMETERS" value="-Djava.library.path=D:\projects\java\LifeBlogger\libexec" />
|
||||
|
@ -327,13 +334,13 @@
|
|||
<window_info id="CVS" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33024693" order="8" />
|
||||
<window_info id="Regex" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33024693" order="9" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="7" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.27142859" order="0" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.24081632" order="0" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33024693" order="1" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="1" />
|
||||
<window_info id="Messages" active="true" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.33024693" order="10" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.69135803" order="6" x="66" y="104" width="924" height="583" />
|
||||
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="11" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.11020408" order="1" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.10510204" order="1" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33796296" order="2" />
|
||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="2" />
|
||||
<window_info id="CVS File View" active="false" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="3" />
|
||||
|
@ -442,20 +449,6 @@
|
|||
</buildFile>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/webstart.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="50" column="78" selection-start="1751" selection-end="1751" vertical-scroll-proportion="0.27706423">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/Base64.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="47" column="13" selection-start="2322" selection-end="2322" vertical-scroll-proportion="0.9445351">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeAction.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="52" column="22" selection-start="2054" selection-end="2054" vertical-scroll-proportion="0.47145188">
|
||||
|
@ -472,23 +465,12 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/buildnum.properties">
|
||||
<provider selected="true" editor-type-id="properties">
|
||||
<state line="2" column="0" selection-start="81" selection-end="81" vertical-scroll-offset="0" key-parts-delimiter="'.'">
|
||||
<NAVIGATION_TREE>
|
||||
<expanded path="build" />
|
||||
<expanded path="build.num" />
|
||||
<expanded path="" />
|
||||
</NAVIGATION_TREE>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/ftp.properties">
|
||||
<provider selected="true" editor-type-id="properties">
|
||||
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-offset="0" key-parts-delimiter="'.'">
|
||||
<NAVIGATION_TREE>
|
||||
<expanded path="ftp" />
|
||||
<expanded path="" />
|
||||
<expanded path="ftp" />
|
||||
</NAVIGATION_TREE>
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -530,9 +512,18 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeFTP.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="57" column="13" selection-start="2224" selection-end="2224" vertical-scroll-proportion="1.0778098">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeBlog.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="57" column="23" selection-start="2216" selection-end="2216" vertical-scroll-proportion="0.048991356">
|
||||
<state line="57" column="23" selection-start="2216" selection-end="2216" vertical-scroll-proportion="0.1037464">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -546,6 +537,15 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeBlogger.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="402" column="25" selection-start="9606" selection-end="9613" vertical-scroll-proportion="1.6051873">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeMediaObject.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="53" column="13" selection-start="2109" selection-end="2109" vertical-scroll-proportion="0.8818444">
|
||||
|
@ -555,21 +555,31 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeBlogger.java">
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/Base64.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="402" column="25" selection-start="9606" selection-end="9613" vertical-scroll-proportion="11.0951">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
<state line="6" column="51" selection-start="114" selection-end="114" vertical-scroll-proportion="0.2939481">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeFTP.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="57" column="13" selection-start="2224" selection-end="2224" vertical-scroll-proportion="-2.0806916">
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
<entry file="file://$PROJECT_DIR$/build.properties">
|
||||
<provider selected="true" editor-type-id="properties">
|
||||
<state line="2" column="18" selection-start="50" selection-end="50" vertical-scroll-offset="0" key-parts-delimiter="'.'">
|
||||
<NAVIGATION_TREE>
|
||||
<expanded path="proj" />
|
||||
<expanded path="" />
|
||||
</NAVIGATION_TREE>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/buildnum.properties">
|
||||
<provider selected="true" editor-type-id="properties">
|
||||
<state line="2" column="16" selection-start="97" selection-end="97" vertical-scroll-offset="0" key-parts-delimiter="'.'">
|
||||
<NAVIGATION_TREE>
|
||||
<expanded path="build" />
|
||||
<expanded path="build.num" />
|
||||
<expanded path="" />
|
||||
</NAVIGATION_TREE>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Project
|
||||
proj.name=LifeBlogger
|
||||
proj.version=0.1.0
|
||||
proj.version=0.1.1
|
||||
proj.package=net.thauvin.lifeblogger
|
||||
proj.run=${proj.package}.LifeBlogger
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ package net.thauvin.lifeblogger;
|
|||
* Change Log:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>v2.1 - Cleaned up javadoc comments and unused variables and methods. Added
|
||||
* some convenience methods for reading and writing to and from files.</li>
|
||||
* <li>v2.0.2 - Now specifies UTF-8 encoding in places where the code fails on systems
|
||||
* with other encodings (like EBCDIC).</li>
|
||||
* <li>v2.0.1 - Fixed an error when decoding a single byte, that is, when the
|
||||
|
@ -37,13 +39,13 @@ package net.thauvin.lifeblogger;
|
|||
* I am placing this code in the Public Domain. Do with it as you will.
|
||||
* This software comes with no guarantees or warranties but with
|
||||
* plenty of well-wishing instead!
|
||||
* Please visit <a href="http://iharder.net/xmlizable">http://iharder.net/base64</a>
|
||||
* Please visit <a href="http://iharder.net/base64">http://iharder.net/base64</a>
|
||||
* periodically to check for updates or to contribute improvements.
|
||||
* </p>
|
||||
*
|
||||
* @author Robert Harder
|
||||
* @author rob@iharder.net
|
||||
* @version 2.0
|
||||
* @version 2.1
|
||||
*/
|
||||
public class Base64
|
||||
{
|
||||
|
@ -111,7 +113,7 @@ public class Base64
|
|||
byte[] __bytes;
|
||||
try
|
||||
{
|
||||
__bytes = new String("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").getBytes( PREFERRED_ENCODING );
|
||||
__bytes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".getBytes( PREFERRED_ENCODING );
|
||||
} // end try
|
||||
catch (java.io.UnsupportedEncodingException use)
|
||||
{
|
||||
|
@ -160,7 +162,8 @@ public class Base64
|
|||
-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */
|
||||
};
|
||||
|
||||
private final static byte BAD_ENCODING = -9; // Indicates error in encoding
|
||||
// I think I end up not using the BAD_ENCODING indicator.
|
||||
//private final static byte BAD_ENCODING = -9; // Indicates error in encoding
|
||||
private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding
|
||||
private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
|
||||
|
||||
|
@ -174,41 +177,6 @@ public class Base64
|
|||
|
||||
|
||||
/**
|
||||
* Encodes the first three bytes of array <var>threeBytes</var>
|
||||
* and returns a four-byte array in Base64 notation.
|
||||
*
|
||||
* @param threeBytes the array to convert
|
||||
* @return four byte array in Base64 notation.
|
||||
* @since 1.3
|
||||
*/
|
||||
private static byte[] encode3to4( byte[] threeBytes )
|
||||
{
|
||||
return encode3to4( threeBytes, 3 );
|
||||
} // end encodeToBytes
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Encodes up to the first three bytes of array <var>threeBytes</var>
|
||||
* and returns a four-byte array in Base64 notation.
|
||||
* The actual number of significant bytes in your array is
|
||||
* given by <var>numSigBytes</var>.
|
||||
* The array <var>threeBytes</var> needs only be as big as
|
||||
* <var>numSigBytes</var>.
|
||||
*
|
||||
* @param threeBytes the array to convert
|
||||
* @param numSigBytes the number of significant bytes in your array
|
||||
* @return four byte array in Base64 notation.
|
||||
* @since 1.3
|
||||
*/
|
||||
private static byte[] encode3to4( byte[] threeBytes, int numSigBytes )
|
||||
{
|
||||
byte[] dest = new byte[4];
|
||||
encode3to4( threeBytes, 0, numSigBytes, dest, 0 );
|
||||
return dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes up to the first three bytes of array <var>threeBytes</var>
|
||||
* and returns a four-byte array in Base64 notation.
|
||||
* The actual number of significant bytes in your array is
|
||||
|
@ -335,7 +303,7 @@ public class Base64
|
|||
* Example: <code>encodeObject( myObj, Base64.GZIP | Base64.DONT_BREAK_LINES )</code>
|
||||
*
|
||||
* @param serializableObject The object to encode
|
||||
* @options Specified options
|
||||
* @param options Specified options
|
||||
* @return The Base64-encoded object
|
||||
* @see Base64#GZIP
|
||||
* @see Base64#DONT_BREAK_LINES
|
||||
|
@ -470,7 +438,6 @@ public class Base64
|
|||
* @param source The data to convert
|
||||
* @param off Offset in array where conversion should begin
|
||||
* @param len Length of data to convert
|
||||
* @param breakLines Break lines at 80 characters or less.
|
||||
* @param options Specified options
|
||||
* @see Base64#GZIP
|
||||
* @see Base64#DONT_BREAK_LINES
|
||||
|
@ -578,30 +545,6 @@ public class Base64
|
|||
/* ******** D E C O D I N G M E T H O D S ******** */
|
||||
|
||||
|
||||
/**
|
||||
* Decodes the first four bytes of array <var>fourBytes</var>
|
||||
* and returns an array up to three bytes long with the
|
||||
* decoded values.
|
||||
*
|
||||
* @param fourBytes the array with Base64 content
|
||||
* @return array with decoded values
|
||||
* @since 1.3
|
||||
*/
|
||||
private static byte[] decode4to3( byte[] fourBytes )
|
||||
{
|
||||
byte[] outBuff1 = new byte[3];
|
||||
int count = decode4to3( fourBytes, 0, outBuff1, 0 );
|
||||
byte[] outBuff2 = new byte[ count ];
|
||||
|
||||
for( int i = 0; i < count; i++ )
|
||||
outBuff2[i] = outBuff1[i];
|
||||
|
||||
return outBuff2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Decodes four bytes from array <var>source</var>
|
||||
* and writes the resulting bytes (up to three of them)
|
||||
|
@ -775,14 +718,11 @@ public class Base64
|
|||
|
||||
// Check to see if it's gzip-compressed
|
||||
// GZIP Magic Two-Byte Number: 0x8b1f (35615)
|
||||
if( bytes.length >= 2 )
|
||||
if( bytes != null && bytes.length >= 4 )
|
||||
{
|
||||
|
||||
int head = ((int)bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
|
||||
if(
|
||||
bytes != null && // In case decoding returned null
|
||||
bytes.length >= 4 && // Don't want to get ArrayIndexOutOfBounds exception
|
||||
java.util.zip.GZIPInputStream.GZIP_MAGIC == head )
|
||||
if( java.util.zip.GZIPInputStream.GZIP_MAGIC == head )
|
||||
{
|
||||
java.io.ByteArrayInputStream bais = null;
|
||||
java.util.zip.GZIPInputStream gzis = null;
|
||||
|
@ -869,22 +809,196 @@ public class Base64
|
|||
} // end decodeObject
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convenience method for encoding data to a file.
|
||||
*
|
||||
* @param dataToEncode byte array of data to encode in base64 form
|
||||
* @param filename Filename for saving encoded data
|
||||
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public static boolean encodeToFile( byte[] dataToEncode, String filename )
|
||||
{
|
||||
boolean success = false;
|
||||
Base64.OutputStream bos = null;
|
||||
try
|
||||
{
|
||||
bos = new Base64.OutputStream(
|
||||
new java.io.FileOutputStream( filename ), Base64.ENCODE );
|
||||
bos.write( dataToEncode );
|
||||
success = true;
|
||||
} // end try
|
||||
catch( java.io.IOException e )
|
||||
{
|
||||
|
||||
success = false;
|
||||
} // end catch: IOException
|
||||
finally
|
||||
{
|
||||
try{ bos.close(); } catch( Exception e ){}
|
||||
} // end finally
|
||||
|
||||
return success;
|
||||
} // end encodeToFile
|
||||
|
||||
|
||||
/**
|
||||
* Convenience method for decoding data to a file.
|
||||
*
|
||||
* @param dataToDecode Base64-encoded data as a string
|
||||
* @param filename Filename for saving decoded data
|
||||
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public static boolean decodeToFile( String dataToDecode, String filename )
|
||||
{
|
||||
boolean success = false;
|
||||
Base64.OutputStream bos = null;
|
||||
try
|
||||
{
|
||||
bos = new Base64.OutputStream(
|
||||
new java.io.FileOutputStream( filename ), Base64.DECODE );
|
||||
bos.write( dataToDecode.getBytes( PREFERRED_ENCODING ) );
|
||||
success = true;
|
||||
} // end try
|
||||
catch( java.io.IOException e )
|
||||
{
|
||||
success = false;
|
||||
} // end catch: IOException
|
||||
finally
|
||||
{
|
||||
try{ bos.close(); } catch( Exception e ){}
|
||||
} // end finally
|
||||
|
||||
return success;
|
||||
} // end decodeToFile
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convenience method for reading a base64-encoded
|
||||
* file and decoding it.
|
||||
*
|
||||
* @param filename Filename for reading encoded data
|
||||
* @return decoded byte array or null if unsuccessful
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public static byte[] decodeFromFile( String filename )
|
||||
{
|
||||
byte[] decodedData = null;
|
||||
Base64.InputStream bis = null;
|
||||
try
|
||||
{
|
||||
// Set up some useful variables
|
||||
java.io.File file = new java.io.File( filename );
|
||||
byte[] buffer = null;
|
||||
int length = 0;
|
||||
int numBytes = 0;
|
||||
|
||||
// Check for size of file
|
||||
if( file.length() > Integer.MAX_VALUE )
|
||||
{
|
||||
System.err.println( "File is too big for this convenience method (" + file.length() + " bytes)." );
|
||||
return null;
|
||||
} // end if: file too big for int index
|
||||
buffer = new byte[ (int)file.length() ];
|
||||
|
||||
// Open a stream
|
||||
bis = new Base64.InputStream(
|
||||
new java.io.BufferedInputStream(
|
||||
new java.io.FileInputStream( file ) ), Base64.DECODE );
|
||||
|
||||
// Read until done
|
||||
while( ( numBytes = bis.read( buffer, length, 4096 ) ) >= 0 )
|
||||
length += numBytes;
|
||||
|
||||
// Save in a variable to return
|
||||
decodedData = new byte[ length ];
|
||||
System.arraycopy( buffer, 0, decodedData, 0, length );
|
||||
|
||||
} // end try
|
||||
catch( java.io.IOException e )
|
||||
{
|
||||
System.err.println( "Error decoding from file " + filename );
|
||||
} // end catch: IOException
|
||||
finally
|
||||
{
|
||||
try{ bis.close(); } catch( Exception e) {}
|
||||
} // end finally
|
||||
|
||||
return decodedData;
|
||||
} // end decodeFromFile
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convenience method for reading a binary file
|
||||
* and base64-encoding it.
|
||||
*
|
||||
* @param filename Filename for reading binary data
|
||||
* @return base64-encoded string or null if unsuccessful
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public static String encodeFromFile( String filename )
|
||||
{
|
||||
String encodedData = null;
|
||||
Base64.InputStream bis = null;
|
||||
try
|
||||
{
|
||||
// Set up some useful variables
|
||||
java.io.File file = new java.io.File( filename );
|
||||
byte[] buffer = new byte[ (int)(file.length() * 1.4) ];
|
||||
int length = 0;
|
||||
int numBytes = 0;
|
||||
|
||||
// Open a stream
|
||||
bis = new Base64.InputStream(
|
||||
new java.io.BufferedInputStream(
|
||||
new java.io.FileInputStream( file ) ), Base64.ENCODE );
|
||||
|
||||
// Read until done
|
||||
while( ( numBytes = bis.read( buffer, length, 4096 ) ) >= 0 )
|
||||
length += numBytes;
|
||||
|
||||
// Save in a variable to return
|
||||
encodedData = new String( buffer, 0, length, Base64.PREFERRED_ENCODING );
|
||||
|
||||
} // end try
|
||||
catch( java.io.IOException e )
|
||||
{
|
||||
System.err.println( "Error encoding from file " + filename );
|
||||
} // end catch: IOException
|
||||
finally
|
||||
{
|
||||
try{ bis.close(); } catch( Exception e) {}
|
||||
} // end finally
|
||||
|
||||
return encodedData;
|
||||
} // end encodeFromFile
|
||||
|
||||
|
||||
|
||||
|
||||
/* ******** I N N E R C L A S S I N P U T S T R E A M ******** */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A {@link Base64#InputStream} will read data from another
|
||||
* {@link java.io.InputStream}, given in the constructor,
|
||||
* A {@link Base64.InputStream} will read data from another
|
||||
* <tt>java.io.InputStream</tt>, given in the constructor,
|
||||
* and encode/decode to/from Base64 notation on the fly.
|
||||
*
|
||||
* @see Base64
|
||||
* @see java.io.FilterInputStream
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class InputStream extends java.io.FilterInputStream
|
||||
{
|
||||
private int options; // Options specified
|
||||
private boolean encode; // Encoding or decoding
|
||||
private int position; // Current position in the buffer
|
||||
private byte[] buffer; // Small buffer holding converted data
|
||||
|
@ -895,9 +1009,9 @@ public class Base64
|
|||
|
||||
|
||||
/**
|
||||
* Constructs a {@link Base64#InputStream} in DECODE mode.
|
||||
* Constructs a {@link Base64.InputStream} in DECODE mode.
|
||||
*
|
||||
* @param in the {@link java.io.InputStream} from which to read data.
|
||||
* @param in the <tt>java.io.InputStream</tt> from which to read data.
|
||||
* @since 1.3
|
||||
*/
|
||||
public InputStream( java.io.InputStream in )
|
||||
|
@ -907,7 +1021,7 @@ public class Base64
|
|||
|
||||
|
||||
/**
|
||||
* Constructs a {@link Base64#InputStream} in
|
||||
* Constructs a {@link Base64.InputStream} in
|
||||
* either ENCODE or DECODE mode.
|
||||
* <p>
|
||||
* Valid options:<pre>
|
||||
|
@ -920,7 +1034,7 @@ public class Base64
|
|||
* Example: <code>new Base64.InputStream( in, Base64.DECODE )</code>
|
||||
*
|
||||
*
|
||||
* @param in the {@link java.io.InputStream} from which to read data.
|
||||
* @param in the <tt>java.io.InputStream</tt> from which to read data.
|
||||
* @param options Specified options
|
||||
* @see Base64#ENCODE
|
||||
* @see Base64#DECODE
|
||||
|
@ -930,11 +1044,8 @@ public class Base64
|
|||
public InputStream( java.io.InputStream in, int options )
|
||||
{
|
||||
super( in );
|
||||
this.options = options;
|
||||
this.breakLines = (options & DONT_BREAK_LINES) != DONT_BREAK_LINES;
|
||||
this.encode = (options & ENCODE) == ENCODE;
|
||||
this.breakLines = breakLines;
|
||||
this.encode = encode;
|
||||
this.bufferLength = encode ? 4 : 3;
|
||||
this.buffer = new byte[ bufferLength ];
|
||||
this.position = -1;
|
||||
|
@ -1065,7 +1176,7 @@ public class Base64
|
|||
|
||||
|
||||
/**
|
||||
* Calls {@link #read} repeatedly until the end of stream
|
||||
* Calls {@link #read()} repeatedly until the end of stream
|
||||
* is reached or <var>len</var> bytes are read.
|
||||
* Returns number of bytes read into array or -1 if
|
||||
* end of stream is encountered.
|
||||
|
@ -1109,17 +1220,15 @@ public class Base64
|
|||
|
||||
|
||||
/**
|
||||
* A {@link Base64#OutputStream} will write data to another
|
||||
* {@link java.io.OutputStream}, given in the constructor,
|
||||
* A {@link Base64.OutputStream} will write data to another
|
||||
* <tt>java.io.OutputStream</tt>, given in the constructor,
|
||||
* and encode/decode to/from Base64 notation on the fly.
|
||||
*
|
||||
* @see Base64
|
||||
* @see java.io.FilterOutputStream
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class OutputStream extends java.io.FilterOutputStream
|
||||
{
|
||||
private int options;
|
||||
private boolean encode;
|
||||
private int position;
|
||||
private byte[] buffer;
|
||||
|
@ -1130,9 +1239,9 @@ public class Base64
|
|||
private boolean suspendEncoding;
|
||||
|
||||
/**
|
||||
* Constructs a {@link Base64#OutputStream} in ENCODE mode.
|
||||
* Constructs a {@link Base64.OutputStream} in ENCODE mode.
|
||||
*
|
||||
* @param out the {@link java.io.OutputStream} to which data will be written.
|
||||
* @param out the <tt>java.io.OutputStream</tt> to which data will be written.
|
||||
* @since 1.3
|
||||
*/
|
||||
public OutputStream( java.io.OutputStream out )
|
||||
|
@ -1142,7 +1251,7 @@ public class Base64
|
|||
|
||||
|
||||
/**
|
||||
* Constructs a {@link Base64#OutputStream} in
|
||||
* Constructs a {@link Base64.OutputStream} in
|
||||
* either ENCODE or DECODE mode.
|
||||
* <p>
|
||||
* Valid options:<pre>
|
||||
|
@ -1154,7 +1263,7 @@ public class Base64
|
|||
* <p>
|
||||
* Example: <code>new Base64.OutputStream( out, Base64.ENCODE )</code>
|
||||
*
|
||||
* @param out the {@link java.io.OutputStream} to which data will be written.
|
||||
* @param out the <tt>java.io.OutputStream</tt> to which data will be written.
|
||||
* @param options Specified options.
|
||||
* @see Base64#ENCODE
|
||||
* @see Base64#DECODE
|
||||
|
@ -1164,7 +1273,6 @@ public class Base64
|
|||
public OutputStream( java.io.OutputStream out, int options )
|
||||
{
|
||||
super( out );
|
||||
this.options = options;
|
||||
this.breakLines = (options & DONT_BREAK_LINES) != DONT_BREAK_LINES;
|
||||
this.encode = (options & ENCODE) == ENCODE;
|
||||
this.bufferLength = encode ? 3 : 4;
|
||||
|
@ -1241,7 +1349,7 @@ public class Base64
|
|||
|
||||
|
||||
/**
|
||||
* Calls {@link #write} repeatedly until <var>len</var>
|
||||
* Calls {@link #write(int)} repeatedly until <var>len</var>
|
||||
* bytes are written.
|
||||
*
|
||||
* @param theBytes array from which to read bytes
|
||||
|
|
|
@ -73,6 +73,8 @@ public class LifeBlogger extends Thinlet
|
|||
private static final String JDBC_PREFIX = "jdbc:sqlite:/";
|
||||
private static final String DATABASE = "\\DataBase\\NokiaLifeblogDataBase.db";
|
||||
private static final String DEFAULT_ACTION = "mw";
|
||||
private static final String MIME_JPG = "image/jpeg";
|
||||
private static final String MIME_3GP = "video/3gpp";
|
||||
private final Properties _prefs = new Properties();
|
||||
private File _homeDir = new File(System.getProperty("user.home") + "\\My Documents\\NokiaLifeblogData");
|
||||
private String _action;
|
||||
|
@ -245,6 +247,10 @@ public class LifeBlogger extends Thinlet
|
|||
boolean first = true;
|
||||
int found = 0;
|
||||
|
||||
String[] info;
|
||||
String oid;
|
||||
String icon;
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
ts = rs.getString("TimeStamp");
|
||||
|
@ -255,20 +261,22 @@ public class LifeBlogger extends Thinlet
|
|||
cell = Thinlet.create("cell");
|
||||
thinlet.setString(cell, "text", name);
|
||||
|
||||
if (name.toLowerCase().endsWith("jpg"))
|
||||
oid = rs.getString("HooverObjectID");
|
||||
info = fileInfo(oid);
|
||||
icon = "/icon/text.gif";
|
||||
|
||||
if (MIME_JPG.equals(info[2]))
|
||||
{
|
||||
thinlet.setIcon(cell, "icon", getIcon("/icon/image.gif"));
|
||||
icon = "/icon/image.gif";
|
||||
}
|
||||
else if (name.toLowerCase().endsWith("3gp"))
|
||||
else if (MIME_3GP.equals(info[2]))
|
||||
{
|
||||
thinlet.setIcon(cell, "icon", getIcon("/icon/movie.gif"));
|
||||
}
|
||||
else
|
||||
{
|
||||
thinlet.setIcon(cell, "icon", getIcon("/icon/text.gif"));
|
||||
icon = "/icon/movie.gif";
|
||||
}
|
||||
|
||||
thinlet.putProperty(cell, "oid", rs.getString("HooverObjectID"));
|
||||
thinlet.setIcon(cell, "icon", getIcon(icon));
|
||||
|
||||
thinlet.putProperty(cell, "oid", oid);
|
||||
thinlet.add(row, cell);
|
||||
|
||||
cell = Thinlet.create("cell");
|
||||
|
@ -530,53 +538,50 @@ public class LifeBlogger extends Thinlet
|
|||
|
||||
final String[] info = fileInfo(oid);
|
||||
|
||||
if (info[0].length() > 0)
|
||||
if ((info[1] != null) && MIME_JPG.equals(info[2]))
|
||||
{
|
||||
if ((info[2].length() > 0) && info[2].endsWith("jpeg"))
|
||||
// Retrieve the jpg image
|
||||
final BufferedImage in = ImageIO.read(new File(info[1]));
|
||||
|
||||
final int maxDim = 200;
|
||||
|
||||
final int height = in.getHeight();
|
||||
final int width = in.getWidth();
|
||||
|
||||
// Determine the scale.
|
||||
double scale = (double) maxDim / (double) height;
|
||||
|
||||
if (in.getWidth() > in.getHeight())
|
||||
{
|
||||
// Retrieve the jpg image
|
||||
final BufferedImage in = ImageIO.read(new File(info[1]));
|
||||
|
||||
final int maxDim = 200;
|
||||
|
||||
final int height = in.getHeight();
|
||||
final int width = in.getWidth();
|
||||
|
||||
// Determine the scale.
|
||||
double scale = (double) maxDim / (double) height;
|
||||
|
||||
if (in.getWidth() > in.getHeight())
|
||||
{
|
||||
scale = (double) maxDim / (double) width;
|
||||
}
|
||||
|
||||
int scaledW = (int) (scale * (double) width);
|
||||
int scaledH = (int) (scale * (double) height);
|
||||
|
||||
// Set the scale.
|
||||
final AffineTransform tx = new AffineTransform();
|
||||
|
||||
if (scale <= 1.0d)
|
||||
{
|
||||
tx.scale(scale, scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
scaledW = width;
|
||||
scaledH = height;
|
||||
}
|
||||
|
||||
final BufferedImage out = new BufferedImage(scaledW, scaledH, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
final Graphics2D g2d = out.createGraphics();
|
||||
g2d.drawImage(in, tx, null);
|
||||
g2d.dispose();
|
||||
|
||||
final Object preview = parse("preview.xml");
|
||||
setString(preview, "text", info[0]);
|
||||
setIcon(find(preview, "image"), "icon", out);
|
||||
add(preview);
|
||||
scale = (double) maxDim / (double) width;
|
||||
}
|
||||
|
||||
int scaledW = (int) (scale * (double) width);
|
||||
int scaledH = (int) (scale * (double) height);
|
||||
|
||||
// Set the scale.
|
||||
final AffineTransform tx = new AffineTransform();
|
||||
|
||||
if (scale <= 1.0d)
|
||||
{
|
||||
tx.scale(scale, scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
scaledW = width;
|
||||
scaledH = height;
|
||||
}
|
||||
|
||||
final BufferedImage out = new BufferedImage(scaledW, scaledH, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
final Graphics2D g2d = out.createGraphics();
|
||||
g2d.drawImage(in, tx, null);
|
||||
g2d.dispose();
|
||||
|
||||
final Object preview = parse("preview.xml");
|
||||
setString(preview, "text", info[0]);
|
||||
setIcon(find(preview, "image"), "icon", out);
|
||||
add(preview);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -658,61 +663,6 @@ public class LifeBlogger extends Thinlet
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preforms the post/publish to blog action.
|
||||
*
|
||||
* @param dialog The post dialog,
|
||||
* @param blogPanel The panel contaning the post data.
|
||||
* @param publish Set to <code>true</code> to publish the post, <code>false</code> otherwise.
|
||||
*
|
||||
* @throws IOException If an error occurs while performing the action.
|
||||
*/
|
||||
private void post(Object dialog, Object blogPanel, boolean publish)
|
||||
throws IOException
|
||||
{
|
||||
final String host = getString(find(blogPanel, "host"), "text");
|
||||
final String blogID = getString(find(blogPanel, "blogid"), "text");
|
||||
final String login = getString(find(blogPanel, "login"), "text");
|
||||
final String password = getString(find(blogPanel, "password"), "text");
|
||||
final String entry = getString(find(blogPanel, "entry"), "text");
|
||||
|
||||
if (host.length() <= 0)
|
||||
{
|
||||
alert("Please specify a XML-RPC URL.");
|
||||
}
|
||||
else if (login.length() <= 0)
|
||||
{
|
||||
alert("Please specify a login name.");
|
||||
}
|
||||
else if (password.length() <= 0)
|
||||
{
|
||||
alert("Please specify a password.");
|
||||
}
|
||||
else if (entry.length() <= 0)
|
||||
{
|
||||
alert("Please specify a post entry.");
|
||||
}
|
||||
else if (blogID.length() <= 0)
|
||||
{
|
||||
alert("Please specify a blog ID.");
|
||||
}
|
||||
else
|
||||
{
|
||||
_prefs.put("blog-host", host);
|
||||
_prefs.put("blog-login", login);
|
||||
_prefs.put("blog-password", Base64.encodeBytes(password.getBytes(), Base64.DONT_BREAK_LINES));
|
||||
_prefs.put("blog-id", blogID);
|
||||
|
||||
savePrefs();
|
||||
|
||||
closeDialog(dialog);
|
||||
|
||||
final LifePost post =
|
||||
new LifePost(this, host, blogID, login, password, getString(find(blogPanel, "entry"), "text"), publish);
|
||||
post.start();
|
||||
}
|
||||
}
|
||||
|
||||
// Displays an alert.
|
||||
private void alert(String message)
|
||||
{
|
||||
|
@ -819,6 +769,61 @@ public class LifeBlogger extends Thinlet
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preforms the post/publish to blog action.
|
||||
*
|
||||
* @param dialog The post dialog,
|
||||
* @param blogPanel The panel contaning the post data.
|
||||
* @param publish Set to <code>true</code> to publish the post, <code>false</code> otherwise.
|
||||
*
|
||||
* @throws IOException If an error occurs while performing the action.
|
||||
*/
|
||||
private void post(Object dialog, Object blogPanel, boolean publish)
|
||||
throws IOException
|
||||
{
|
||||
final String host = getString(find(blogPanel, "host"), "text");
|
||||
final String blogID = getString(find(blogPanel, "blogid"), "text");
|
||||
final String login = getString(find(blogPanel, "login"), "text");
|
||||
final String password = getString(find(blogPanel, "password"), "text");
|
||||
final String entry = getString(find(blogPanel, "entry"), "text");
|
||||
|
||||
if (host.length() <= 0)
|
||||
{
|
||||
alert("Please specify a XML-RPC URL.");
|
||||
}
|
||||
else if (login.length() <= 0)
|
||||
{
|
||||
alert("Please specify a login name.");
|
||||
}
|
||||
else if (password.length() <= 0)
|
||||
{
|
||||
alert("Please specify a password.");
|
||||
}
|
||||
else if (entry.length() <= 0)
|
||||
{
|
||||
alert("Please specify a post entry.");
|
||||
}
|
||||
else if (blogID.length() <= 0)
|
||||
{
|
||||
alert("Please specify a blog ID.");
|
||||
}
|
||||
else
|
||||
{
|
||||
_prefs.put("blog-host", host);
|
||||
_prefs.put("blog-login", login);
|
||||
_prefs.put("blog-password", Base64.encodeBytes(password.getBytes(), Base64.DONT_BREAK_LINES));
|
||||
_prefs.put("blog-id", blogID);
|
||||
|
||||
savePrefs();
|
||||
|
||||
closeDialog(dialog);
|
||||
|
||||
final LifePost post =
|
||||
new LifePost(this, host, blogID, login, password, getString(find(blogPanel, "entry"), "text"), publish);
|
||||
post.start();
|
||||
}
|
||||
}
|
||||
|
||||
// Saves the properties.
|
||||
private void savePrefs()
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Created by JReleaseInfo AntTask from Open Source Competence Group */
|
||||
/* Creation date Thu Aug 26 13:35:50 PDT 2004 */
|
||||
/* Creation date Wed Sep 29 05:39:16 PDT 2004 */
|
||||
package net.thauvin.lifeblogger;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -12,28 +12,28 @@ import java.util.Date;
|
|||
public class ReleaseInfo {
|
||||
|
||||
|
||||
/** buildDate (set during build process to 1093552550453L). */
|
||||
private static Date buildDate = new Date(1093552550453L);
|
||||
/** buildDate (set during build process to 1096461556906L). */
|
||||
private static Date buildDate = new Date(1096461556906L);
|
||||
|
||||
/**
|
||||
* Get buildDate (set during build process to Thu Aug 26 13:35:50 PDT 2004).
|
||||
* Get buildDate (set during build process to Wed Sep 29 05:39:16 PDT 2004).
|
||||
* @return Date buildDate
|
||||
*/
|
||||
public static final Date getBuildDate() { return buildDate; }
|
||||
|
||||
|
||||
/**
|
||||
* Get buildNumber (set during build process to 118).
|
||||
* Get buildNumber (set during build process to 1).
|
||||
* @return int buildNumber
|
||||
*/
|
||||
public static final int getBuildNumber() { return 118; }
|
||||
public static final int getBuildNumber() { return 1; }
|
||||
|
||||
|
||||
/** version (set during build process to "0.1.0"). */
|
||||
private static String version = new String("0.1.0");
|
||||
/** version (set during build process to "0.1.1"). */
|
||||
private static String version = new String("0.1.1");
|
||||
|
||||
/**
|
||||
* Get version (set during build process to "0.1.0").
|
||||
* Get version (set during build process to "0.1.1").
|
||||
* @return String version
|
||||
*/
|
||||
public static final String getVersion() { return version; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue