本文整理匯總了Java中org.apache.commons.net.ftp.FTPFile.setType方法的典型用法代碼示例。如果您正苦於以下問題:Java FTPFile.setType方法的具體用法?Java FTPFile.setType怎麽用?Java FTPFile.setType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.net.ftp.FTPFile
的用法示例。
在下文中一共展示了FTPFile.setType方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseMemberList
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Parse entries within a partitioned dataset.
*
* Format of a memberlist within a PDS: 1 2 3 4 5 6 7 8 9 Name VV.MM Created
* Changed Size Init Mod Id TBSHELF 01.03 2002/09/12 2002/10/11 09:37 11 11
* 0 KIL001 TBTOOL 01.12 2002/09/12 2004/11/26 19:54 51 28 0 KIL001
*
* ------------------------------------------- [1] Name [2] VV.MM: Version .
* modification [3] Created: yyyy / MM / dd [4,5] Changed: yyyy / MM / dd
* HH:mm [6] Size: number of lines [7] Init: number of lines when first
* created [8] Mod: number of modified lines a last save [9] Id: User id for
* last update
*
*
* @param file
* will be updated with Name, Type and Timestamp if parsed.
* @param entry zosDirectoryEntry
* @return true: entry was parsed, false: entry was not parsed.
*/
private boolean parseMemberList(FTPFile file, String entry) {
if (matches(entry)) {
file.setRawListing(entry);
String name = group(1);
String datestr = group(2) + " " + group(3);
file.setName(name);
file.setType(FTPFile.FILE_TYPE);
try {
file.setTimestamp(super.parseTimestamp(datestr));
} catch (ParseException e) {
e.printStackTrace();
// just ignore parsing errors.
// TODO check this is ok
return false; // this is a parsing failure too.
}
return true;
}
return false;
}
示例2: parseSimpleEntry
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Assigns the name to the first word of the entry. Only to be used from a
* safe context, for example from a memberlist, where the regex for some
* reason fails. Then just assign the name field of FTPFile.
*
* @param file
* @param entry
* @return true if the entry string is non-null and non-empty
*/
private boolean parseSimpleEntry(FTPFile file, String entry) {
if (entry != null && entry.trim().length() > 0) {
file.setRawListing(entry);
String name = entry.split(" ")[0];
file.setName(name);
file.setType(FTPFile.FILE_TYPE);
return true;
}
return false;
}
示例3: setUp
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
@Before
public void setUp() {
format = new MainframeDatasetInputFormat<SqoopRecord>();
mockFTPClient = mock(FTPClient.class);
MainframeFTPClientUtils.setMockFTPClient(mockFTPClient);
try {
when(mockFTPClient.login("user", "pssword")).thenReturn(true);
when(mockFTPClient.logout()).thenReturn(true);
when(mockFTPClient.isConnected()).thenReturn(true);
when(mockFTPClient.completePendingCommand()).thenReturn(true);
when(mockFTPClient.changeWorkingDirectory(anyString())).thenReturn(true);
when(mockFTPClient.getReplyCode()).thenReturn(200);
when(mockFTPClient.getReplyString()).thenReturn("");
when(mockFTPClient.noop()).thenReturn(200);
when(mockFTPClient.setFileType(anyInt())).thenReturn(true);
FTPFile ftpFile1 = new FTPFile();
ftpFile1.setType(FTPFile.FILE_TYPE);
ftpFile1.setName("test1");
FTPFile ftpFile2 = new FTPFile();
ftpFile2.setType(FTPFile.FILE_TYPE);
ftpFile2.setName("test2");
FTPFile[] ftpFiles = { ftpFile1, ftpFile2 };
when(mockFTPClient.listFiles()).thenReturn(ftpFiles);
} catch (IOException e) {
fail("No IOException should be thrown!");
}
}
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:29,代碼來源:TestMainframeDatasetInputFormat.java
示例4: parseSimpleEntry
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Assigns the name to the first word of the entry. Only to be used from a
* safe context, for example from a memberlist, where the regex for some
* reason fails. Then just assign the name field of FTPFile.
*
* @param file
* @param entry
* @return
*/
private boolean parseSimpleEntry(FTPFile file, String entry) {
if (entry != null && entry.trim().length() > 0) {
file.setRawListing(entry);
String name = entry.split(" ")[0];
file.setName(name);
file.setType(FTPFile.FILE_TYPE);
return true;
}
return false;
}
示例5: parseFileList
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Parse entries representing a dataset list. Only datasets with DSORG PS or
* PO or PO-E and with RECFM F* or V* will be parsed.
*
* Format of ZOS/MVS file list: 1 2 3 4 5 6 7 8 9 10 Volume Unit Referred
* Ext Used Recfm Lrecl BlkSz Dsorg Dsname B10142 3390 2006/03/20 2 31 F 80
* 80 PS MDI.OKL.WORK ARCIVE Not Direct Access Device
* KJ.IOP998.ERROR.PL.UNITTEST B1N231 3390 2006/03/20 1 15 VB 256 27998 PO
* PLU B1N231 3390 2006/03/20 1 15 VB 256 27998 PO-E PLB
*
* ----------------------------------- Group within Regex [1] Volume [2]
* Unit [3] Referred [4] Ext: number of extents [5] Used [6] Recfm: Record
* format [7] Lrecl: Logical record length [8] BlkSz: Block size [9] Dsorg:
* Dataset organisation. Many exists but only support: PS, PO, PO-E [10]
* Dsname: Dataset name
*
* Note: When volume is ARCIVE, it means the dataset is stored somewhere in
* a tape archive. These entries is currently not supported by this parser.
* A null value is returned.
*
* @param file
* will be updated with Name, Type, Timestamp if parsed.
* @param entry zosDirectoryEntry
* @return true: entry was parsed, false: entry was not parsed.
*/
private boolean parseFileList(FTPFile file, String entry) {
if (matches(entry)) {
file.setRawListing(entry);
String name = group(2);
String dsorg = group(1);
file.setName(name);
// DSORG
if ("PS".equals(dsorg)) {
file.setType(FTPFile.FILE_TYPE);
}
else if ("PO".equals(dsorg) || "PO-E".equals(dsorg)) {
// regex already ruled out anything other than PO or PO-E
file.setType(FTPFile.DIRECTORY_TYPE);
}
else {
return false;
}
return true;
}
return false;
}
示例6: parseFTPEntry
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Parses a line of an OS2 FTP server file listing and converts it into a
* usable format in the form of an <code> FTPFile </code> instance. If the
* file listing line doesn't describe a file, <code> null </code> is
* returned, otherwise a <code> FTPFile </code> instance representing the
* files in the directory is returned.
* <p>
* @param entry A line of text from the file listing
* @return An FTPFile instance corresponding to the supplied entry
*/
// @Override
public FTPFile parseFTPEntry(String entry)
{
FTPFile f = new FTPFile();
if (matches(entry))
{
String size = group(1);
String attrib = group(2);
String dirString = group(3);
String datestr = group(4)+" "+group(5);
String name = group(6);
try
{
f.setTimestamp(super.parseTimestamp(datestr));
}
catch (ParseException e)
{
// intentionally do nothing
}
//is it a DIR or a file
if (dirString.trim().equals("DIR") || attrib.trim().equals("DIR"))
{
f.setType(FTPFile.DIRECTORY_TYPE);
}
else
{
f.setType(FTPFile.FILE_TYPE);
}
//set the name
f.setName(name.trim());
//set the size
f.setSize(Long.parseLong(size.trim()));
return (f);
}
return null;
}
示例7: parseFTPEntry
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Parses a line of an NetwareFTP server file listing and converts it into a
* usable format in the form of an <code> FTPFile </code> instance. If the
* file listing line doesn't describe a file, <code> null </code> is
* returned, otherwise a <code> FTPFile </code> instance representing the
* files in the directory is returned.
* <p>
* <p>
* Netware file permissions are in the following format: RWCEAFMS, and are explained as follows:
* <ul>
* <li><b>S</b> - Supervisor; All rights.
* <li><b>R</b> - Read; Right to open and read or execute.
* <li><b>W</b> - Write; Right to open and modify.
* <li><b>C</b> - Create; Right to create; when assigned to a file, allows a deleted file to be recovered.
* <li><b>E</b> - Erase; Right to delete.
* <li><b>M</b> - Modify; Right to rename a file and to change attributes.
* <li><b>F</b> - File Scan; Right to see directory or file listings.
* <li><b>A</b> - Access Control; Right to modify trustee assignments and the Inherited Rights Mask.
* </ul>
*
* See <a href="http://www.novell.com/documentation/nfap10/index.html?page=/documentation/nfap10/nfaubook/data/abxraws.html">here</a>
* for more details
*
* @param entry A line of text from the file listing
* @return An FTPFile instance corresponding to the supplied entry
*/
// @Override
public FTPFile parseFTPEntry(String entry) {
FTPFile f = new FTPFile();
if (matches(entry)) {
String dirString = group(1);
String attrib = group(2);
String user = group(3);
String size = group(4);
String datestr = group(5);
String name = group(9);
try {
f.setTimestamp(super.parseTimestamp(datestr));
} catch (ParseException e) {
// intentionally do nothing
}
//is it a DIR or a file
if (dirString.trim().equals("d")) {
f.setType(FTPFile.DIRECTORY_TYPE);
} else // Should be "-"
{
f.setType(FTPFile.FILE_TYPE);
}
f.setUser(user);
//set the name
f.setName(name.trim());
//set the size
f.setSize(Long.parseLong(size.trim()));
// Now set the permissions (or at least a subset thereof - full permissions would probably require
// subclassing FTPFile and adding extra metainformation there)
if (attrib.indexOf("R") != -1) {
f.setPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION,
true);
}
if (attrib.indexOf("W") != -1) {
f.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
true);
}
return (f);
}
return null;
}
示例8: parseFTPEntry
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Parses a line of an NT FTP server file listing and converts it into a
* usable format in the form of an <code> FTPFile </code> instance. If the
* file listing line doesn't describe a file, <code> null </code> is
* returned, otherwise a <code> FTPFile </code> instance representing the
* files in the directory is returned.
* <p>
* @param entry A line of text from the file listing
* @return An FTPFile instance corresponding to the supplied entry
*/
// @Override
public FTPFile parseFTPEntry(String entry)
{
FTPFile f = new FTPFile();
f.setRawListing(entry);
if (matches(entry))
{
String datestr = group(1)+" "+group(2);
String dirString = group(3);
String size = group(4);
String name = group(5);
try
{
f.setTimestamp(super.parseTimestamp(datestr));
}
catch (ParseException e)
{
// parsing fails, try the other date format
try
{
f.setTimestamp(timestampParser.parseTimestamp(datestr));
}
catch (ParseException e2)
{
// intentionally do nothing
}
}
if (null == name || name.equals(".") || name.equals(".."))
{
return (null);
}
f.setName(name);
if ("<DIR>".equals(dirString))
{
f.setType(FTPFile.DIRECTORY_TYPE);
f.setSize(0);
}
else
{
f.setType(FTPFile.FILE_TYPE);
if (null != size)
{
f.setSize(Long.parseLong(size));
}
}
return (f);
}
return null;
}
示例9: setUp
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
@Before
public void setUp() throws IOException {
mockFTPClient = mock(FTPClient.class);
MainframeFTPClientUtils.setMockFTPClient(mockFTPClient);
try {
when(mockFTPClient.login("user", "pssword")).thenReturn(true);
when(mockFTPClient.logout()).thenReturn(true);
when(mockFTPClient.isConnected()).thenReturn(true);
when(mockFTPClient.completePendingCommand()).thenReturn(true);
when(mockFTPClient.changeWorkingDirectory(anyString())).thenReturn(true);
when(mockFTPClient.getReplyCode()).thenReturn(200);
when(mockFTPClient.noop()).thenReturn(200);
when(mockFTPClient.setFileType(anyInt())).thenReturn(true);
FTPFile ftpFile1 = new FTPFile();
ftpFile1.setType(FTPFile.FILE_TYPE);
ftpFile1.setName("test1");
FTPFile ftpFile2 = new FTPFile();
ftpFile2.setType(FTPFile.FILE_TYPE);
ftpFile2.setName("test2");
FTPFile[] ftpFiles = { ftpFile1, ftpFile2 };
when(mockFTPClient.listFiles()).thenReturn(ftpFiles);
when(mockFTPClient.retrieveFileStream("test1")).thenReturn(
new ByteArrayInputStream("123\n456\n".getBytes()));
when(mockFTPClient.retrieveFileStream("test2")).thenReturn(
new ByteArrayInputStream("789\n".getBytes()));
when(mockFTPClient.retrieveFileStream("NotComplete")).thenReturn(
new ByteArrayInputStream("NotComplete\n".getBytes()));
} catch (IOException e) {
fail("No IOException should be thrown!");
}
JobConf conf = new JobConf();
conf.set(DBConfiguration.URL_PROPERTY, "localhost:" + "11111");
conf.set(DBConfiguration.USERNAME_PROPERTY, "user");
conf.set(DBConfiguration.PASSWORD_PROPERTY, "pssword");
// set the password in the secure credentials object
Text PASSWORD_SECRET_KEY = new Text(DBConfiguration.PASSWORD_PROPERTY);
conf.getCredentials().addSecretKey(PASSWORD_SECRET_KEY,
"pssword".getBytes());
conf.setClass(DBConfiguration.INPUT_CLASS_PROPERTY, DummySqoopRecord.class,
DBWritable.class);
Job job = new Job(conf);
mfDIS = new MainframeDatasetInputSplit();
mfDIS.addDataset("test1");
mfDIS.addDataset("test2");
context = mock(TaskAttemptContext.class);
when(context.getConfiguration()).thenReturn(job.getConfiguration());
mfDFTPRR = new MainframeDatasetFTPRecordReader();
}
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:53,代碼來源:TestMainframeDatasetFTPRecordReader.java
示例10: parseFTPEntry
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Parses a line of an OS2 FTP server file listing and converts it into a
* usable format in the form of an <code> FTPFile </code> instance. If the
* file listing line doesn't describe a file, <code> null </code> is
* returned, otherwise a <code> FTPFile </code> instance representing the
* files in the directory is returned.
* <p>
* @param entry A line of text from the file listing
* @return An FTPFile instance corresponding to the supplied entry
*/
public FTPFile parseFTPEntry(String entry)
{
FTPFile f = new FTPFile();
if (matches(entry))
{
String size = group(1);
String attrib = group(2);
String dirString = group(3);
String datestr = group(4)+" "+group(5);
String name = group(6);
try
{
f.setTimestamp(super.parseTimestamp(datestr));
}
catch (ParseException e)
{
// intentionally do nothing
}
//is it a DIR or a file
if (dirString.trim().equals("DIR") || attrib.trim().equals("DIR"))
{
f.setType(FTPFile.DIRECTORY_TYPE);
}
else
{
f.setType(FTPFile.FILE_TYPE);
}
//set the name
f.setName(name.trim());
//set the size
f.setSize(Long.parseLong(size.trim()));
return (f);
}
return null;
}
示例11: parseFTPEntry
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Parses a line of an NetwareFTP server file listing and converts it into a
* usable format in the form of an <code> FTPFile </code> instance. If the
* file listing line doesn't describe a file, <code> null </code> is
* returned, otherwise a <code> FTPFile </code> instance representing the
* files in the directory is returned.
* <p>
* <p>
* Netware file permissions are in the following format: RWCEAFMS, and are explained as follows:
* <ul>
* <li><b>S</b> - Supervisor; All rights.
* <li><b>R</b> - Read; Right to open and read or execute.
* <li><b>W</b> - Write; Right to open and modify.
* <li><b>C</b> - Create; Right to create; when assigned to a file, allows a deleted file to be recovered.
* <li><b>E</b> - Erase; Right to delete.
* <li><b>M</b> - Modify; Right to rename a file and to change attributes.
* <li><b>F</b> - File Scan; Right to see directory or file listings.
* <li><b>A</b> - Access Control; Right to modify trustee assignments and the Inherited Rights Mask.
* </ul>
*
* See <a href="http://www.novell.com/documentation/nfap10/index.html?page=/documentation/nfap10/nfaubook/data/abxraws.html">here</a>
* for more details
*
* @param entry A line of text from the file listing
* @return An FTPFile instance corresponding to the supplied entry
*/
public FTPFile parseFTPEntry(String entry) {
FTPFile f = new FTPFile();
if (matches(entry)) {
String dirString = group(1);
String attrib = group(2);
String user = group(3);
String size = group(4);
String datestr = group(5);
String name = group(9);
try {
f.setTimestamp(super.parseTimestamp(datestr));
} catch (ParseException e) {
// intentionally do nothing
}
//is it a DIR or a file
if (dirString.trim().equals("d")) {
f.setType(FTPFile.DIRECTORY_TYPE);
} else // Should be "-"
{
f.setType(FTPFile.FILE_TYPE);
}
f.setUser(user);
//set the name
f.setName(name.trim());
//set the size
f.setSize(Long.parseLong(size.trim()));
// Now set the permissions (or at least a subset thereof - full permissions would probably require
// subclassing FTPFile and adding extra metainformation there)
if (attrib.indexOf("R") != -1) {
f.setPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION,
true);
}
if (attrib.indexOf("W") != -1) {
f.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
true);
}
return (f);
}
return null;
}
示例12: parseFTPEntry
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Parses a line of an NT FTP server file listing and converts it into a
* usable format in the form of an <code> FTPFile </code> instance. If the
* file listing line doesn't describe a file, <code> null </code> is
* returned, otherwise a <code> FTPFile </code> instance representing the
* files in the directory is returned.
* <p>
* @param entry A line of text from the file listing
* @return An FTPFile instance corresponding to the supplied entry
*/
public FTPFile parseFTPEntry(String entry)
{
FTPFile f = new FTPFile();
f.setRawListing(entry);
if (matches(entry))
{
String datestr = group(1)+" "+group(2);
String dirString = group(3);
String size = group(4);
String name = group(5);
try
{
f.setTimestamp(super.parseTimestamp(datestr));
}
catch (ParseException e)
{
// parsing fails, try the other date format
try
{
f.setTimestamp(timestampParser.parseTimestamp(datestr));
}
catch (ParseException e2)
{
// intentionally do nothing
}
}
if (null == name || name.equals(".") || name.equals(".."))
{
return (null);
}
f.setName(name);
if ("<DIR>".equals(dirString))
{
f.setType(FTPFile.DIRECTORY_TYPE);
f.setSize(0);
}
else
{
f.setType(FTPFile.FILE_TYPE);
if (null != size)
{
f.setSize(Long.parseLong(size));
}
}
return (f);
}
return null;
}
示例13: parseJeslevel1List
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Matches these entries, note: no header: [1] [2] [3] [4] [5] IBMUSER1
* JOB01906 OUTPUT 3 Spool Files
* 012345678901234567890123456789012345678901234 1 2 3 4
* ------------------------------------------- Group in regex [1] Job name
* [2] Job number [3] Job status (INPUT,ACTIVE,OUTPUT) [4] Number of sysout
* files [5] The string "Spool Files"
*
*
* @param file
* will be updated with Name, Type and Timestamp if parsed.
* @param entry zosDirectoryEntry
* @return true: entry was parsed, false: entry was not parsed.
*/
private boolean parseJeslevel1List(FTPFile file, String entry) {
if (matches(entry)) {
if (group(3).equalsIgnoreCase("OUTPUT")) {
file.setRawListing(entry);
String name = group(2); /* Job Number, used by GET */
file.setName(name);
file.setType(FTPFile.FILE_TYPE);
return true;
}
}
return false;
}
示例14: parseJeslevel2List
import org.apache.commons.net.ftp.FTPFile; //導入方法依賴的package包/類
/**
* Matches these entries, note: no header: [1] [2] [3] [4] [5] JOBNAME JOBID
* OWNER STATUS CLASS IBMUSER1 JOB01906 IBMUSER OUTPUT A RC=0000 3 spool
* files IBMUSER TSU01830 IBMUSER OUTPUT TSU ABEND=522 3 spool files
* 012345678901234567890123456789012345678901234 1 2 3 4
* ------------------------------------------- Group in regex [1] Job name
* [2] Job number [3] Owner [4] Job status (INPUT,ACTIVE,OUTPUT) [5] Job
* Class [6] The rest
*
*
* @param file
* will be updated with Name, Type and Timestamp if parsed.
* @param entry zosDirectoryEntry
* @return true: entry was parsed, false: entry was not parsed.
*/
private boolean parseJeslevel2List(FTPFile file, String entry) {
if (matches(entry)) {
if (group(4).equalsIgnoreCase("OUTPUT")) {
file.setRawListing(entry);
String name = group(2); /* Job Number, used by GET */
file.setName(name);
file.setType(FTPFile.FILE_TYPE);
return true;
}
}
return false;
}