de.frame4j
Class UCopy

java.lang.Object
  extended by de.frame4j.util.App
      extended by de.frame4j.UCopy
All Implemented Interfaces:
AttrSettable, TextHelper.MessageComponents, UIInfo, ActionListener, EventListener, DynamicMBean

@MinDoc(copyright="Copyright 1997 - 2003, 2005, 2009  A. Weinert",
        author="Albrecht Weinert",
        version="V.55",
        lastModified="28.07.2010",
        lastModifiedBy="A. Weinert",
        usage="start as Java application (-? for help)",
        purpose="copy file or URL to file")
public class UCopy
extends App

Copy from file or URL to file.

This application copies from a file or an URL to an output file or to normal output. The source specification is understood as URL (e.g. "http://www.xyz.de/applets/t.class") and as file (e.g. "D:/uhu/tmp/edwin/t.class"), treating both (comfortably) as equal (at command line / script level). File specifications will be used with the "correct" file separator (see ComVar.FS).

If the destination is a directory the source's filename will be used.

This tool fetches files from Internet, the download of which by "save link as" most browsers deny or not even offer, like e.g. the .class or .jar of Applets.
To get files from the net an authentication (name, password) may be provided as well as proxy settings. Like with all Frame4J's (App inheritors) applications this may be done by command line or — with more comfort — by providing an extra .properties file.

On copying to a destination file the source's last modification date will be transfered (when possible) as the date of the copying usually being irrelevant.

The copying process is binary by default (byte by byte; one to one).
If different encodings are specified for source and destination two transformations to and from Unicode are inserted. The same applies if text transformations are ordered. In these cases only, source and destination file may be the same. This is ordered by just omitting the destination parameter.

Use cases for changing the the file encoding in situ are compilers that insist in just one source file encoding no matter which the platform and all other tools use and the platform independent deployment of text files in archives (like .properties in .jar).

The example of changing of a file's text encoding shows that the copy process by this tool is a good place for any sort of text manipulation. Those may be implemented by extending this class and just overriding the method manipContent(String) that will be intervened between reading and writing if textManip is not empty. If it is "eclipseDictionary" this class's implementation of manipContent(String) will

That's just what's needed to bring a text containing correctly spelled word forms to the most simple form of a .dic file (dictionary) usable for Eclipse.


Hint: To this application UCopy belongs (as integral part) a .properties file named UCopy.properties. It's part of the documentation.
See also the hints in the package description.


© Copyright 1997 - 2003, 2005, 2007   Albrecht Weinert


Field Summary
 String destination
          Name of destination file or directory.
 String inEncoding
          The input's (text) encoding.
 String name
          User name with password (name:passw).
 String outEncoding
          The output's (text) encoding.
 String proxyHost
          Name of the proxy server.
 String proxyPort
          Port of the proxy server..
 boolean proxySet
          Use a proxy server when reading from URLs.
 String source
          Name of source file or source URL.
 String textManip
          Denomination of a text manipulation to be done while copying.
 
Fields inherited from class de.frame4j.util.App
ano, appBase, appIO, appStartTime, args, bgColor, err, fullClassName, help, icon, INIT_ERROR, jmxRemoteNote, JOB_DONE_OK, log, LOG_OUT_ERROR, MAIN_THREAD_EXC, mainThread, myClass, myFrame, NO_PARS_ERROR, objectName, out, outMode, packName, prop, retCode, runFlag, shortClassName, title, verbose, verbosity
 
Fields inherited from interface de.frame4j.net.AttrSettable
ILLEGAL_TYPE, ILLEGAL_VALUE, NO_ATTRIBUTE, NO_KNOWN_ATTRIBUTE, NO_VALUE, OK
 
Constructor Summary
UCopy()
           
 
Method Summary
 int doIt()
          Working method of UCopy.
static void main(String[] args)
          Start method of UCopy.
protected  String manipContent(String content)
          Optional text manipulation method.
 
Methods inherited from class de.frame4j.util.App
actionPerformed, allowNoPropertiesFile, clientOrder, condHelpLog, connect, errMeld, errMeld, errorExit, errorExit, errorExit, errorText, formMessage, formMessage, getAbout, getAboutText, getActTime, getAppLogger, getAppStartTime, getArgs, getAttribute, getAttributes, getAuthor, getCopyright, getDbLogger, getExecTimeMs, getExecTimeString, getHelp, getHelpText, getIcon, getLanguage, getLogHandler, getMBeanInfo, getMessageComponent, getMessageComponentsLength, getMyFrame, getName, getNameWithVersDate, getOutMode, getProp, getPurpose, getStartTime, getStateString, getTitle, getUsage, getVerbosity, getVerbosityString, getVersDate, getXMLinput, go, go, go, haveIcon, invoke, isDebug, isHelp, isHelpLog, isNormal, isRunFlag, isSilent, isTest, isVerbose, logVerbose, logVerbose, makeDbLogger, makeMenuBar, makeMenuBar, makeStatusTextEnd, makeStatusTextStart, messageFormat, normalExit, parsePartial, performeAction, postDeregister, postRegister, preRegister, queueAction, registerAsMBean, setAboutText, setAttribute, setAttribute, setAttribute, setAttributes, setAuthor, setBgColor, setCodePages, setCopyright, setHelp, setJmxRemoteNote, setLogOut2, setName, setOutMode, setOutMode, setPurpose, setTitle, setUsage, setVerbose, setVerbose, setVerbosity, setVerbosity, setVerbosityString, setVersDate, stop, threeLineEndMsg, toString, twoLineEndMsg, twoLineStartMsg, valueLang, valueLang, wakeMainThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

source

public String source
Name of source file or source URL.


destination

public String destination
Name of destination file or directory.


textManip

public String textManip
Denomination of a text manipulation to be done while copying.

default: null = do nothing, except perhaps character coding changes
possible values: null, "eclipseDictionary", .. ..

See Also:
manipContent(String), inEncoding, outEncoding

proxySet

public boolean proxySet
Use a proxy server when reading from URLs.

If true a proxy will be used and properties proxyHost and proxyHost take effect.

Default: true


proxyHost

public String proxyHost
Name of the proxy server.

Default: cache

See Also:
proxySet

proxyPort

public String proxyPort
Port of the proxy server..

Default: 8080

See Also:
proxySet

name

public String name
User name with password (name:passw).

Default: no name.


inEncoding

public String inEncoding
The input's (text) encoding.

Default: no encoding / binary


outEncoding

public String outEncoding
The output's (text) encoding.

Default: no encoding / binary.

Constructor Detail

UCopy

public UCopy()
Method Detail

main

public static void main(String[] args)
Start method of UCopy.

Execution is: java UCopy [options] source [destination]

Parameters:
args - command line arguments
See Also:
doIt(), App.go(String[], boolean)

manipContent

protected String manipContent(String content)
Optional text manipulation method.

If the property textManip is not empty this method is called between reading and writing the text content. It may do any optional content manipulation.
This implementation will do the preparation of an (Eclipse) dictionary if textManip is "eclipseDictionary".

In that case this implementation will That is just what's needed to bring a text containing correctly spelled word forms to the most simple form of a .dic file (dictionary) usable for Eclipse.

For all other values of textManip this implementation will return the content unchanged.

Parameters:
content - the original text content, null will return the empty String, no matter what textManip says

doIt

public int doIt()
Working method of UCopy.

Specified by:
doIt in class App
See Also:
main(String[]), App.go(String[], boolean)