repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
sagiegurari/fax4j
src/main/java/org/fax4j/spi/adapter/AdapterFaxClientSpi.java
AdapterFaxClientSpi.validateCondition
protected boolean validateCondition(String key,String value) { boolean valid=false; FaxClientSpiConfigurationConstants condition=FaxClientSpiConfigurationConstants.getEnum(key); String propertyValue=null; switch(condition) { case PROPERTY_CONDITION: //get value propertyValue=this.getConfigurationValue(value); if(propertyValue!=null) { valid=true; } break; case OS_CONDITION: //get OS name String osName=System.getProperty("os.name"); //change values to lower case osName=osName.toLowerCase(); String updatedValue=value.toLowerCase(); if(osName.contains(updatedValue)) { valid=true; } break; case JAVA_CLASS_CONDITION: try { //load class ReflectionHelper.getType(value); valid=true; } catch(Throwable throwable) { //ignore } break; case NATIVE_LIB_CONDITION: try { //load library System.loadLibrary(value); valid=true; } catch(Throwable throwable) { //ignore } break; case EXECUTABLE_CONDITION: //get system path String systemPath=System.getProperty("java.library.path"); String[] systemPathElements=systemPath.split(System.getProperty("path.separator")); //get amount int amount=systemPathElements.length; String directoryPath=null; File file=null; for(int index=0;index<amount;index++) { //get next element directoryPath=systemPathElements[index]; //get file file=new File(directoryPath,value); if((file.exists())&&(file.isFile())) { valid=true; } } break; case STABLE_CONDITION: //get property key String propertyKey=FaxClientSpiConfigurationConstants.SPI_STABLE_PROPERTY_KEY_PREFIX+value+FaxClientSpiConfigurationConstants.SPI_STABLE_PROPERTY_KEY_SUFFIX; //get value propertyValue=this.getConfigurationValue(propertyKey); valid=Boolean.parseBoolean(propertyValue); break; default: throw new FaxException("Invalid condition key provided: "+key); } return valid; }
java
protected boolean validateCondition(String key,String value) { boolean valid=false; FaxClientSpiConfigurationConstants condition=FaxClientSpiConfigurationConstants.getEnum(key); String propertyValue=null; switch(condition) { case PROPERTY_CONDITION: //get value propertyValue=this.getConfigurationValue(value); if(propertyValue!=null) { valid=true; } break; case OS_CONDITION: //get OS name String osName=System.getProperty("os.name"); //change values to lower case osName=osName.toLowerCase(); String updatedValue=value.toLowerCase(); if(osName.contains(updatedValue)) { valid=true; } break; case JAVA_CLASS_CONDITION: try { //load class ReflectionHelper.getType(value); valid=true; } catch(Throwable throwable) { //ignore } break; case NATIVE_LIB_CONDITION: try { //load library System.loadLibrary(value); valid=true; } catch(Throwable throwable) { //ignore } break; case EXECUTABLE_CONDITION: //get system path String systemPath=System.getProperty("java.library.path"); String[] systemPathElements=systemPath.split(System.getProperty("path.separator")); //get amount int amount=systemPathElements.length; String directoryPath=null; File file=null; for(int index=0;index<amount;index++) { //get next element directoryPath=systemPathElements[index]; //get file file=new File(directoryPath,value); if((file.exists())&&(file.isFile())) { valid=true; } } break; case STABLE_CONDITION: //get property key String propertyKey=FaxClientSpiConfigurationConstants.SPI_STABLE_PROPERTY_KEY_PREFIX+value+FaxClientSpiConfigurationConstants.SPI_STABLE_PROPERTY_KEY_SUFFIX; //get value propertyValue=this.getConfigurationValue(propertyKey); valid=Boolean.parseBoolean(propertyValue); break; default: throw new FaxException("Invalid condition key provided: "+key); } return valid; }
[ "protected", "boolean", "validateCondition", "(", "String", "key", ",", "String", "value", ")", "{", "boolean", "valid", "=", "false", ";", "FaxClientSpiConfigurationConstants", "condition", "=", "FaxClientSpiConfigurationConstants", ".", "getEnum", "(", "key", ")", ...
Validates the SPI condition. @param key The condition key <br> property - checks a fax4j property is defined and contains a value<br> OS - checks OS name contains the value (case insensitive)<br> java-class - checks that java class can be loaded<br> native-lib - checks that native lib can be loaded<br> executable - checks executable is on system path<br> stable - checks for a fax4j property org.fax4j.spi.xxx.stable is defined and equals true, where xxx is the SPI key (for example: org.fax4j.spi.adapter.stable=true) @param value The condition value @return True if the condition is met
[ "Validates", "the", "SPI", "condition", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/adapter/AdapterFaxClientSpi.java#L359-L452
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/adapter/AdapterFaxClientSpi.java
AdapterFaxClientSpi.createFaxClientSpi
protected void createFaxClientSpi(String type) { //setup fax client SPI configuration Properties configuration=this.createFaxClientSpiConfiguration(); //create fax client SPI this.faxClientSpi=FaxClientSpiFactory.createChildFaxClientSpi(type,configuration); }
java
protected void createFaxClientSpi(String type) { //setup fax client SPI configuration Properties configuration=this.createFaxClientSpiConfiguration(); //create fax client SPI this.faxClientSpi=FaxClientSpiFactory.createChildFaxClientSpi(type,configuration); }
[ "protected", "void", "createFaxClientSpi", "(", "String", "type", ")", "{", "//setup fax client SPI configuration", "Properties", "configuration", "=", "this", ".", "createFaxClientSpiConfiguration", "(", ")", ";", "//create fax client SPI", "this", ".", "faxClientSpi", "...
This function creates a new fax client SPI based on the provided configuration. @param type The fax client type
[ "This", "function", "creates", "a", "new", "fax", "client", "SPI", "based", "on", "the", "provided", "configuration", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/adapter/AdapterFaxClientSpi.java#L460-L467
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/adapter/AdapterFaxClientSpi.java
AdapterFaxClientSpi.createFaxClientSpiConfiguration
protected Properties createFaxClientSpiConfiguration() { //get configuration Map<String,String> configuration=this.getConfiguration(); //create new configuration Properties internalSPIConfiguration=new Properties(); Properties overrideConfiguration=new Properties(); //go over current configuration Iterator<Entry<String,String>> iterator=configuration.entrySet().iterator(); Entry<String,String> entry=null; String key=null; String value=null; String overrideKey=null; String overridePrefix=FaxClientSpiConfigurationConstants.SPI_CONFIGURATION_OVERRIDE_PROPERTY_KEY_PREFIX.toString(); int prefixLength=overridePrefix.length(); while(iterator.hasNext()) { //get next entry entry=iterator.next(); //get key/value key=entry.getKey(); value=entry.getValue(); //override internal configuration if((key.startsWith(overridePrefix))) { if(key.length()!=prefixLength) { overrideKey=key.substring(prefixLength); //put in override configuration overrideConfiguration.setProperty(overrideKey,value); } } //put in new configuration internalSPIConfiguration.setProperty(key,value); } //override configuration internalSPIConfiguration.putAll(overrideConfiguration); return internalSPIConfiguration; }
java
protected Properties createFaxClientSpiConfiguration() { //get configuration Map<String,String> configuration=this.getConfiguration(); //create new configuration Properties internalSPIConfiguration=new Properties(); Properties overrideConfiguration=new Properties(); //go over current configuration Iterator<Entry<String,String>> iterator=configuration.entrySet().iterator(); Entry<String,String> entry=null; String key=null; String value=null; String overrideKey=null; String overridePrefix=FaxClientSpiConfigurationConstants.SPI_CONFIGURATION_OVERRIDE_PROPERTY_KEY_PREFIX.toString(); int prefixLength=overridePrefix.length(); while(iterator.hasNext()) { //get next entry entry=iterator.next(); //get key/value key=entry.getKey(); value=entry.getValue(); //override internal configuration if((key.startsWith(overridePrefix))) { if(key.length()!=prefixLength) { overrideKey=key.substring(prefixLength); //put in override configuration overrideConfiguration.setProperty(overrideKey,value); } } //put in new configuration internalSPIConfiguration.setProperty(key,value); } //override configuration internalSPIConfiguration.putAll(overrideConfiguration); return internalSPIConfiguration; }
[ "protected", "Properties", "createFaxClientSpiConfiguration", "(", ")", "{", "//get configuration", "Map", "<", "String", ",", "String", ">", "configuration", "=", "this", ".", "getConfiguration", "(", ")", ";", "//create new configuration", "Properties", "internalSPICo...
This function creates and returns the internal fax client SPI configuration. @return The internal fax client SPI configuration
[ "This", "function", "creates", "and", "returns", "the", "internal", "fax", "client", "SPI", "configuration", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/adapter/AdapterFaxClientSpi.java#L475-L521
train
hivemq/hivemq-spi
src/main/java/com/hivemq/spi/util/DefaultSslEngineUtil.java
DefaultSslEngineUtil.getSupportedCipherSuites
@ReadOnly public List<String> getSupportedCipherSuites() throws SslException { try { final SSLEngine engine = getDefaultSslEngine(); return ImmutableList.copyOf(engine.getSupportedCipherSuites()); } catch (NoSuchAlgorithmException | KeyManagementException e) { throw new SslException("Not able to get list of supported cipher suites from JVM", e); } }
java
@ReadOnly public List<String> getSupportedCipherSuites() throws SslException { try { final SSLEngine engine = getDefaultSslEngine(); return ImmutableList.copyOf(engine.getSupportedCipherSuites()); } catch (NoSuchAlgorithmException | KeyManagementException e) { throw new SslException("Not able to get list of supported cipher suites from JVM", e); } }
[ "@", "ReadOnly", "public", "List", "<", "String", ">", "getSupportedCipherSuites", "(", ")", "throws", "SslException", "{", "try", "{", "final", "SSLEngine", "engine", "=", "getDefaultSslEngine", "(", ")", ";", "return", "ImmutableList", ".", "copyOf", "(", "e...
Returns a list of all supported Cipher Suites of the JVM. @return a list of all supported cipher suites of the JVM @throws SslException
[ "Returns", "a", "list", "of", "all", "supported", "Cipher", "Suites", "of", "the", "JVM", "." ]
55fa89ccb081ad5b6d46eaca02179272148e64ed
https://github.com/hivemq/hivemq-spi/blob/55fa89ccb081ad5b6d46eaca02179272148e64ed/src/main/java/com/hivemq/spi/util/DefaultSslEngineUtil.java#L43-L54
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/email/MailConnectionFactoryImpl.java
MailConnectionFactoryImpl.createTransport
protected Transport createTransport(Session session) { Transport transport=null; try { //get the transport transport=session.getTransport(this.transportProtocol); //connect if(this.transportPort>0) { transport.connect(this.transportHost,this.transportPort,this.userName,this.password); } else { transport.connect(this.transportHost,this.userName,this.password); } } catch(Exception exception) { throw new FaxException("Error while connecting to mail host: "+this.transportHost,exception); } return transport; }
java
protected Transport createTransport(Session session) { Transport transport=null; try { //get the transport transport=session.getTransport(this.transportProtocol); //connect if(this.transportPort>0) { transport.connect(this.transportHost,this.transportPort,this.userName,this.password); } else { transport.connect(this.transportHost,this.userName,this.password); } } catch(Exception exception) { throw new FaxException("Error while connecting to mail host: "+this.transportHost,exception); } return transport; }
[ "protected", "Transport", "createTransport", "(", "Session", "session", ")", "{", "Transport", "transport", "=", "null", ";", "try", "{", "//get the transport", "transport", "=", "session", ".", "getTransport", "(", "this", ".", "transportProtocol", ")", ";", "/...
This function returns a transport for the provided session. @param session The mail session @return The mail transport
[ "This", "function", "returns", "a", "transport", "for", "the", "provided", "session", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/email/MailConnectionFactoryImpl.java#L59-L83
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.getFax4jInternalTemporaryDirectoryImpl
private static File getFax4jInternalTemporaryDirectoryImpl() { File temporaryFile=null; try { //create temporary file temporaryFile=File.createTempFile("temp_",".temp"); } catch(IOException exception) { throw new FaxException("Unable to create temporary file.",exception); } //get parent directory File temporaryDirectory=temporaryFile.getParentFile(); //delete file boolean deleted=temporaryFile.delete(); if(!deleted) { temporaryFile.deleteOnExit(); } //read properties Properties properties=LibraryConfigurationLoader.readInternalConfiguration(); //get values String name=properties.getProperty("org.fax4j.product.name"); String version=properties.getProperty("org.fax4j.product.version"); //create sub directory File fax4jTemporaryDirectory=new File(temporaryDirectory,name+"_"+version); if(!fax4jTemporaryDirectory.exists()) { boolean created=fax4jTemporaryDirectory.mkdirs(); if(!created) { throw new FaxException("Unable to create fax4j internal temporary directory: "+fax4jTemporaryDirectory); } } return fax4jTemporaryDirectory; }
java
private static File getFax4jInternalTemporaryDirectoryImpl() { File temporaryFile=null; try { //create temporary file temporaryFile=File.createTempFile("temp_",".temp"); } catch(IOException exception) { throw new FaxException("Unable to create temporary file.",exception); } //get parent directory File temporaryDirectory=temporaryFile.getParentFile(); //delete file boolean deleted=temporaryFile.delete(); if(!deleted) { temporaryFile.deleteOnExit(); } //read properties Properties properties=LibraryConfigurationLoader.readInternalConfiguration(); //get values String name=properties.getProperty("org.fax4j.product.name"); String version=properties.getProperty("org.fax4j.product.version"); //create sub directory File fax4jTemporaryDirectory=new File(temporaryDirectory,name+"_"+version); if(!fax4jTemporaryDirectory.exists()) { boolean created=fax4jTemporaryDirectory.mkdirs(); if(!created) { throw new FaxException("Unable to create fax4j internal temporary directory: "+fax4jTemporaryDirectory); } } return fax4jTemporaryDirectory; }
[ "private", "static", "File", "getFax4jInternalTemporaryDirectoryImpl", "(", ")", "{", "File", "temporaryFile", "=", "null", ";", "try", "{", "//create temporary file", "temporaryFile", "=", "File", ".", "createTempFile", "(", "\"temp_\"", ",", "\".temp\"", ")", ";",...
This function returns the fax4j library internal temporary directory. @return The fax4j library internal temporary directory
[ "This", "function", "returns", "the", "fax4j", "library", "internal", "temporary", "directory", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L61-L103
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.getEncodingToUse
private static String getEncodingToUse(String encoding) { //get encoding String updatedEncoding=encoding; if(updatedEncoding==null) { updatedEncoding=IOHelper.getDefaultEncoding(); } return updatedEncoding; }
java
private static String getEncodingToUse(String encoding) { //get encoding String updatedEncoding=encoding; if(updatedEncoding==null) { updatedEncoding=IOHelper.getDefaultEncoding(); } return updatedEncoding; }
[ "private", "static", "String", "getEncodingToUse", "(", "String", "encoding", ")", "{", "//get encoding", "String", "updatedEncoding", "=", "encoding", ";", "if", "(", "updatedEncoding", "==", "null", ")", "{", "updatedEncoding", "=", "IOHelper", ".", "getDefaultE...
This function returns the encoding to use. If provided encoding is null, the default system encoding is returend. @param encoding The encoding (may be null for system default encoding) @return The encoding to use
[ "This", "function", "returns", "the", "encoding", "to", "use", ".", "If", "provided", "encoding", "is", "null", "the", "default", "system", "encoding", "is", "returend", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L113-L123
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.convertStringToBinary
public static byte[] convertStringToBinary(String text,String encoding) { byte[] data=null; if(text!=null) { if(text.length()==0) { data=new byte[0]; } else { //get logger LoggerManager loggerManager=LoggerManager.getInstance(); Logger logger=loggerManager.getLogger(); String encodingToUse=encoding; if((encodingToUse!=null)&&(encodingToUse.length()>0)) { try { data=text.getBytes(encodingToUse); } catch(UnsupportedEncodingException exception) { logger.logError(new Object[]{"Unable to convert text to binary using encoding: ",encodingToUse," using default system encoding."},exception); } } if(data==null) { encodingToUse=IOHelper.getDefaultEncoding(); try { data=text.getBytes(encodingToUse); } catch(UnsupportedEncodingException exception) { logger.logError(new Object[]{"Unable to convert text to binary using default encoding: ",encodingToUse},exception); throw new FaxException("Unable to convert text to binary using encoding: "+encodingToUse,exception); } } } } return data; }
java
public static byte[] convertStringToBinary(String text,String encoding) { byte[] data=null; if(text!=null) { if(text.length()==0) { data=new byte[0]; } else { //get logger LoggerManager loggerManager=LoggerManager.getInstance(); Logger logger=loggerManager.getLogger(); String encodingToUse=encoding; if((encodingToUse!=null)&&(encodingToUse.length()>0)) { try { data=text.getBytes(encodingToUse); } catch(UnsupportedEncodingException exception) { logger.logError(new Object[]{"Unable to convert text to binary using encoding: ",encodingToUse," using default system encoding."},exception); } } if(data==null) { encodingToUse=IOHelper.getDefaultEncoding(); try { data=text.getBytes(encodingToUse); } catch(UnsupportedEncodingException exception) { logger.logError(new Object[]{"Unable to convert text to binary using default encoding: ",encodingToUse},exception); throw new FaxException("Unable to convert text to binary using encoding: "+encodingToUse,exception); } } } } return data; }
[ "public", "static", "byte", "[", "]", "convertStringToBinary", "(", "String", "text", ",", "String", "encoding", ")", "{", "byte", "[", "]", "data", "=", "null", ";", "if", "(", "text", "!=", "null", ")", "{", "if", "(", "text", ".", "length", "(", ...
This function converts the provided string to binary data. @param text The text to convert @param encoding The text encoding @return The binary data
[ "This", "function", "converts", "the", "provided", "string", "to", "binary", "data", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L154-L201
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.createReader
public static Reader createReader(InputStream inputStream,String encoding) { //get encoding String updatedEncoding=IOHelper.getEncodingToUse(encoding); //create reader Reader reader=null; try { reader=new InputStreamReader(inputStream,updatedEncoding); } catch(UnsupportedEncodingException exception) { throw new FaxException("Unable to create reader, unsupported encoding: "+encoding,exception); } return reader; }
java
public static Reader createReader(InputStream inputStream,String encoding) { //get encoding String updatedEncoding=IOHelper.getEncodingToUse(encoding); //create reader Reader reader=null; try { reader=new InputStreamReader(inputStream,updatedEncoding); } catch(UnsupportedEncodingException exception) { throw new FaxException("Unable to create reader, unsupported encoding: "+encoding,exception); } return reader; }
[ "public", "static", "Reader", "createReader", "(", "InputStream", "inputStream", ",", "String", "encoding", ")", "{", "//get encoding", "String", "updatedEncoding", "=", "IOHelper", ".", "getEncodingToUse", "(", "encoding", ")", ";", "//create reader", "Reader", "re...
This function creates and returns a new reader for the provided input stream. @param inputStream The input stream @param encoding The encoding used by the reader (null for default system encoding) @return The reader
[ "This", "function", "creates", "and", "returns", "a", "new", "reader", "for", "the", "provided", "input", "stream", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L235-L252
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.createWriter
public static Writer createWriter(OutputStream outputStream,String encoding) { //get encoding String updatedEncoding=IOHelper.getEncodingToUse(encoding); //create writer Writer writer=null; try { writer=new OutputStreamWriter(outputStream,updatedEncoding); } catch(UnsupportedEncodingException exception) { throw new FaxException("Unable to create writer, unsupported encoding: "+encoding,exception); } return writer; }
java
public static Writer createWriter(OutputStream outputStream,String encoding) { //get encoding String updatedEncoding=IOHelper.getEncodingToUse(encoding); //create writer Writer writer=null; try { writer=new OutputStreamWriter(outputStream,updatedEncoding); } catch(UnsupportedEncodingException exception) { throw new FaxException("Unable to create writer, unsupported encoding: "+encoding,exception); } return writer; }
[ "public", "static", "Writer", "createWriter", "(", "OutputStream", "outputStream", ",", "String", "encoding", ")", "{", "//get encoding", "String", "updatedEncoding", "=", "IOHelper", ".", "getEncodingToUse", "(", "encoding", ")", ";", "//create writer", "Writer", "...
This function creates and returns a new writer for the provided output stream. @param outputStream The output stream @param encoding The encoding used by the writer (null for default system encoding) @return The writer
[ "This", "function", "creates", "and", "returns", "a", "new", "writer", "for", "the", "provided", "output", "stream", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L264-L281
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.readTextStream
public static String readTextStream(Reader reader) throws IOException { char[] buffer=new char[5000]; Writer stringWriter=new StringWriter(); int read=-1; try { do { //read next buffer read=reader.read(buffer); if(read!=-1) { //write to string writer stringWriter.write(buffer,0,read); } }while(read!=-1); } finally { //close streams IOHelper.closeResource(reader); } //get text String text=stringWriter.toString(); return text; }
java
public static String readTextStream(Reader reader) throws IOException { char[] buffer=new char[5000]; Writer stringWriter=new StringWriter(); int read=-1; try { do { //read next buffer read=reader.read(buffer); if(read!=-1) { //write to string writer stringWriter.write(buffer,0,read); } }while(read!=-1); } finally { //close streams IOHelper.closeResource(reader); } //get text String text=stringWriter.toString(); return text; }
[ "public", "static", "String", "readTextStream", "(", "Reader", "reader", ")", "throws", "IOException", "{", "char", "[", "]", "buffer", "=", "new", "char", "[", "5000", "]", ";", "Writer", "stringWriter", "=", "new", "StringWriter", "(", ")", ";", "int", ...
Reads the text from the stream. @param reader The reader to the text @return The text read from the provided stream @throws IOException Any IO exception
[ "Reads", "the", "text", "from", "the", "stream", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L292-L321
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.readTextFile
public static String readTextFile(File file) throws IOException { //create reader to file (with default encoding) InputStream inputStream=new FileInputStream(file); Reader reader=IOHelper.createReader(inputStream,null); //read text String text=IOHelper.readTextStream(reader); return text; }
java
public static String readTextFile(File file) throws IOException { //create reader to file (with default encoding) InputStream inputStream=new FileInputStream(file); Reader reader=IOHelper.createReader(inputStream,null); //read text String text=IOHelper.readTextStream(reader); return text; }
[ "public", "static", "String", "readTextFile", "(", "File", "file", ")", "throws", "IOException", "{", "//create reader to file (with default encoding)", "InputStream", "inputStream", "=", "new", "FileInputStream", "(", "file", ")", ";", "Reader", "reader", "=", "IOHel...
Reads the text from the file. @param file The text file @return The text read from the provided file @throws IOException Any IO exception
[ "Reads", "the", "text", "from", "the", "file", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L332-L342
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.writeTextFile
public static void writeTextFile(String text,File file) throws IOException { Writer writer=null; try { //create writer to file (with default encoding) OutputStream outputStream=new FileOutputStream(file); writer=IOHelper.createWriter(outputStream,null); //write to file writer.write(text); } finally { //close writer IOHelper.closeResource(writer); } }
java
public static void writeTextFile(String text,File file) throws IOException { Writer writer=null; try { //create writer to file (with default encoding) OutputStream outputStream=new FileOutputStream(file); writer=IOHelper.createWriter(outputStream,null); //write to file writer.write(text); } finally { //close writer IOHelper.closeResource(writer); } }
[ "public", "static", "void", "writeTextFile", "(", "String", "text", ",", "File", "file", ")", "throws", "IOException", "{", "Writer", "writer", "=", "null", ";", "try", "{", "//create writer to file (with default encoding)", "OutputStream", "outputStream", "=", "new...
Writes the text to the file. @param text The text to write to the provided file @param file The text file @throws IOException Any IO exception
[ "Writes", "the", "text", "to", "the", "file", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L354-L371
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.readAndWriteStreams
public static void readAndWriteStreams(InputStream inputStream,OutputStream outputStream) throws IOException { byte[] buffer=new byte[5000]; int read=-1; try { do { //read next buffer read=inputStream.read(buffer); if(read!=-1) { //write to in memory stream outputStream.write(buffer,0,read); } }while(read!=-1); } finally { //close streams IOHelper.closeResource(inputStream); IOHelper.closeResource(outputStream); } }
java
public static void readAndWriteStreams(InputStream inputStream,OutputStream outputStream) throws IOException { byte[] buffer=new byte[5000]; int read=-1; try { do { //read next buffer read=inputStream.read(buffer); if(read!=-1) { //write to in memory stream outputStream.write(buffer,0,read); } }while(read!=-1); } finally { //close streams IOHelper.closeResource(inputStream); IOHelper.closeResource(outputStream); } }
[ "public", "static", "void", "readAndWriteStreams", "(", "InputStream", "inputStream", ",", "OutputStream", "outputStream", ")", "throws", "IOException", "{", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "5000", "]", ";", "int", "read", "=", "-", "1",...
Reads the data from the input stream and writes to the output stream. @param inputStream The inputStream to read from @param outputStream The output stream to write to @throws IOException Any IO exception
[ "Reads", "the", "data", "from", "the", "input", "stream", "and", "writes", "to", "the", "output", "stream", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L384-L408
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.readStream
public static byte[] readStream(InputStream inputStream) throws IOException { //create output stream ByteArrayOutputStream outputStream=new ByteArrayOutputStream(5000); //read/write IOHelper.readAndWriteStreams(inputStream,outputStream); //get data byte[] data=outputStream.toByteArray(); return data; }
java
public static byte[] readStream(InputStream inputStream) throws IOException { //create output stream ByteArrayOutputStream outputStream=new ByteArrayOutputStream(5000); //read/write IOHelper.readAndWriteStreams(inputStream,outputStream); //get data byte[] data=outputStream.toByteArray(); return data; }
[ "public", "static", "byte", "[", "]", "readStream", "(", "InputStream", "inputStream", ")", "throws", "IOException", "{", "//create output stream", "ByteArrayOutputStream", "outputStream", "=", "new", "ByteArrayOutputStream", "(", "5000", ")", ";", "//read/write", "IO...
Reads the data from the stream. @param inputStream The inputStream @return The data read from the provided stream @throws IOException Any IO exception
[ "Reads", "the", "data", "from", "the", "stream", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L419-L431
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.readFile
public static byte[] readFile(File file) throws IOException { //create stream to file InputStream inputStream=new FileInputStream(file); //read data byte[] data=IOHelper.readStream(inputStream); return data; }
java
public static byte[] readFile(File file) throws IOException { //create stream to file InputStream inputStream=new FileInputStream(file); //read data byte[] data=IOHelper.readStream(inputStream); return data; }
[ "public", "static", "byte", "[", "]", "readFile", "(", "File", "file", ")", "throws", "IOException", "{", "//create stream to file", "InputStream", "inputStream", "=", "new", "FileInputStream", "(", "file", ")", ";", "//read data", "byte", "[", "]", "data", "=...
Reads the data from the file. @param file The file @return The data read from the provided file @throws IOException Any IO exception
[ "Reads", "the", "data", "from", "the", "file", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L442-L451
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.writeFile
public static void writeFile(byte[] content,File file) throws IOException { OutputStream outputStream=null; try { //create output stream to file outputStream=new FileOutputStream(file); //write to file outputStream.write(content); } finally { //close writer IOHelper.closeResource(outputStream); } }
java
public static void writeFile(byte[] content,File file) throws IOException { OutputStream outputStream=null; try { //create output stream to file outputStream=new FileOutputStream(file); //write to file outputStream.write(content); } finally { //close writer IOHelper.closeResource(outputStream); } }
[ "public", "static", "void", "writeFile", "(", "byte", "[", "]", "content", ",", "File", "file", ")", "throws", "IOException", "{", "OutputStream", "outputStream", "=", "null", ";", "try", "{", "//create output stream to file", "outputStream", "=", "new", "FileOu...
Writes the content to the file. @param content The content to write to the provided file @param file The target file @throws IOException Any IO exception
[ "Writes", "the", "content", "to", "the", "file", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L463-L479
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.getFileFromPathList
public static File getFileFromPathList(String fileNameWithNoPath,String[] pathList) { File foundFile=null; if(pathList!=null) { //get amount int amount=pathList.length; String directoryPath=null; File file=null; for(int index=0;index<amount;index++) { //get next element directoryPath=pathList[index]; //get file file=new File(directoryPath,fileNameWithNoPath); if((file.exists())&&(file.isFile())) { foundFile=file; break; } } } return foundFile; }
java
public static File getFileFromPathList(String fileNameWithNoPath,String[] pathList) { File foundFile=null; if(pathList!=null) { //get amount int amount=pathList.length; String directoryPath=null; File file=null; for(int index=0;index<amount;index++) { //get next element directoryPath=pathList[index]; //get file file=new File(directoryPath,fileNameWithNoPath); if((file.exists())&&(file.isFile())) { foundFile=file; break; } } } return foundFile; }
[ "public", "static", "File", "getFileFromPathList", "(", "String", "fileNameWithNoPath", ",", "String", "[", "]", "pathList", ")", "{", "File", "foundFile", "=", "null", ";", "if", "(", "pathList", "!=", "null", ")", "{", "//get amount", "int", "amount", "=",...
This function returns the file object of the first location in which the requested file is found. @param fileNameWithNoPath The file name (with no directory path) @param pathList The path list @return The file object if found, else null will be returned
[ "This", "function", "returns", "the", "file", "object", "of", "the", "first", "location", "in", "which", "the", "requested", "file", "is", "found", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L491-L518
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/IOHelper.java
IOHelper.getFileFromNativePath
public static File getFileFromNativePath(String fileNameWithNoPath) { //get system path String systemPath=System.getProperty("java.library.path"); String pathSeperator=System.getProperty("path.separator"); String[] systemPathElements=systemPath.split(pathSeperator); //get file File file=IOHelper.getFileFromPathList(fileNameWithNoPath,systemPathElements); return file; }
java
public static File getFileFromNativePath(String fileNameWithNoPath) { //get system path String systemPath=System.getProperty("java.library.path"); String pathSeperator=System.getProperty("path.separator"); String[] systemPathElements=systemPath.split(pathSeperator); //get file File file=IOHelper.getFileFromPathList(fileNameWithNoPath,systemPathElements); return file; }
[ "public", "static", "File", "getFileFromNativePath", "(", "String", "fileNameWithNoPath", ")", "{", "//get system path", "String", "systemPath", "=", "System", ".", "getProperty", "(", "\"java.library.path\"", ")", ";", "String", "pathSeperator", "=", "System", ".", ...
This function returns the file object of the first location in which the requested file is found. The path list used, is the current native path of the process. @param fileNameWithNoPath The file name (with no directory path) @return The file object if found, else null will be returned
[ "This", "function", "returns", "the", "file", "object", "of", "the", "first", "location", "in", "which", "the", "requested", "file", "is", "found", ".", "The", "path", "list", "used", "is", "the", "current", "native", "path", "of", "the", "process", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/IOHelper.java#L529-L540
train
sagiegurari/fax4j
src/main/java/org/fax4j/bridge/AbstractContextFaxBridge.java
AbstractContextFaxBridge.submitFaxJob
public FaxJob submitFaxJob(T inputData) { if(inputData==null) { throw new FaxException("Input data not provided."); } //create fax job FaxJob faxJob=this.createFaxJob(); //update fax job info this.requestParser.updateFaxJobFromInputData(inputData,faxJob); //create file info FileInfo fileInfo=this.requestParser.getFileInfoFromInputData(inputData); if(fileInfo==null) { throw new FaxException("Unable to extract file info from input data."); } //submit fax job this.submitFaxJob(faxJob,fileInfo); return faxJob; }
java
public FaxJob submitFaxJob(T inputData) { if(inputData==null) { throw new FaxException("Input data not provided."); } //create fax job FaxJob faxJob=this.createFaxJob(); //update fax job info this.requestParser.updateFaxJobFromInputData(inputData,faxJob); //create file info FileInfo fileInfo=this.requestParser.getFileInfoFromInputData(inputData); if(fileInfo==null) { throw new FaxException("Unable to extract file info from input data."); } //submit fax job this.submitFaxJob(faxJob,fileInfo); return faxJob; }
[ "public", "FaxJob", "submitFaxJob", "(", "T", "inputData", ")", "{", "if", "(", "inputData", "==", "null", ")", "{", "throw", "new", "FaxException", "(", "\"Input data not provided.\"", ")", ";", "}", "//create fax job", "FaxJob", "faxJob", "=", "this", ".", ...
This function will submit a new fax job. @param inputData The input data holding the fax job information @return The submitted fax job
[ "This", "function", "will", "submit", "a", "new", "fax", "job", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/AbstractContextFaxBridge.java#L70-L94
train
sagiegurari/fax4j
src/main/java/org/fax4j/bridge/email/DefaultMailMessageParser.java
DefaultMailMessageParser.getTargetAddress
protected String getTargetAddress(Message mailMessage) throws MessagingException { //by default the target address is taken from the mail subject which //is expected to be in the format of: fax:<number> String subject=mailMessage.getSubject(); String targetAddress=null; if((subject!=null)&&(subject.startsWith("fax:"))&&(subject.length()>4)) { targetAddress=subject.substring(4); } return targetAddress; }
java
protected String getTargetAddress(Message mailMessage) throws MessagingException { //by default the target address is taken from the mail subject which //is expected to be in the format of: fax:<number> String subject=mailMessage.getSubject(); String targetAddress=null; if((subject!=null)&&(subject.startsWith("fax:"))&&(subject.length()>4)) { targetAddress=subject.substring(4); } return targetAddress; }
[ "protected", "String", "getTargetAddress", "(", "Message", "mailMessage", ")", "throws", "MessagingException", "{", "//by default the target address is taken from the mail subject which", "//is expected to be in the format of: fax:<number>", "String", "subject", "=", "mailMessage", "...
Returns the target address from the provided mail object. @param mailMessage The mail message with the fax data @return The target address @throws MessagingException Any exception while handling the mail message
[ "Returns", "the", "target", "address", "from", "the", "provided", "mail", "object", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/email/DefaultMailMessageParser.java#L123-L135
train
sagiegurari/fax4j
src/main/java/org/fax4j/bridge/email/DefaultMailMessageParser.java
DefaultMailMessageParser.getSenderEmail
protected String getSenderEmail(Message mailMessage) throws MessagingException { Address[] addresses=mailMessage.getFrom(); String senderEmail=null; if((addresses!=null)&&(addresses.length>0)) { //get sender mail address (only first from is used) Address address=addresses[0]; //get as string senderEmail=address.toString(); } return senderEmail; }
java
protected String getSenderEmail(Message mailMessage) throws MessagingException { Address[] addresses=mailMessage.getFrom(); String senderEmail=null; if((addresses!=null)&&(addresses.length>0)) { //get sender mail address (only first from is used) Address address=addresses[0]; //get as string senderEmail=address.toString(); } return senderEmail; }
[ "protected", "String", "getSenderEmail", "(", "Message", "mailMessage", ")", "throws", "MessagingException", "{", "Address", "[", "]", "addresses", "=", "mailMessage", ".", "getFrom", "(", ")", ";", "String", "senderEmail", "=", "null", ";", "if", "(", "(", ...
Returns the sender email from the provided mail object. @param mailMessage The mail message with the fax data @return The sender email @throws MessagingException Any exception while handling the mail message
[ "Returns", "the", "sender", "email", "from", "the", "provided", "mail", "object", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/email/DefaultMailMessageParser.java#L146-L160
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java
MultiPartFaxJob2HTTPRequestConverter.initializeAdditionalParameters
protected Map<String,String> initializeAdditionalParameters() { //get configuration Map<String,String> configuration=this.getConfiguration(); //get property part String propertyPart=this.getPropertyPart(); //get prefix String prefix=FaxJob2HTTPRequestConverterConfigurationConstants.ADDITIONAL_PARAMETER_PROPERTY_KEY_PREFIX.toString(); prefix=MessageFormat.format(prefix,propertyPart); //init output Map<String,String> additionalParametersMap=new HashMap<String,String>(); Iterator<Entry<String,String>> iterator=configuration.entrySet().iterator(); Entry<String,String> entry=null; String key=null; String value=null; while(iterator.hasNext()) { //get next entry entry=iterator.next(); //get next key key=entry.getKey(); if(key!=null) { //format key key=MessageFormat.format(key,propertyPart); key=key.trim(); if(key.length()>0) { //check if additional parameter key if(key.startsWith(prefix)) { //get value value=entry.getValue(); if(value!=null) { value=value.trim(); if(value.length()>0) { //get updated key without prefix key=key.substring(prefix.length()); //put in map additionalParametersMap.put(key,value); } } } } } } return additionalParametersMap; }
java
protected Map<String,String> initializeAdditionalParameters() { //get configuration Map<String,String> configuration=this.getConfiguration(); //get property part String propertyPart=this.getPropertyPart(); //get prefix String prefix=FaxJob2HTTPRequestConverterConfigurationConstants.ADDITIONAL_PARAMETER_PROPERTY_KEY_PREFIX.toString(); prefix=MessageFormat.format(prefix,propertyPart); //init output Map<String,String> additionalParametersMap=new HashMap<String,String>(); Iterator<Entry<String,String>> iterator=configuration.entrySet().iterator(); Entry<String,String> entry=null; String key=null; String value=null; while(iterator.hasNext()) { //get next entry entry=iterator.next(); //get next key key=entry.getKey(); if(key!=null) { //format key key=MessageFormat.format(key,propertyPart); key=key.trim(); if(key.length()>0) { //check if additional parameter key if(key.startsWith(prefix)) { //get value value=entry.getValue(); if(value!=null) { value=value.trim(); if(value.length()>0) { //get updated key without prefix key=key.substring(prefix.length()); //put in map additionalParametersMap.put(key,value); } } } } } } return additionalParametersMap; }
[ "protected", "Map", "<", "String", ",", "String", ">", "initializeAdditionalParameters", "(", ")", "{", "//get configuration", "Map", "<", "String", ",", "String", ">", "configuration", "=", "this", ".", "getConfiguration", "(", ")", ";", "//get property part", ...
This function builds and returns the additional parameters map. @return The additional parameters
[ "This", "function", "builds", "and", "returns", "the", "additional", "parameters", "map", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java#L320-L379
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java
MultiPartFaxJob2HTTPRequestConverter.createCommonHTTPRequest
protected HTTPRequest createCommonHTTPRequest(HTTPFaxClientSpi faxClientSpi,FaxActionType faxActionType) { //setup common request data HTTPRequest httpRequest=new HTTPRequest(); String resource=faxClientSpi.getHTTPResource(faxActionType); httpRequest.setResource(resource); String urlParameters=faxClientSpi.getHTTPURLParameters(); httpRequest.setParametersText(urlParameters); return httpRequest; }
java
protected HTTPRequest createCommonHTTPRequest(HTTPFaxClientSpi faxClientSpi,FaxActionType faxActionType) { //setup common request data HTTPRequest httpRequest=new HTTPRequest(); String resource=faxClientSpi.getHTTPResource(faxActionType); httpRequest.setResource(resource); String urlParameters=faxClientSpi.getHTTPURLParameters(); httpRequest.setParametersText(urlParameters); return httpRequest; }
[ "protected", "HTTPRequest", "createCommonHTTPRequest", "(", "HTTPFaxClientSpi", "faxClientSpi", ",", "FaxActionType", "faxActionType", ")", "{", "//setup common request data", "HTTPRequest", "httpRequest", "=", "new", "HTTPRequest", "(", ")", ";", "String", "resource", "=...
Creates a HTTP request with the common data. @param faxClientSpi The HTTP fax client SPI @param faxActionType The fax action type @return The HTTP request to send
[ "Creates", "a", "HTTP", "request", "with", "the", "common", "data", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java#L470-L480
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java
MultiPartFaxJob2HTTPRequestConverter.addContentPart
protected final void addContentPart(List<ContentPart<?>> contentList,String key,String value) { if((key!=null)&&(value!=null)&&(value.length()>0)) { if(this.shouldAddContentPart(key)) { contentList.add(new ContentPart<String>(key,value,ContentPartType.STRING)); } } }
java
protected final void addContentPart(List<ContentPart<?>> contentList,String key,String value) { if((key!=null)&&(value!=null)&&(value.length()>0)) { if(this.shouldAddContentPart(key)) { contentList.add(new ContentPart<String>(key,value,ContentPartType.STRING)); } } }
[ "protected", "final", "void", "addContentPart", "(", "List", "<", "ContentPart", "<", "?", ">", ">", "contentList", ",", "String", "key", ",", "String", "value", ")", "{", "if", "(", "(", "key", "!=", "null", ")", "&&", "(", "value", "!=", "null", ")...
This function adds a string content part @param contentList The content list with all the created parts @param key The parameter key @param value The parameter value
[ "This", "function", "adds", "a", "string", "content", "part" ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java#L492-L501
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java
MultiPartFaxJob2HTTPRequestConverter.addAdditionalParameters
protected final void addAdditionalParameters(List<ContentPart<?>> contentList) { //add additional parameters if(this.additionalParameters!=null) { Iterator<Entry<String,String>> iterator=this.additionalParameters.entrySet().iterator(); Entry<String,String> entry=null; String key=null; String value=null; while(iterator.hasNext()) { //get next entry entry=iterator.next(); //get next key/value key=entry.getKey(); value=entry.getValue(); if((key!=null)&&(value!=null)) { this.addContentPart(contentList,key,value); } } } }
java
protected final void addAdditionalParameters(List<ContentPart<?>> contentList) { //add additional parameters if(this.additionalParameters!=null) { Iterator<Entry<String,String>> iterator=this.additionalParameters.entrySet().iterator(); Entry<String,String> entry=null; String key=null; String value=null; while(iterator.hasNext()) { //get next entry entry=iterator.next(); //get next key/value key=entry.getKey(); value=entry.getValue(); if((key!=null)&&(value!=null)) { this.addContentPart(contentList,key,value); } } } }
[ "protected", "final", "void", "addAdditionalParameters", "(", "List", "<", "ContentPart", "<", "?", ">", ">", "contentList", ")", "{", "//add additional parameters", "if", "(", "this", ".", "additionalParameters", "!=", "null", ")", "{", "Iterator", "<", "Entry"...
This function adds the additional parameters. @param contentList The content list with all the created parts
[ "This", "function", "adds", "the", "additional", "parameters", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java#L528-L552
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java
MultiPartFaxJob2HTTPRequestConverter.addAdditionalContentParts
protected void addAdditionalContentParts(HTTPFaxClientSpi faxClientSpi,FaxActionType faxActionType,FaxJob faxJob,List<ContentPart<?>> contentList) { //empty hook for extending classes }
java
protected void addAdditionalContentParts(HTTPFaxClientSpi faxClientSpi,FaxActionType faxActionType,FaxJob faxJob,List<ContentPart<?>> contentList) { //empty hook for extending classes }
[ "protected", "void", "addAdditionalContentParts", "(", "HTTPFaxClientSpi", "faxClientSpi", ",", "FaxActionType", "faxActionType", ",", "FaxJob", "faxJob", ",", "List", "<", "ContentPart", "<", "?", ">", ">", "contentList", ")", "{", "//empty hook for extending classes",...
This function enables extending classes to add additional content parts. @param faxClientSpi The HTTP fax client SPI @param faxActionType The fax action type @param faxJob The fax job object @param contentList The content list with all the created parts
[ "This", "function", "enables", "extending", "classes", "to", "add", "additional", "content", "parts", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/MultiPartFaxJob2HTTPRequestConverter.java#L566-L569
train
sagiegurari/fax4j
src/main/java/org/fax4j/bridge/AbstractRequestParser.java
AbstractRequestParser.getFileInfoFromInputData
public FileInfo getFileInfoFromInputData(T inputData) { if(!this.initialized) { throw new FaxException("Fax bridge not initialized."); } //get file info FileInfo fileInfo=this.getFileInfoFromInputDataImpl(inputData); return fileInfo; }
java
public FileInfo getFileInfoFromInputData(T inputData) { if(!this.initialized) { throw new FaxException("Fax bridge not initialized."); } //get file info FileInfo fileInfo=this.getFileInfoFromInputDataImpl(inputData); return fileInfo; }
[ "public", "FileInfo", "getFileInfoFromInputData", "(", "T", "inputData", ")", "{", "if", "(", "!", "this", ".", "initialized", ")", "{", "throw", "new", "FaxException", "(", "\"Fax bridge not initialized.\"", ")", ";", "}", "//get file info", "FileInfo", "fileInfo...
This function returns the file info from the input data. @param inputData The input data @return The file info
[ "This", "function", "returns", "the", "file", "info", "from", "the", "input", "data", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/AbstractRequestParser.java#L60-L71
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/vbs/VBSProcessOutputHandler.java
VBSProcessOutputHandler.getFaxJobStatusFromWindowsFaxJobStatusString
protected FaxJobStatus getFaxJobStatusFromWindowsFaxJobStatusString(String faxJobStatusStr) { FaxJobStatus faxJobStatus=FaxJobStatus.UNKNOWN; if((faxJobStatusStr!=null)&&(faxJobStatusStr.length()>0)) { if((faxJobStatusStr.equalsIgnoreCase("Pending"))||(faxJobStatusStr.equalsIgnoreCase("Paused"))||(faxJobStatusStr.equalsIgnoreCase("Retrying"))) { faxJobStatus=FaxJobStatus.PENDING; } else if(faxJobStatusStr.equalsIgnoreCase("In Progress")) { faxJobStatus=FaxJobStatus.IN_PROGRESS; } else if((faxJobStatusStr.equalsIgnoreCase("Failed"))||(faxJobStatusStr.equalsIgnoreCase("No Line"))||(faxJobStatusStr.equalsIgnoreCase("Retries Exceeded"))) { faxJobStatus=FaxJobStatus.ERROR; } } return faxJobStatus; }
java
protected FaxJobStatus getFaxJobStatusFromWindowsFaxJobStatusString(String faxJobStatusStr) { FaxJobStatus faxJobStatus=FaxJobStatus.UNKNOWN; if((faxJobStatusStr!=null)&&(faxJobStatusStr.length()>0)) { if((faxJobStatusStr.equalsIgnoreCase("Pending"))||(faxJobStatusStr.equalsIgnoreCase("Paused"))||(faxJobStatusStr.equalsIgnoreCase("Retrying"))) { faxJobStatus=FaxJobStatus.PENDING; } else if(faxJobStatusStr.equalsIgnoreCase("In Progress")) { faxJobStatus=FaxJobStatus.IN_PROGRESS; } else if((faxJobStatusStr.equalsIgnoreCase("Failed"))||(faxJobStatusStr.equalsIgnoreCase("No Line"))||(faxJobStatusStr.equalsIgnoreCase("Retries Exceeded"))) { faxJobStatus=FaxJobStatus.ERROR; } } return faxJobStatus; }
[ "protected", "FaxJobStatus", "getFaxJobStatusFromWindowsFaxJobStatusString", "(", "String", "faxJobStatusStr", ")", "{", "FaxJobStatus", "faxJobStatus", "=", "FaxJobStatus", ".", "UNKNOWN", ";", "if", "(", "(", "faxJobStatusStr", "!=", "null", ")", "&&", "(", "faxJobS...
This function returns the fax job status based on the windows fax job status string value. @param faxJobStatusStr The fax job status string value @return The fax job status
[ "This", "function", "returns", "the", "fax", "job", "status", "based", "on", "the", "windows", "fax", "job", "status", "string", "value", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/vbs/VBSProcessOutputHandler.java#L42-L62
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/HTTPFaxClientSpi.java
HTTPFaxClientSpi.updateFaxJob
protected void updateFaxJob(FaxJob faxJob,HTTPResponse httpResponse,FaxActionType faxActionType) { this.httpResponseHandler.updateFaxJob(faxJob,httpResponse,faxActionType); }
java
protected void updateFaxJob(FaxJob faxJob,HTTPResponse httpResponse,FaxActionType faxActionType) { this.httpResponseHandler.updateFaxJob(faxJob,httpResponse,faxActionType); }
[ "protected", "void", "updateFaxJob", "(", "FaxJob", "faxJob", ",", "HTTPResponse", "httpResponse", ",", "FaxActionType", "faxActionType", ")", "{", "this", ".", "httpResponseHandler", ".", "updateFaxJob", "(", "faxJob", ",", "httpResponse", ",", "faxActionType", ")"...
Updates the fax job based on the data from the HTTP response. @param faxJob The fax job object @param httpResponse The HTTP response @param faxActionType The fax action type
[ "Updates", "the", "fax", "job", "based", "on", "the", "data", "from", "the", "HTTP", "response", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/HTTPFaxClientSpi.java#L641-L644
train
sagiegurari/fax4j
src/main/java/org/fax4j/bridge/AbstractFaxBridge.java
AbstractFaxBridge.initialize
public final synchronized void initialize(String type,Properties configuration,Object flowOwner) { if(this.initialized) { throw new FaxException("Fax bridge already initialized."); } //set flag this.initialized=true; //get configuration Map<String,String> map=new HashMap<String,String>(); SpiUtil.copyPropertiesToMap(configuration,map); this.bridgeConfiguration=new ConfigurationHolderImpl(map); //create fax client this.faxClient=FaxClientFactory.createFaxClient(type,configuration); //get logger LoggerManager loggerManager=LoggerManager.getInstance(); this.bridgeLogger=loggerManager.getLogger(); //create vendor policy this.vendorPolicy=this.createVendorPolicy(); if(this.vendorPolicy==null) { throw new FaxException("Unable to create vendor policy"); } //initialize vendor policy this.vendorPolicy.initialize(flowOwner); if(this.vendorPolicy instanceof FaxMonitorEventListener) { this.faxClient.addFaxMonitorEventListener((FaxMonitorEventListener)this.vendorPolicy); } //log fax client SPI information this.bridgeLogger.logDebug(new Object[]{"Initializing fax bridge of type: ",this.getClass().getName(),"\nProvider Information:\n",this.getProvider(),"\nFax Bridge Configuration:\n",configuration,"\nVendor Policy Type: ",this.vendorPolicy.getClass().getName()},null); //invoke hook this.initializeImpl(); }
java
public final synchronized void initialize(String type,Properties configuration,Object flowOwner) { if(this.initialized) { throw new FaxException("Fax bridge already initialized."); } //set flag this.initialized=true; //get configuration Map<String,String> map=new HashMap<String,String>(); SpiUtil.copyPropertiesToMap(configuration,map); this.bridgeConfiguration=new ConfigurationHolderImpl(map); //create fax client this.faxClient=FaxClientFactory.createFaxClient(type,configuration); //get logger LoggerManager loggerManager=LoggerManager.getInstance(); this.bridgeLogger=loggerManager.getLogger(); //create vendor policy this.vendorPolicy=this.createVendorPolicy(); if(this.vendorPolicy==null) { throw new FaxException("Unable to create vendor policy"); } //initialize vendor policy this.vendorPolicy.initialize(flowOwner); if(this.vendorPolicy instanceof FaxMonitorEventListener) { this.faxClient.addFaxMonitorEventListener((FaxMonitorEventListener)this.vendorPolicy); } //log fax client SPI information this.bridgeLogger.logDebug(new Object[]{"Initializing fax bridge of type: ",this.getClass().getName(),"\nProvider Information:\n",this.getProvider(),"\nFax Bridge Configuration:\n",configuration,"\nVendor Policy Type: ",this.vendorPolicy.getClass().getName()},null); //invoke hook this.initializeImpl(); }
[ "public", "final", "synchronized", "void", "initialize", "(", "String", "type", ",", "Properties", "configuration", ",", "Object", "flowOwner", ")", "{", "if", "(", "this", ".", "initialized", ")", "{", "throw", "new", "FaxException", "(", "\"Fax bridge already ...
This function initializes the fax bridge. @param type The fax client type (may be null for default type) @param configuration The fax client configuration (may be null) @param flowOwner The flow owner (servlet, CLI main, ....) to be passed to the vendor policy
[ "This", "function", "initializes", "the", "fax", "bridge", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/AbstractFaxBridge.java#L78-L119
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/SpiUtil.java
SpiUtil.copyPropertiesToMap
public static void copyPropertiesToMap(Properties source,Map<String,String> target) { if(source!=null) { //convert to map Iterator<Entry<Object,Object>> iterator=source.entrySet().iterator(); Entry<Object,Object> entry=null; String key=null; String value=null; while(iterator.hasNext()) { //get next entry entry=iterator.next(); //get next key/value key=(String)entry.getKey(); value=(String)entry.getValue(); //put in map target.put(key,value); } } }
java
public static void copyPropertiesToMap(Properties source,Map<String,String> target) { if(source!=null) { //convert to map Iterator<Entry<Object,Object>> iterator=source.entrySet().iterator(); Entry<Object,Object> entry=null; String key=null; String value=null; while(iterator.hasNext()) { //get next entry entry=iterator.next(); //get next key/value key=(String)entry.getKey(); value=(String)entry.getValue(); //put in map target.put(key,value); } } }
[ "public", "static", "void", "copyPropertiesToMap", "(", "Properties", "source", ",", "Map", "<", "String", ",", "String", ">", "target", ")", "{", "if", "(", "source", "!=", "null", ")", "{", "//convert to map", "Iterator", "<", "Entry", "<", "Object", ","...
This function copies all mappings from source properties to target map. @param source The source properties @param target The target map to populate
[ "This", "function", "copies", "all", "mappings", "from", "source", "properties", "to", "target", "map", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/SpiUtil.java#L81-L103
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/SpiUtil.java
SpiUtil.replaceTemplateParameter
public static String replaceTemplateParameter(String template,String parameter,String value,TemplateParameterEncoder encoder) { String text=template; if((text!=null)&&(parameter!=null)) { String updatedValue=value; if(updatedValue==null) { updatedValue=SpiUtil.EMPTY_STRING; } else if(encoder!=null) { updatedValue=encoder.encodeTemplateParameter(updatedValue); } text=text.replace(parameter,updatedValue); } return text; }
java
public static String replaceTemplateParameter(String template,String parameter,String value,TemplateParameterEncoder encoder) { String text=template; if((text!=null)&&(parameter!=null)) { String updatedValue=value; if(updatedValue==null) { updatedValue=SpiUtil.EMPTY_STRING; } else if(encoder!=null) { updatedValue=encoder.encodeTemplateParameter(updatedValue); } text=text.replace(parameter,updatedValue); } return text; }
[ "public", "static", "String", "replaceTemplateParameter", "(", "String", "template", ",", "String", "parameter", ",", "String", "value", ",", "TemplateParameterEncoder", "encoder", ")", "{", "String", "text", "=", "template", ";", "if", "(", "(", "text", "!=", ...
This function replaces the parameter with the provided value. @param template The template @param parameter The parameter @param value The value @param encoder The encoder that encodes the template values (may be null) @return The updated template
[ "This", "function", "replaces", "the", "parameter", "with", "the", "provided", "value", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/SpiUtil.java#L183-L201
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/SpiUtil.java
SpiUtil.urlEncode
public static String urlEncode(String text) { String urlEncodedString=text; if(text!=null) { try { urlEncodedString=URLEncoder.encode(text,SpiUtil.UTF_8_ENCODING_NAME); } catch(UnsupportedEncodingException exception) { throw new FaxException("Error while URL encoding text.",exception); } } return urlEncodedString; }
java
public static String urlEncode(String text) { String urlEncodedString=text; if(text!=null) { try { urlEncodedString=URLEncoder.encode(text,SpiUtil.UTF_8_ENCODING_NAME); } catch(UnsupportedEncodingException exception) { throw new FaxException("Error while URL encoding text.",exception); } } return urlEncodedString; }
[ "public", "static", "String", "urlEncode", "(", "String", "text", ")", "{", "String", "urlEncodedString", "=", "text", ";", "if", "(", "text", "!=", "null", ")", "{", "try", "{", "urlEncodedString", "=", "URLEncoder", ".", "encode", "(", "text", ",", "Sp...
This function URL encodes the given text. @param text The text to encode @return The encoded text
[ "This", "function", "URL", "encodes", "the", "given", "text", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/SpiUtil.java#L210-L226
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/SpiUtil.java
SpiUtil.urlDecode
public static String urlDecode(String text) { String urlEncodedString=text; if(text!=null) { try { urlEncodedString=URLDecoder.decode(text,SpiUtil.UTF_8_ENCODING_NAME); } catch(UnsupportedEncodingException exception) { throw new FaxException("Error while URL decoding text.",exception); } } return urlEncodedString; }
java
public static String urlDecode(String text) { String urlEncodedString=text; if(text!=null) { try { urlEncodedString=URLDecoder.decode(text,SpiUtil.UTF_8_ENCODING_NAME); } catch(UnsupportedEncodingException exception) { throw new FaxException("Error while URL decoding text.",exception); } } return urlEncodedString; }
[ "public", "static", "String", "urlDecode", "(", "String", "text", ")", "{", "String", "urlEncodedString", "=", "text", ";", "if", "(", "text", "!=", "null", ")", "{", "try", "{", "urlEncodedString", "=", "URLDecoder", ".", "decode", "(", "text", ",", "Sp...
This function URL decodes the given text. @param text The text to decode @return The decoded text
[ "This", "function", "URL", "decodes", "the", "given", "text", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/SpiUtil.java#L235-L251
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/SpiUtil.java
SpiUtil.getFileParameterValue
private static String getFileParameterValue(FaxJob faxJob) { String value=null; File file=faxJob.getFile(); if(file!=null) { try { //read file (only text files supported) value=IOHelper.readTextFile(faxJob.getFile()); } catch(IOException exception) { throw new FaxException("Error while reading file.",exception); } } return value; }
java
private static String getFileParameterValue(FaxJob faxJob) { String value=null; File file=faxJob.getFile(); if(file!=null) { try { //read file (only text files supported) value=IOHelper.readTextFile(faxJob.getFile()); } catch(IOException exception) { throw new FaxException("Error while reading file.",exception); } } return value; }
[ "private", "static", "String", "getFileParameterValue", "(", "FaxJob", "faxJob", ")", "{", "String", "value", "=", "null", ";", "File", "file", "=", "faxJob", ".", "getFile", "(", ")", ";", "if", "(", "file", "!=", "null", ")", "{", "try", "{", "//read...
This function returns the file parameter value based on the file content. @param faxJob The fax job object @return The file parameter value
[ "This", "function", "returns", "the", "file", "parameter", "value", "based", "on", "the", "file", "content", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/SpiUtil.java#L261-L279
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/FaxJobMonitorImpl.java
FaxJobMonitorImpl.initializeImpl
@Override protected void initializeImpl() { //init data structures this.data=new HashMap<FaxClientSpi,Map<FaxJob,FaxJobStatus>>(20); //get polling interval String value=this.getConfigurationValue(FaxJobMonitorImpl.POLLING_INTERVAL_IN_MILLIES_PROPERTY_KEY); this.pollingInterval=5000; if(value!=null) { this.pollingInterval=Long.parseLong(value); if(this.pollingInterval<=0) { throw new FaxException("Polling interval set to an invalid value: "+this.pollingInterval); } } //get fixed polling interval flag value=this.getConfigurationValue(FaxJobMonitorImpl.FIXED_POLLING_INTERVAL_PROPERTY_KEY); this.fixedPollingInterval=Boolean.parseBoolean(value); //get poller thread priority value=this.getConfigurationValue(FaxJobMonitorImpl.POLLING_THREAD_PRIORITY_PROPERTY_KEY); this.pollingThreadPriority=2; if(value!=null) { this.pollingThreadPriority=Integer.parseInt(value); if((this.pollingThreadPriority<Thread.MIN_PRIORITY)||(this.pollingThreadPriority>Thread.MAX_PRIORITY)) { throw new FaxException("Polling thread priority set to an invalid value: "+this.pollingThreadPriority); } } //create poller task this.pollerTask=new PollerTask(this); }
java
@Override protected void initializeImpl() { //init data structures this.data=new HashMap<FaxClientSpi,Map<FaxJob,FaxJobStatus>>(20); //get polling interval String value=this.getConfigurationValue(FaxJobMonitorImpl.POLLING_INTERVAL_IN_MILLIES_PROPERTY_KEY); this.pollingInterval=5000; if(value!=null) { this.pollingInterval=Long.parseLong(value); if(this.pollingInterval<=0) { throw new FaxException("Polling interval set to an invalid value: "+this.pollingInterval); } } //get fixed polling interval flag value=this.getConfigurationValue(FaxJobMonitorImpl.FIXED_POLLING_INTERVAL_PROPERTY_KEY); this.fixedPollingInterval=Boolean.parseBoolean(value); //get poller thread priority value=this.getConfigurationValue(FaxJobMonitorImpl.POLLING_THREAD_PRIORITY_PROPERTY_KEY); this.pollingThreadPriority=2; if(value!=null) { this.pollingThreadPriority=Integer.parseInt(value); if((this.pollingThreadPriority<Thread.MIN_PRIORITY)||(this.pollingThreadPriority>Thread.MAX_PRIORITY)) { throw new FaxException("Polling thread priority set to an invalid value: "+this.pollingThreadPriority); } } //create poller task this.pollerTask=new PollerTask(this); }
[ "@", "Override", "protected", "void", "initializeImpl", "(", ")", "{", "//init data structures", "this", ".", "data", "=", "new", "HashMap", "<", "FaxClientSpi", ",", "Map", "<", "FaxJob", ",", "FaxJobStatus", ">", ">", "(", "20", ")", ";", "//get polling in...
This function initializes the fax job monitor.
[ "This", "function", "initializes", "the", "fax", "job", "monitor", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/FaxJobMonitorImpl.java#L55-L91
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/FaxJobMonitorImpl.java
FaxJobMonitorImpl.runPollingCycle
protected void runPollingCycle() { synchronized(this.LOCK) { Set<Entry<FaxClientSpi,Map<FaxJob,FaxJobStatus>>> entrySet=this.data.entrySet(); Iterator<Entry<FaxClientSpi,Map<FaxJob,FaxJobStatus>>> faxClientSpiIterator=entrySet.iterator(); Entry<FaxClientSpi,Map<FaxJob,FaxJobStatus>> faxClientSpiEntry=null; FaxClientSpi faxClientSpi=null; Map<FaxJob,FaxJobStatus> faxJobMap=null; Iterator<Entry<FaxJob,FaxJobStatus>> faxJobIterator=null; Entry<FaxJob,FaxJobStatus> faxJobEntry=null; FaxJob[] faxJobs=null; FaxJobStatus[] previousFaxJobStatuses=null; FaxJobStatus[] currentFaxJobStatuses=null; FaxJob faxJob=null; FaxJobStatus previousFaxJobStatus=null; FaxJobStatus currentFaxJobStatus=null; int counter=0; while(faxClientSpiIterator.hasNext()) { //get next entry faxClientSpiEntry=faxClientSpiIterator.next(); //get values faxClientSpi=faxClientSpiEntry.getKey(); faxJobMap=faxClientSpiEntry.getValue(); //get iterator faxJobIterator=faxJobMap.entrySet().iterator(); int amount=faxJobMap.size(); if(amount>0) { //init arrays faxJobs=new FaxJob[amount]; previousFaxJobStatuses=new FaxJobStatus[amount]; counter=0; while(faxJobIterator.hasNext()) { //get next entry faxJobEntry=faxJobIterator.next(); //get values faxJob=faxJobEntry.getKey(); previousFaxJobStatus=faxJobEntry.getValue(); //put in array faxJobs[counter]=faxJob; previousFaxJobStatuses[counter]=previousFaxJobStatus; counter++; } //poll for changes currentFaxJobStatuses=faxClientSpi.pollForFaxJobStatues(faxJobs); if((currentFaxJobStatuses!=null)&&(currentFaxJobStatuses.length==amount)) { for(int index=0;index<amount;index++) { //get current fax job status currentFaxJobStatus=currentFaxJobStatuses[index]; if(currentFaxJobStatus!=null) { //get values faxJob=faxJobs[index]; previousFaxJobStatus=previousFaxJobStatuses[index]; //if status was changed if(!previousFaxJobStatus.equals(currentFaxJobStatus)) { //update data structure faxJobMap.put(faxJob,currentFaxJobStatus); //fire event faxClientSpi.fireFaxMonitorEvent(FaxMonitorEventID.FAX_JOB_STATUS_CHANGE,faxJob,currentFaxJobStatus); } //if status is unknown or error, stop monitoring fax job switch(currentFaxJobStatus) { case UNKNOWN: case ERROR: faxJobMap.remove(faxJob); break; case IN_PROGRESS: case PENDING: default: //do nothing break; } } } } } if(faxJobMap.isEmpty()) { faxClientSpiIterator.remove(); } } } //check if need to stop the monitor this.checkAndStopMonitor(); }
java
protected void runPollingCycle() { synchronized(this.LOCK) { Set<Entry<FaxClientSpi,Map<FaxJob,FaxJobStatus>>> entrySet=this.data.entrySet(); Iterator<Entry<FaxClientSpi,Map<FaxJob,FaxJobStatus>>> faxClientSpiIterator=entrySet.iterator(); Entry<FaxClientSpi,Map<FaxJob,FaxJobStatus>> faxClientSpiEntry=null; FaxClientSpi faxClientSpi=null; Map<FaxJob,FaxJobStatus> faxJobMap=null; Iterator<Entry<FaxJob,FaxJobStatus>> faxJobIterator=null; Entry<FaxJob,FaxJobStatus> faxJobEntry=null; FaxJob[] faxJobs=null; FaxJobStatus[] previousFaxJobStatuses=null; FaxJobStatus[] currentFaxJobStatuses=null; FaxJob faxJob=null; FaxJobStatus previousFaxJobStatus=null; FaxJobStatus currentFaxJobStatus=null; int counter=0; while(faxClientSpiIterator.hasNext()) { //get next entry faxClientSpiEntry=faxClientSpiIterator.next(); //get values faxClientSpi=faxClientSpiEntry.getKey(); faxJobMap=faxClientSpiEntry.getValue(); //get iterator faxJobIterator=faxJobMap.entrySet().iterator(); int amount=faxJobMap.size(); if(amount>0) { //init arrays faxJobs=new FaxJob[amount]; previousFaxJobStatuses=new FaxJobStatus[amount]; counter=0; while(faxJobIterator.hasNext()) { //get next entry faxJobEntry=faxJobIterator.next(); //get values faxJob=faxJobEntry.getKey(); previousFaxJobStatus=faxJobEntry.getValue(); //put in array faxJobs[counter]=faxJob; previousFaxJobStatuses[counter]=previousFaxJobStatus; counter++; } //poll for changes currentFaxJobStatuses=faxClientSpi.pollForFaxJobStatues(faxJobs); if((currentFaxJobStatuses!=null)&&(currentFaxJobStatuses.length==amount)) { for(int index=0;index<amount;index++) { //get current fax job status currentFaxJobStatus=currentFaxJobStatuses[index]; if(currentFaxJobStatus!=null) { //get values faxJob=faxJobs[index]; previousFaxJobStatus=previousFaxJobStatuses[index]; //if status was changed if(!previousFaxJobStatus.equals(currentFaxJobStatus)) { //update data structure faxJobMap.put(faxJob,currentFaxJobStatus); //fire event faxClientSpi.fireFaxMonitorEvent(FaxMonitorEventID.FAX_JOB_STATUS_CHANGE,faxJob,currentFaxJobStatus); } //if status is unknown or error, stop monitoring fax job switch(currentFaxJobStatus) { case UNKNOWN: case ERROR: faxJobMap.remove(faxJob); break; case IN_PROGRESS: case PENDING: default: //do nothing break; } } } } } if(faxJobMap.isEmpty()) { faxClientSpiIterator.remove(); } } } //check if need to stop the monitor this.checkAndStopMonitor(); }
[ "protected", "void", "runPollingCycle", "(", ")", "{", "synchronized", "(", "this", ".", "LOCK", ")", "{", "Set", "<", "Entry", "<", "FaxClientSpi", ",", "Map", "<", "FaxJob", ",", "FaxJobStatus", ">", ">", ">", "entrySet", "=", "this", ".", "data", "....
Runs the polling cycle to fetch and create monitor events.
[ "Runs", "the", "polling", "cycle", "to", "fetch", "and", "create", "monitor", "events", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/FaxJobMonitorImpl.java#L154-L260
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/AbstractFaxJobMonitor.java
AbstractFaxJobMonitor.getConfigurationValue
protected final String getConfigurationValue(String key) { //get value String value=this.monitorConfiguration.get(key); //trim value if(value!=null) { value=value.trim(); //set as null if empty string if(value.length()==0) { value=null; } } this.monitorLogger.logDebug(new Object[]{"Extracted configuration for key: ",key," value: ",value},null); return value; }
java
protected final String getConfigurationValue(String key) { //get value String value=this.monitorConfiguration.get(key); //trim value if(value!=null) { value=value.trim(); //set as null if empty string if(value.length()==0) { value=null; } } this.monitorLogger.logDebug(new Object[]{"Extracted configuration for key: ",key," value: ",value},null); return value; }
[ "protected", "final", "String", "getConfigurationValue", "(", "String", "key", ")", "{", "//get value", "String", "value", "=", "this", ".", "monitorConfiguration", ".", "get", "(", "key", ")", ";", "//trim value", "if", "(", "value", "!=", "null", ")", "{",...
Returns the value from the monitor configuration based on the provided configuration key. @param key The configuration key @return The value
[ "Returns", "the", "value", "from", "the", "monitor", "configuration", "based", "on", "the", "provided", "configuration", "key", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/AbstractFaxJobMonitor.java#L85-L105
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/windows/WindowsFaxClientSpiHelper.java
WindowsFaxClientSpiHelper.loadNativeLibrary
public static void loadNativeLibrary(Logger logger) { synchronized(WindowsFaxClientSpiHelper.NATIVE_LOCK) { if(!WindowsFaxClientSpiHelper.nativeLibraryLoaded) { try { //get temporary directory File directory=IOHelper.getFax4jInternalTemporaryDirectory(); //get dll path File dllFile=new File(directory,"fax4j.dll"); //get path String path=dllFile.getPath(); //load native library System.load(path); logger.logDebug(new Object[]{"Loaded native library runtime path."},null); //set flag WindowsFaxClientSpiHelper.nativeLibraryLoaded=true; } catch(Throwable throwable) { logger.logError(new Object[]{"Error while loading native library from runtime path."},throwable); } if(!WindowsFaxClientSpiHelper.nativeLibraryLoaded) { try { //load native library System.loadLibrary("fax4j"); logger.logDebug(new Object[]{"Loaded native library from native path."},null); //set flag WindowsFaxClientSpiHelper.nativeLibraryLoaded=true; } catch(Throwable throwable) { logger.logError(new Object[]{"Error while loading native library from native path."},throwable); } } } } }
java
public static void loadNativeLibrary(Logger logger) { synchronized(WindowsFaxClientSpiHelper.NATIVE_LOCK) { if(!WindowsFaxClientSpiHelper.nativeLibraryLoaded) { try { //get temporary directory File directory=IOHelper.getFax4jInternalTemporaryDirectory(); //get dll path File dllFile=new File(directory,"fax4j.dll"); //get path String path=dllFile.getPath(); //load native library System.load(path); logger.logDebug(new Object[]{"Loaded native library runtime path."},null); //set flag WindowsFaxClientSpiHelper.nativeLibraryLoaded=true; } catch(Throwable throwable) { logger.logError(new Object[]{"Error while loading native library from runtime path."},throwable); } if(!WindowsFaxClientSpiHelper.nativeLibraryLoaded) { try { //load native library System.loadLibrary("fax4j"); logger.logDebug(new Object[]{"Loaded native library from native path."},null); //set flag WindowsFaxClientSpiHelper.nativeLibraryLoaded=true; } catch(Throwable throwable) { logger.logError(new Object[]{"Error while loading native library from native path."},throwable); } } } } }
[ "public", "static", "void", "loadNativeLibrary", "(", "Logger", "logger", ")", "{", "synchronized", "(", "WindowsFaxClientSpiHelper", ".", "NATIVE_LOCK", ")", "{", "if", "(", "!", "WindowsFaxClientSpiHelper", ".", "nativeLibraryLoaded", ")", "{", "try", "{", "//ge...
Loads the native library if not loaded before. @param logger The logger
[ "Loads", "the", "native", "library", "if", "not", "loaded", "before", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/windows/WindowsFaxClientSpiHelper.java#L95-L142
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/windows/WindowsFaxClientSpiHelper.java
WindowsFaxClientSpiHelper.getServerNameFromConfiguration
public static String getServerNameFromConfiguration(FaxClientSpi faxClientSpi) { //get logger Logger logger=faxClientSpi.getLogger(); //get fax server name String faxServerName=faxClientSpi.getConfigurationValue(FaxClientSpiConfigurationConstants.FAX_SERVER_NAME_PROPERTY_KEY); logger.logDebug(new Object[]{"Fax server name: ",faxServerName},null); return faxServerName; }
java
public static String getServerNameFromConfiguration(FaxClientSpi faxClientSpi) { //get logger Logger logger=faxClientSpi.getLogger(); //get fax server name String faxServerName=faxClientSpi.getConfigurationValue(FaxClientSpiConfigurationConstants.FAX_SERVER_NAME_PROPERTY_KEY); logger.logDebug(new Object[]{"Fax server name: ",faxServerName},null); return faxServerName; }
[ "public", "static", "String", "getServerNameFromConfiguration", "(", "FaxClientSpi", "faxClientSpi", ")", "{", "//get logger", "Logger", "logger", "=", "faxClientSpi", ".", "getLogger", "(", ")", ";", "//get fax server name", "String", "faxServerName", "=", "faxClientSp...
This function returns the server name from the SPI configuration. @param faxClientSpi The fax client SPI @return The server name
[ "This", "function", "returns", "the", "server", "name", "from", "the", "SPI", "configuration", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/windows/WindowsFaxClientSpiHelper.java#L161-L171
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/windows/WindowsFaxClientSpiHelper.java
WindowsFaxClientSpiHelper.getOutputPart
public static String getOutputPart(ProcessOutput processOutput,String prefix) { //get output String output=processOutput.getOutputText(); if(output!=null) { //set flag boolean validOutput=false; int index=output.indexOf(prefix); if(index!=-1) { //get index index=index+prefix.length(); if(output.length()>index) { //get output output=output.substring(index); output=output.trim(); index=output.indexOf("\n"); if(index!=-1) { output=output.substring(0,index); output=output.trim(); } if(output.length()>0) { //set flag validOutput=true; } } } if(!validOutput) { output=null; } } return output; }
java
public static String getOutputPart(ProcessOutput processOutput,String prefix) { //get output String output=processOutput.getOutputText(); if(output!=null) { //set flag boolean validOutput=false; int index=output.indexOf(prefix); if(index!=-1) { //get index index=index+prefix.length(); if(output.length()>index) { //get output output=output.substring(index); output=output.trim(); index=output.indexOf("\n"); if(index!=-1) { output=output.substring(0,index); output=output.trim(); } if(output.length()>0) { //set flag validOutput=true; } } } if(!validOutput) { output=null; } } return output; }
[ "public", "static", "String", "getOutputPart", "(", "ProcessOutput", "processOutput", ",", "String", "prefix", ")", "{", "//get output", "String", "output", "=", "processOutput", ".", "getOutputText", "(", ")", ";", "if", "(", "output", "!=", "null", ")", "{",...
This function returns the relevant part from the process output. @param processOutput The process output @param prefix The prefix to look for in the output @return The relevant output part
[ "This", "function", "returns", "the", "relevant", "part", "from", "the", "process", "output", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/windows/WindowsFaxClientSpiHelper.java#L282-L326
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/comm/RXTXCommPortAdapter.java
RXTXCommPortAdapter.getInputStream
public InputStream getInputStream() { InputStream stream=null; try { stream=this.commPort.getInputStream(); } catch(IOException exception) { throw new FaxException("Unable to extract input stream.",exception); } return stream; }
java
public InputStream getInputStream() { InputStream stream=null; try { stream=this.commPort.getInputStream(); } catch(IOException exception) { throw new FaxException("Unable to extract input stream.",exception); } return stream; }
[ "public", "InputStream", "getInputStream", "(", ")", "{", "InputStream", "stream", "=", "null", ";", "try", "{", "stream", "=", "this", ".", "commPort", ".", "getInputStream", "(", ")", ";", "}", "catch", "(", "IOException", "exception", ")", "{", "throw",...
This function returns the input stream to the COMM port. @return The input stream
[ "This", "function", "returns", "the", "input", "stream", "to", "the", "COMM", "port", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/comm/RXTXCommPortAdapter.java#L61-L74
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/comm/RXTXCommPortAdapter.java
RXTXCommPortAdapter.getOutputStream
public OutputStream getOutputStream() { OutputStream stream=null; try { stream=this.commPort.getOutputStream(); } catch(IOException exception) { throw new FaxException("Unable to extract output stream.",exception); } return stream; }
java
public OutputStream getOutputStream() { OutputStream stream=null; try { stream=this.commPort.getOutputStream(); } catch(IOException exception) { throw new FaxException("Unable to extract output stream.",exception); } return stream; }
[ "public", "OutputStream", "getOutputStream", "(", ")", "{", "OutputStream", "stream", "=", "null", ";", "try", "{", "stream", "=", "this", ".", "commPort", ".", "getOutputStream", "(", ")", ";", "}", "catch", "(", "IOException", "exception", ")", "{", "thr...
This function returns the output stream to the COMM port. @return The output stream
[ "This", "function", "returns", "the", "output", "stream", "to", "the", "COMM", "port", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/comm/RXTXCommPortAdapter.java#L81-L94
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/FaxClientSpiFactory.java
FaxClientSpiFactory.getLogger
private static Logger getLogger() { if(FaxClientSpiFactory.logger==null) { synchronized(FaxClientSpiFactory.class) { if(FaxClientSpiFactory.logger==null) { //get logger manager LoggerManager loggerManager=LoggerManager.getInstance(); //get logger Logger localLogger=loggerManager.getLogger(); //print product info localLogger.logDebug(new Object[]{ProductInfo.getProductInfoPrintout()},null); //keep reference FaxClientSpiFactory.logger=localLogger; } } } return FaxClientSpiFactory.logger; }
java
private static Logger getLogger() { if(FaxClientSpiFactory.logger==null) { synchronized(FaxClientSpiFactory.class) { if(FaxClientSpiFactory.logger==null) { //get logger manager LoggerManager loggerManager=LoggerManager.getInstance(); //get logger Logger localLogger=loggerManager.getLogger(); //print product info localLogger.logDebug(new Object[]{ProductInfo.getProductInfoPrintout()},null); //keep reference FaxClientSpiFactory.logger=localLogger; } } } return FaxClientSpiFactory.logger; }
[ "private", "static", "Logger", "getLogger", "(", ")", "{", "if", "(", "FaxClientSpiFactory", ".", "logger", "==", "null", ")", "{", "synchronized", "(", "FaxClientSpiFactory", ".", "class", ")", "{", "if", "(", "FaxClientSpiFactory", ".", "logger", "==", "nu...
This function returns the internal logger for the fax4j framework. @return The logger
[ "This", "function", "returns", "the", "internal", "logger", "for", "the", "fax4j", "framework", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/FaxClientSpiFactory.java#L347-L371
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/FaxClientSpiFactory.java
FaxClientSpiFactory.getFaxJobMonitor
private static FaxJobMonitor getFaxJobMonitor() { //get system configuration Map<String,String> systemConfig=LibraryConfigurationLoader.getSystemConfiguration(); if(FaxClientSpiFactory.faxJobMonitor==null) { synchronized(FaxClientSpiFactory.class) { if(FaxClientSpiFactory.faxJobMonitor==null) { //create fax job monitor FaxJobMonitor localFaxJobMonitor=FaxClientSpiFactory.createFaxJobMonitor(systemConfig); //get logger Logger localLogger=FaxClientSpiFactory.getLogger(); //initialize localFaxJobMonitor.initialize(systemConfig,localLogger); //keep reference FaxClientSpiFactory.faxJobMonitor=localFaxJobMonitor; } } } return FaxClientSpiFactory.faxJobMonitor; }
java
private static FaxJobMonitor getFaxJobMonitor() { //get system configuration Map<String,String> systemConfig=LibraryConfigurationLoader.getSystemConfiguration(); if(FaxClientSpiFactory.faxJobMonitor==null) { synchronized(FaxClientSpiFactory.class) { if(FaxClientSpiFactory.faxJobMonitor==null) { //create fax job monitor FaxJobMonitor localFaxJobMonitor=FaxClientSpiFactory.createFaxJobMonitor(systemConfig); //get logger Logger localLogger=FaxClientSpiFactory.getLogger(); //initialize localFaxJobMonitor.initialize(systemConfig,localLogger); //keep reference FaxClientSpiFactory.faxJobMonitor=localFaxJobMonitor; } } } return FaxClientSpiFactory.faxJobMonitor; }
[ "private", "static", "FaxJobMonitor", "getFaxJobMonitor", "(", ")", "{", "//get system configuration", "Map", "<", "String", ",", "String", ">", "systemConfig", "=", "LibraryConfigurationLoader", ".", "getSystemConfiguration", "(", ")", ";", "if", "(", "FaxClientSpiFa...
This function returns the fax job monitor. @return The fax job monitor
[ "This", "function", "returns", "the", "fax", "job", "monitor", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/FaxClientSpiFactory.java#L378-L405
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/FaxClientSpiFactory.java
FaxClientSpiFactory.createFaxJobMonitor
private static FaxJobMonitor createFaxJobMonitor(Map<String,String> systemConfig) { //get class name String className=systemConfig.get(FaxClientSpiFactory.FAX_JOB_MONITOR_CLASS_NAME_PROPERTY_KEY); if((className==null)||(className.length()==0)) { className=FaxJobMonitorImpl.class.getName(); } //create new instance FaxJobMonitor faxJobMonitorInstance=(FaxJobMonitor)ReflectionHelper.createInstance(className); return faxJobMonitorInstance; }
java
private static FaxJobMonitor createFaxJobMonitor(Map<String,String> systemConfig) { //get class name String className=systemConfig.get(FaxClientSpiFactory.FAX_JOB_MONITOR_CLASS_NAME_PROPERTY_KEY); if((className==null)||(className.length()==0)) { className=FaxJobMonitorImpl.class.getName(); } //create new instance FaxJobMonitor faxJobMonitorInstance=(FaxJobMonitor)ReflectionHelper.createInstance(className); return faxJobMonitorInstance; }
[ "private", "static", "FaxJobMonitor", "createFaxJobMonitor", "(", "Map", "<", "String", ",", "String", ">", "systemConfig", ")", "{", "//get class name", "String", "className", "=", "systemConfig", ".", "get", "(", "FaxClientSpiFactory", ".", "FAX_JOB_MONITOR_CLASS_NA...
This function creates the fax job monitor used by the fax4j framework. @param systemConfig The system configuration @return The logger
[ "This", "function", "creates", "the", "fax", "job", "monitor", "used", "by", "the", "fax4j", "framework", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/FaxClientSpiFactory.java#L414-L427
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/FaxClientSpiFactory.java
FaxClientSpiFactory.createFaxClientSpiProxy
private static FaxClientSpiProxy createFaxClientSpiProxy(FaxClientSpi faxClientSpi) { //create fax client SPI interceptors FaxClientSpiInterceptor[] interceptors=FaxClientSpiFactory.createFaxClientSpiInterceptors(faxClientSpi); //get class name String className=faxClientSpi.getConfigurationValue(FaxClientSpiFactory.SPI_PROXY_CLASS_NAME_PROPERTY_KEY); if(className==null) { className=FaxClientSpiProxyImpl.class.getName(); } //create new instance FaxClientSpiProxy faxClientSpiProxy=(FaxClientSpiProxy)ReflectionHelper.createInstance(className); //initialize faxClientSpiProxy.initialize(faxClientSpi,interceptors); return faxClientSpiProxy; }
java
private static FaxClientSpiProxy createFaxClientSpiProxy(FaxClientSpi faxClientSpi) { //create fax client SPI interceptors FaxClientSpiInterceptor[] interceptors=FaxClientSpiFactory.createFaxClientSpiInterceptors(faxClientSpi); //get class name String className=faxClientSpi.getConfigurationValue(FaxClientSpiFactory.SPI_PROXY_CLASS_NAME_PROPERTY_KEY); if(className==null) { className=FaxClientSpiProxyImpl.class.getName(); } //create new instance FaxClientSpiProxy faxClientSpiProxy=(FaxClientSpiProxy)ReflectionHelper.createInstance(className); //initialize faxClientSpiProxy.initialize(faxClientSpi,interceptors); return faxClientSpiProxy; }
[ "private", "static", "FaxClientSpiProxy", "createFaxClientSpiProxy", "(", "FaxClientSpi", "faxClientSpi", ")", "{", "//create fax client SPI interceptors", "FaxClientSpiInterceptor", "[", "]", "interceptors", "=", "FaxClientSpiFactory", ".", "createFaxClientSpiInterceptors", "(",...
This function creates the fax client SPI proxy. @param faxClientSpi The fax client SPI @return The fax client SPI proxy
[ "This", "function", "creates", "the", "fax", "client", "SPI", "proxy", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/FaxClientSpiFactory.java#L436-L455
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/FaxClientSpiFactory.java
FaxClientSpiFactory.createFaxClientSpiInterceptors
private static FaxClientSpiInterceptor[] createFaxClientSpiInterceptors(FaxClientSpi faxClientSpi) { //get type list String typeListStr=faxClientSpi.getConfigurationValue(FaxClientSpiFactory.SPI_INTERCEPTOR_LIST_PROPERTY_KEY); FaxClientSpiInterceptor[] interceptors=null; if(typeListStr!=null) { //split list String[] types=typeListStr.split(FaxClientSpiFactory.SPI_INTERCEPTOR_LIST_SEPARATOR); //get amount int amount=types.length; String type=null; String propertyKey=null; String className=null; FaxClientSpiInterceptor interceptor=null; List<FaxClientSpiInterceptor> interceptorList=new LinkedList<FaxClientSpiInterceptor>(); for(int index=0;index<amount;index++) { //get next type type=types[index]; if((type!=null)&&(type.length()>0)) { //get property key propertyKey=FaxClientSpiFactory.SPI_INTERCEPTOR_TYPE_PROPERTY_KEY_PREFIX+type; //get class name className=faxClientSpi.getConfigurationValue(propertyKey); if(className==null) { throw new FaxException("Class name not defined by property: "+propertyKey+" for SPI interceptor."); } //create new instance interceptor=(FaxClientSpiInterceptor)ReflectionHelper.createInstance(className); //initialize interceptor.initialize(faxClientSpi); //add to list interceptorList.add(interceptor); } //convert to array interceptors=interceptorList.toArray(new FaxClientSpiInterceptor[interceptorList.size()]); } } return interceptors; }
java
private static FaxClientSpiInterceptor[] createFaxClientSpiInterceptors(FaxClientSpi faxClientSpi) { //get type list String typeListStr=faxClientSpi.getConfigurationValue(FaxClientSpiFactory.SPI_INTERCEPTOR_LIST_PROPERTY_KEY); FaxClientSpiInterceptor[] interceptors=null; if(typeListStr!=null) { //split list String[] types=typeListStr.split(FaxClientSpiFactory.SPI_INTERCEPTOR_LIST_SEPARATOR); //get amount int amount=types.length; String type=null; String propertyKey=null; String className=null; FaxClientSpiInterceptor interceptor=null; List<FaxClientSpiInterceptor> interceptorList=new LinkedList<FaxClientSpiInterceptor>(); for(int index=0;index<amount;index++) { //get next type type=types[index]; if((type!=null)&&(type.length()>0)) { //get property key propertyKey=FaxClientSpiFactory.SPI_INTERCEPTOR_TYPE_PROPERTY_KEY_PREFIX+type; //get class name className=faxClientSpi.getConfigurationValue(propertyKey); if(className==null) { throw new FaxException("Class name not defined by property: "+propertyKey+" for SPI interceptor."); } //create new instance interceptor=(FaxClientSpiInterceptor)ReflectionHelper.createInstance(className); //initialize interceptor.initialize(faxClientSpi); //add to list interceptorList.add(interceptor); } //convert to array interceptors=interceptorList.toArray(new FaxClientSpiInterceptor[interceptorList.size()]); } } return interceptors; }
[ "private", "static", "FaxClientSpiInterceptor", "[", "]", "createFaxClientSpiInterceptors", "(", "FaxClientSpi", "faxClientSpi", ")", "{", "//get type list", "String", "typeListStr", "=", "faxClientSpi", ".", "getConfigurationValue", "(", "FaxClientSpiFactory", ".", "SPI_IN...
This function creates the fax client SPI interceptors. @param faxClientSpi The fax client SPI @return The interceptors
[ "This", "function", "creates", "the", "fax", "client", "SPI", "interceptors", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/FaxClientSpiFactory.java#L464-L516
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/windows/WindowsJNIFaxClientSpi.java
WindowsJNIFaxClientSpi.preNativeCall
protected void preNativeCall() { //get logger Logger logger=this.getLogger(); //get log level LogLevel logLevel=logger.getLogLevel(); boolean debugMode=false; if(logLevel.equals(LogLevel.DEBUG)) { debugMode=true; } //set debug mode WindowsJNIFaxClientSpi.setDebugModeNative(debugMode); }
java
protected void preNativeCall() { //get logger Logger logger=this.getLogger(); //get log level LogLevel logLevel=logger.getLogLevel(); boolean debugMode=false; if(logLevel.equals(LogLevel.DEBUG)) { debugMode=true; } //set debug mode WindowsJNIFaxClientSpi.setDebugModeNative(debugMode); }
[ "protected", "void", "preNativeCall", "(", ")", "{", "//get logger", "Logger", "logger", "=", "this", ".", "getLogger", "(", ")", ";", "//get log level", "LogLevel", "logLevel", "=", "logger", ".", "getLogLevel", "(", ")", ";", "boolean", "debugMode", "=", "...
This function is invoked before any native call to set the native layer debug mode.
[ "This", "function", "is", "invoked", "before", "any", "native", "call", "to", "set", "the", "native", "layer", "debug", "mode", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/windows/WindowsJNIFaxClientSpi.java#L110-L126
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/windows/WindowsJNIFaxClientSpi.java
WindowsJNIFaxClientSpi.winGetFaxJobStatus
private String winGetFaxJobStatus(String serverName,int faxJobID) { String status=null; synchronized(WindowsFaxClientSpiHelper.NATIVE_LOCK) { //pre native call this.preNativeCall(); //invoke native status=WindowsJNIFaxClientSpi.getFaxJobStatusNative(serverName,faxJobID); } return status; }
java
private String winGetFaxJobStatus(String serverName,int faxJobID) { String status=null; synchronized(WindowsFaxClientSpiHelper.NATIVE_LOCK) { //pre native call this.preNativeCall(); //invoke native status=WindowsJNIFaxClientSpi.getFaxJobStatusNative(serverName,faxJobID); } return status; }
[ "private", "String", "winGetFaxJobStatus", "(", "String", "serverName", ",", "int", "faxJobID", ")", "{", "String", "status", "=", "null", ";", "synchronized", "(", "WindowsFaxClientSpiHelper", ".", "NATIVE_LOCK", ")", "{", "//pre native call", "this", ".", "preNa...
This function returns the fax job status. @param serverName The fax server name @param faxJobID The fax job ID @return The fax job status
[ "This", "function", "returns", "the", "fax", "job", "status", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/windows/WindowsJNIFaxClientSpi.java#L349-L362
train
sagiegurari/fax4j
src/main/java/org/fax4j/bridge/http/MultiPartHTTPRequestParser.java
MultiPartHTTPRequestParser.getContentPartAsString
protected String getContentPartAsString(Map<String,ContentPart<?>> contentPartsMap,String parameter) { //get part String stringValue=null; ContentPart<?> contentPart=contentPartsMap.get(parameter); if(contentPart!=null) { ContentPartType contentPartType=contentPart.getType(); Object content=contentPart.getContent(); if(content!=null) { switch(contentPartType) { case STRING: stringValue=(String)content; break; case BINARY: byte[] data=(byte[])content; String encoding=IOHelper.getDefaultEncoding(); try { stringValue=new String(data,encoding); } catch(UnsupportedEncodingException exception) { throw new FaxException("Unable to convert binary data to string for parameter: "+parameter,exception); } break; default: throw new FaxException("Unsupported content part type: "+contentPartType); } } } return stringValue; }
java
protected String getContentPartAsString(Map<String,ContentPart<?>> contentPartsMap,String parameter) { //get part String stringValue=null; ContentPart<?> contentPart=contentPartsMap.get(parameter); if(contentPart!=null) { ContentPartType contentPartType=contentPart.getType(); Object content=contentPart.getContent(); if(content!=null) { switch(contentPartType) { case STRING: stringValue=(String)content; break; case BINARY: byte[] data=(byte[])content; String encoding=IOHelper.getDefaultEncoding(); try { stringValue=new String(data,encoding); } catch(UnsupportedEncodingException exception) { throw new FaxException("Unable to convert binary data to string for parameter: "+parameter,exception); } break; default: throw new FaxException("Unsupported content part type: "+contentPartType); } } } return stringValue; }
[ "protected", "String", "getContentPartAsString", "(", "Map", "<", "String", ",", "ContentPart", "<", "?", ">", ">", "contentPartsMap", ",", "String", "parameter", ")", "{", "//get part", "String", "stringValue", "=", "null", ";", "ContentPart", "<", "?", ">", ...
This function returns the content part string value. @param contentPartsMap The content parts map @param parameter The part parameter name @return The part string value
[ "This", "function", "returns", "the", "content", "part", "string", "value", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/http/MultiPartHTTPRequestParser.java#L340-L375
train
sagiegurari/fax4j
src/main/java/org/fax4j/bridge/http/MultiPartHTTPRequestParser.java
MultiPartHTTPRequestParser.getContentPartsAsMap
protected Map<String,ContentPart<?>> getContentPartsAsMap(HTTPRequest httpRequest) { Map<String,ContentPart<?>> contentPartsMap=null; ContentType contentType=httpRequest.getContentType(); switch(contentType) { case MULTI_PART: //init map contentPartsMap=new HashMap<String,HTTPRequest.ContentPart<?>>(); //get parts ContentPart<?>[] contentParts=httpRequest.getContentAsParts(); int amount=contentParts.length; ContentPart<?> contentPart=null; String partName=null; for(int index=0;index<amount;index++) { //get next part contentPart=contentParts[index]; //get part name partName=contentPart.getName(); //put in map contentPartsMap.put(partName,contentPart); } break; default: throw new FaxException("Unsupported content type: "+contentType); } return contentPartsMap; }
java
protected Map<String,ContentPart<?>> getContentPartsAsMap(HTTPRequest httpRequest) { Map<String,ContentPart<?>> contentPartsMap=null; ContentType contentType=httpRequest.getContentType(); switch(contentType) { case MULTI_PART: //init map contentPartsMap=new HashMap<String,HTTPRequest.ContentPart<?>>(); //get parts ContentPart<?>[] contentParts=httpRequest.getContentAsParts(); int amount=contentParts.length; ContentPart<?> contentPart=null; String partName=null; for(int index=0;index<amount;index++) { //get next part contentPart=contentParts[index]; //get part name partName=contentPart.getName(); //put in map contentPartsMap.put(partName,contentPart); } break; default: throw new FaxException("Unsupported content type: "+contentType); } return contentPartsMap; }
[ "protected", "Map", "<", "String", ",", "ContentPart", "<", "?", ">", ">", "getContentPartsAsMap", "(", "HTTPRequest", "httpRequest", ")", "{", "Map", "<", "String", ",", "ContentPart", "<", "?", ">", ">", "contentPartsMap", "=", "null", ";", "ContentType", ...
This function returns the HTTP request multi parts as map. @param httpRequest The HTTP request @return The HTTP request multi parts as map
[ "This", "function", "returns", "the", "HTTP", "request", "multi", "parts", "as", "map", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/http/MultiPartHTTPRequestParser.java#L384-L416
train
sagiegurari/fax4j
src/main/java/org/fax4j/ProductInfo.java
ProductInfo.getProductInfoPrintout
public static String getProductInfoPrintout() { //read properties Properties properties=LibraryConfigurationLoader.readInternalConfiguration(); //get values String name=properties.getProperty("org.fax4j.product.name"); String version=properties.getProperty("org.fax4j.product.version"); //init buffer StringBuilder buffer=new StringBuilder(); buffer.append(name); buffer.append(" library."); buffer.append(Logger.SYSTEM_EOL); buffer.append("Version: "); buffer.append(version); //get text String text=buffer.toString(); return text; }
java
public static String getProductInfoPrintout() { //read properties Properties properties=LibraryConfigurationLoader.readInternalConfiguration(); //get values String name=properties.getProperty("org.fax4j.product.name"); String version=properties.getProperty("org.fax4j.product.version"); //init buffer StringBuilder buffer=new StringBuilder(); buffer.append(name); buffer.append(" library."); buffer.append(Logger.SYSTEM_EOL); buffer.append("Version: "); buffer.append(version); //get text String text=buffer.toString(); return text; }
[ "public", "static", "String", "getProductInfoPrintout", "(", ")", "{", "//read properties", "Properties", "properties", "=", "LibraryConfigurationLoader", ".", "readInternalConfiguration", "(", ")", ";", "//get values", "String", "name", "=", "properties", ".", "getProp...
Returns the product info printout. @return The product info printout
[ "Returns", "the", "product", "info", "printout", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/ProductInfo.java#L58-L79
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/DefaultProcessExecutor.java
DefaultProcessExecutor.parseCommand
protected List<String> parseCommand(ConfigurationHolder configurationHolder,String command) { //init list List<String> commandList=new LinkedList<String>(); StringBuilder buffer=new StringBuilder(command); String part=null; int quoteIndex=-1; int spaceIndex=-1; int length=-1; do { quoteIndex=buffer.indexOf("\""); spaceIndex=buffer.indexOf(" "); if(quoteIndex==-1) { if(spaceIndex==-1) { buffer=this.addAllBuffer(commandList,buffer); } else { buffer=this.addPart(commandList,buffer,spaceIndex,true); } } else if(spaceIndex==-1) { if(quoteIndex==-1) { buffer=this.addAllBuffer(commandList,buffer); } else if(quoteIndex==0) { quoteIndex=buffer.indexOf("\"",1); if(quoteIndex==-1) { throw new FaxException("Unable to parse command: "+command); } buffer=this.addPart(commandList,buffer,quoteIndex,false); } else { throw new FaxException("Unable to parse command: "+command); } } else if(quoteIndex<spaceIndex) { if(quoteIndex==0) { quoteIndex=buffer.indexOf("\"",1); if(quoteIndex==-1) { throw new FaxException("Unable to parse command: "+command); } buffer=this.addPart(commandList,buffer,quoteIndex,false); } else { buffer=this.addPart(commandList,buffer,spaceIndex,true); } } else //spaceIndex<quoteIndex { buffer=this.addPart(commandList,buffer,spaceIndex,true); } length=buffer.length(); if(length>0) { part=buffer.toString(); part=part.trim(); buffer.delete(0,length); buffer.append(part); length=buffer.length(); } }while(length>0); return commandList; }
java
protected List<String> parseCommand(ConfigurationHolder configurationHolder,String command) { //init list List<String> commandList=new LinkedList<String>(); StringBuilder buffer=new StringBuilder(command); String part=null; int quoteIndex=-1; int spaceIndex=-1; int length=-1; do { quoteIndex=buffer.indexOf("\""); spaceIndex=buffer.indexOf(" "); if(quoteIndex==-1) { if(spaceIndex==-1) { buffer=this.addAllBuffer(commandList,buffer); } else { buffer=this.addPart(commandList,buffer,spaceIndex,true); } } else if(spaceIndex==-1) { if(quoteIndex==-1) { buffer=this.addAllBuffer(commandList,buffer); } else if(quoteIndex==0) { quoteIndex=buffer.indexOf("\"",1); if(quoteIndex==-1) { throw new FaxException("Unable to parse command: "+command); } buffer=this.addPart(commandList,buffer,quoteIndex,false); } else { throw new FaxException("Unable to parse command: "+command); } } else if(quoteIndex<spaceIndex) { if(quoteIndex==0) { quoteIndex=buffer.indexOf("\"",1); if(quoteIndex==-1) { throw new FaxException("Unable to parse command: "+command); } buffer=this.addPart(commandList,buffer,quoteIndex,false); } else { buffer=this.addPart(commandList,buffer,spaceIndex,true); } } else //spaceIndex<quoteIndex { buffer=this.addPart(commandList,buffer,spaceIndex,true); } length=buffer.length(); if(length>0) { part=buffer.toString(); part=part.trim(); buffer.delete(0,length); buffer.append(part); length=buffer.length(); } }while(length>0); return commandList; }
[ "protected", "List", "<", "String", ">", "parseCommand", "(", "ConfigurationHolder", "configurationHolder", ",", "String", "command", ")", "{", "//init list", "List", "<", "String", ">", "commandList", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";...
This function parsers the command and converts to a command array. @param configurationHolder The configuration holder used when invoking the process @param command The command to parse @return The parsed command as an array
[ "This", "function", "parsers", "the", "command", "and", "converts", "to", "a", "command", "array", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/DefaultProcessExecutor.java#L83-L163
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/comm/AbstractFaxModemAdapter.java
AbstractFaxModemAdapter.initialize
public void initialize(FaxClientSpi faxClientSpi) { if(this.initialized) { throw new FaxException("Fax Modem Adapter already initialized."); } //set flag this.initialized=true; //get logger Logger logger=faxClientSpi.getLogger(); //log fax client SPI information logger.logDebug(new Object[]{"Initializing fax modem adapter of type: ",this.getClass().getName(),"\nProvider Information:\n",this.getProvider()},null); //initialize this.initializeImpl(faxClientSpi); }
java
public void initialize(FaxClientSpi faxClientSpi) { if(this.initialized) { throw new FaxException("Fax Modem Adapter already initialized."); } //set flag this.initialized=true; //get logger Logger logger=faxClientSpi.getLogger(); //log fax client SPI information logger.logDebug(new Object[]{"Initializing fax modem adapter of type: ",this.getClass().getName(),"\nProvider Information:\n",this.getProvider()},null); //initialize this.initializeImpl(faxClientSpi); }
[ "public", "void", "initialize", "(", "FaxClientSpi", "faxClientSpi", ")", "{", "if", "(", "this", ".", "initialized", ")", "{", "throw", "new", "FaxException", "(", "\"Fax Modem Adapter already initialized.\"", ")", ";", "}", "//set flag", "this", ".", "initialize...
This function initializes the fax modem adapter. @param faxClientSpi The fax client SPI
[ "This", "function", "initializes", "the", "fax", "modem", "adapter", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/comm/AbstractFaxModemAdapter.java#L37-L55
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java
AbstractMailFaxClientSpi.createMailConnectionFactoryImpl
protected final MailConnectionFactory createMailConnectionFactoryImpl(String className) { String factoryClassName=className; if(factoryClassName==null) { factoryClassName=MailConnectionFactoryImpl.class.getName(); } //create new instance MailConnectionFactory factory=(MailConnectionFactory)ReflectionHelper.createInstance(factoryClassName); //initialize factory.initialize(this); return factory; }
java
protected final MailConnectionFactory createMailConnectionFactoryImpl(String className) { String factoryClassName=className; if(factoryClassName==null) { factoryClassName=MailConnectionFactoryImpl.class.getName(); } //create new instance MailConnectionFactory factory=(MailConnectionFactory)ReflectionHelper.createInstance(factoryClassName); //initialize factory.initialize(this); return factory; }
[ "protected", "final", "MailConnectionFactory", "createMailConnectionFactoryImpl", "(", "String", "className", ")", "{", "String", "factoryClassName", "=", "className", ";", "if", "(", "factoryClassName", "==", "null", ")", "{", "factoryClassName", "=", "MailConnectionFa...
Creates and returns the mail connection factory. @param className The connection factory class name @return The mail connection factory
[ "Creates", "and", "returns", "the", "mail", "connection", "factory", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java#L207-L222
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java
AbstractMailFaxClientSpi.createMailConnection
protected Connection<MailResourcesHolder> createMailConnection() { //create new connection Connection<MailResourcesHolder> mailConnection=this.connectionFactory.createConnection(); //log debug Logger logger=this.getLogger(); logger.logInfo(new Object[]{"Created mail connection."},null); return mailConnection; }
java
protected Connection<MailResourcesHolder> createMailConnection() { //create new connection Connection<MailResourcesHolder> mailConnection=this.connectionFactory.createConnection(); //log debug Logger logger=this.getLogger(); logger.logInfo(new Object[]{"Created mail connection."},null); return mailConnection; }
[ "protected", "Connection", "<", "MailResourcesHolder", ">", "createMailConnection", "(", ")", "{", "//create new connection", "Connection", "<", "MailResourcesHolder", ">", "mailConnection", "=", "this", ".", "connectionFactory", ".", "createConnection", "(", ")", ";", ...
Creates and returns the mail connection to be used to send the fax via mail. @return The mail connection
[ "Creates", "and", "returns", "the", "mail", "connection", "to", "be", "used", "to", "send", "the", "fax", "via", "mail", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java#L248-L258
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java
AbstractMailFaxClientSpi.closeMailConnection
protected void closeMailConnection(Connection<MailResourcesHolder> mailConnection) throws IOException { if(mailConnection!=null) { //get logger Logger logger=this.getLogger(); //release connection logger.logInfo(new Object[]{"Closing mail connection."},null); mailConnection.close(); } }
java
protected void closeMailConnection(Connection<MailResourcesHolder> mailConnection) throws IOException { if(mailConnection!=null) { //get logger Logger logger=this.getLogger(); //release connection logger.logInfo(new Object[]{"Closing mail connection."},null); mailConnection.close(); } }
[ "protected", "void", "closeMailConnection", "(", "Connection", "<", "MailResourcesHolder", ">", "mailConnection", ")", "throws", "IOException", "{", "if", "(", "mailConnection", "!=", "null", ")", "{", "//get logger", "Logger", "logger", "=", "this", ".", "getLogg...
This function closes the provided mail connection. @param mailConnection The mail connection to close @throws IOException Never thrown
[ "This", "function", "closes", "the", "provided", "mail", "connection", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java#L268-L279
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java
AbstractMailFaxClientSpi.getMailConnection
protected Connection<MailResourcesHolder> getMailConnection() { Connection<MailResourcesHolder> mailConnection=null; if(this.usePersistentConnection) { synchronized(this) { if(this.connection==null) { //create new connection this.connection=this.createMailConnection(); } } //get connection mailConnection=this.connection; } else { //create new connection mailConnection=this.createMailConnection(); } return mailConnection; }
java
protected Connection<MailResourcesHolder> getMailConnection() { Connection<MailResourcesHolder> mailConnection=null; if(this.usePersistentConnection) { synchronized(this) { if(this.connection==null) { //create new connection this.connection=this.createMailConnection(); } } //get connection mailConnection=this.connection; } else { //create new connection mailConnection=this.createMailConnection(); } return mailConnection; }
[ "protected", "Connection", "<", "MailResourcesHolder", ">", "getMailConnection", "(", ")", "{", "Connection", "<", "MailResourcesHolder", ">", "mailConnection", "=", "null", ";", "if", "(", "this", ".", "usePersistentConnection", ")", "{", "synchronized", "(", "th...
Returns the mail connection to be used to send the fax via mail. @return The mail connection
[ "Returns", "the", "mail", "connection", "to", "be", "used", "to", "send", "the", "fax", "via", "mail", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java#L287-L311
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java
AbstractMailFaxClientSpi.sendMail
protected void sendMail(FaxJob faxJob,Connection<MailResourcesHolder> mailConnection,Message message) { if(message==null) { this.throwUnsupportedException(); } else { //get holder MailResourcesHolder mailResourcesHolder=mailConnection.getResource(); //get transport Transport transport=mailResourcesHolder.getTransport(); try { //send message message.saveChanges(); if(transport==null) { Transport.send(message,message.getAllRecipients()); } else { transport.sendMessage(message,message.getAllRecipients()); } } catch(Throwable throwable) { throw new FaxException("Unable to send message.",throwable); } finally { if(!this.usePersistentConnection) { try { //close connection this.closeMailConnection(mailConnection); } catch(Exception exception) { //log error Logger logger=this.getLogger(); logger.logInfo(new Object[]{"Error while releasing mail connection."},exception); } } } } }
java
protected void sendMail(FaxJob faxJob,Connection<MailResourcesHolder> mailConnection,Message message) { if(message==null) { this.throwUnsupportedException(); } else { //get holder MailResourcesHolder mailResourcesHolder=mailConnection.getResource(); //get transport Transport transport=mailResourcesHolder.getTransport(); try { //send message message.saveChanges(); if(transport==null) { Transport.send(message,message.getAllRecipients()); } else { transport.sendMessage(message,message.getAllRecipients()); } } catch(Throwable throwable) { throw new FaxException("Unable to send message.",throwable); } finally { if(!this.usePersistentConnection) { try { //close connection this.closeMailConnection(mailConnection); } catch(Exception exception) { //log error Logger logger=this.getLogger(); logger.logInfo(new Object[]{"Error while releasing mail connection."},exception); } } } } }
[ "protected", "void", "sendMail", "(", "FaxJob", "faxJob", ",", "Connection", "<", "MailResourcesHolder", ">", "mailConnection", ",", "Message", "message", ")", "{", "if", "(", "message", "==", "null", ")", "{", "this", ".", "throwUnsupportedException", "(", ")...
This function will send the mail message. @param faxJob The fax job object containing the needed information @param mailConnection The mail connection (will be released if not persistent) @param message The message to send
[ "This", "function", "will", "send", "the", "mail", "message", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/email/AbstractMailFaxClientSpi.java#L323-L372
train
sagiegurari/fax4j
src/main/java/org/fax4j/bridge/FaxBridgeImpl.java
FaxBridgeImpl.updateFaxJobWithFileInfo
@Override protected void updateFaxJobWithFileInfo(FaxJob faxJob,FileInfo fileInfo) { //get file File file=fileInfo.getFile(); if(file==null) { //get file name String fileName=fileInfo.getName(); //get file content byte[] content=fileInfo.getContent(); try { //create temporary file file=File.createTempFile("fax_",fileName); //write content to file IOHelper.writeFile(content,file); } catch(IOException exception) { throw new FaxException("Unable to write file content to temporary file.",exception); } } //update fax job faxJob.setFile(file); }
java
@Override protected void updateFaxJobWithFileInfo(FaxJob faxJob,FileInfo fileInfo) { //get file File file=fileInfo.getFile(); if(file==null) { //get file name String fileName=fileInfo.getName(); //get file content byte[] content=fileInfo.getContent(); try { //create temporary file file=File.createTempFile("fax_",fileName); //write content to file IOHelper.writeFile(content,file); } catch(IOException exception) { throw new FaxException("Unable to write file content to temporary file.",exception); } } //update fax job faxJob.setFile(file); }
[ "@", "Override", "protected", "void", "updateFaxJobWithFileInfo", "(", "FaxJob", "faxJob", ",", "FileInfo", "fileInfo", ")", "{", "//get file", "File", "file", "=", "fileInfo", ".", "getFile", "(", ")", ";", "if", "(", "file", "==", "null", ")", "{", "//ge...
This function stores the file in the local machine and updates the fax job with the new file data. @param faxJob The fax job object to be updated @param fileInfo The file information of the requested fax
[ "This", "function", "stores", "the", "file", "in", "the", "local", "machine", "and", "updates", "the", "fax", "job", "with", "the", "new", "file", "data", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/FaxBridgeImpl.java#L85-L115
train
sagiegurari/fax4j
src/main/java/org/fax4j/bridge/http/SimpleHTTPRequestParser.java
SimpleHTTPRequestParser.convertParametersTextToMap
protected Map<String,String> convertParametersTextToMap(HTTPRequest request) { //init data structure Map<String,String> map=new HashMap<String,String>(); //get parameters text String parametersText=request.getParametersText(); if(parametersText!=null) { //split to key/value pairs (key=value) String[] keyValuePairs=parametersText.split("&"); //get amount int pairsAmount=keyValuePairs.length; String keyValuePair=null; String[] parts=null; String key=null; String value=null; for(int index=0;index<pairsAmount;index++) { //get next key/value pair keyValuePair=keyValuePairs[index]; //split to key and value parts=keyValuePair.split("="); if(parts.length==2) { //get key key=parts[0]; if(key.length()>0) { //decode key key=SpiUtil.urlDecode(key); //get value value=parts[1].trim(); //decode value value=SpiUtil.urlDecode(value); //put in data structure map.put(key,value); } } } } return map; }
java
protected Map<String,String> convertParametersTextToMap(HTTPRequest request) { //init data structure Map<String,String> map=new HashMap<String,String>(); //get parameters text String parametersText=request.getParametersText(); if(parametersText!=null) { //split to key/value pairs (key=value) String[] keyValuePairs=parametersText.split("&"); //get amount int pairsAmount=keyValuePairs.length; String keyValuePair=null; String[] parts=null; String key=null; String value=null; for(int index=0;index<pairsAmount;index++) { //get next key/value pair keyValuePair=keyValuePairs[index]; //split to key and value parts=keyValuePair.split("="); if(parts.length==2) { //get key key=parts[0]; if(key.length()>0) { //decode key key=SpiUtil.urlDecode(key); //get value value=parts[1].trim(); //decode value value=SpiUtil.urlDecode(value); //put in data structure map.put(key,value); } } } } return map; }
[ "protected", "Map", "<", "String", ",", "String", ">", "convertParametersTextToMap", "(", "HTTPRequest", "request", ")", "{", "//init data structure", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", ...
This function converts the provided query string to a map object. @param request The HTTP request @return The query string broken to key/value
[ "This", "function", "converts", "the", "provided", "query", "string", "to", "a", "map", "object", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/http/SimpleHTTPRequestParser.java#L105-L155
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/mac/MacFaxClientSpi.java
MacFaxClientSpi.createSubmitFaxCommand
protected String createSubmitFaxCommand(FaxJob faxJob) { //init buffer StringBuilder buffer=new StringBuilder(); //create command buffer.append(this.submitCommand); buffer.append(" "); buffer.append(this.printQueueParameter); buffer.append(" "); buffer.append(this.printQueueName); buffer.append(" "); buffer.append(this.generalParameters); buffer.append(" "); buffer.append(this.phoneParameter); buffer.append("="); buffer.append(faxJob.getTargetAddress()); String targetName=faxJob.getTargetName(); if((targetName!=null)&&(targetName.length()>0)) { buffer.append(" "); buffer.append(this.faxToParameter); buffer.append("=\""); targetName=SpiUtil.urlEncode(targetName); buffer.append(targetName); buffer.append("\""); } buffer.append(" \""); buffer.append(faxJob.getFilePath()); buffer.append("\""); //get command String command=buffer.toString(); return command; }
java
protected String createSubmitFaxCommand(FaxJob faxJob) { //init buffer StringBuilder buffer=new StringBuilder(); //create command buffer.append(this.submitCommand); buffer.append(" "); buffer.append(this.printQueueParameter); buffer.append(" "); buffer.append(this.printQueueName); buffer.append(" "); buffer.append(this.generalParameters); buffer.append(" "); buffer.append(this.phoneParameter); buffer.append("="); buffer.append(faxJob.getTargetAddress()); String targetName=faxJob.getTargetName(); if((targetName!=null)&&(targetName.length()>0)) { buffer.append(" "); buffer.append(this.faxToParameter); buffer.append("=\""); targetName=SpiUtil.urlEncode(targetName); buffer.append(targetName); buffer.append("\""); } buffer.append(" \""); buffer.append(faxJob.getFilePath()); buffer.append("\""); //get command String command=buffer.toString(); return command; }
[ "protected", "String", "createSubmitFaxCommand", "(", "FaxJob", "faxJob", ")", "{", "//init buffer", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "//create command", "buffer", ".", "append", "(", "this", ".", "submitCommand", ")", ";", ...
Creates and returns the submit fax command. @param faxJob The fax job object containing the needed information @return The command
[ "Creates", "and", "returns", "the", "submit", "fax", "command", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/mac/MacFaxClientSpi.java#L258-L293
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/mac/MacFaxClientSpi.java
MacFaxClientSpi.executeProcess
protected ProcessOutput executeProcess(String command,FaxActionType faxActionType) { //execute process ProcessOutput processOutput=ProcessExecutorHelper.executeProcess(this,command); //validate process output this.processOutputValidator.validateProcessOutput(this,processOutput,faxActionType); return processOutput; }
java
protected ProcessOutput executeProcess(String command,FaxActionType faxActionType) { //execute process ProcessOutput processOutput=ProcessExecutorHelper.executeProcess(this,command); //validate process output this.processOutputValidator.validateProcessOutput(this,processOutput,faxActionType); return processOutput; }
[ "protected", "ProcessOutput", "executeProcess", "(", "String", "command", ",", "FaxActionType", "faxActionType", ")", "{", "//execute process", "ProcessOutput", "processOutput", "=", "ProcessExecutorHelper", ".", "executeProcess", "(", "this", ",", "command", ")", ";", ...
This function executes the external command to send the fax. @param command The command to execute @param faxActionType The fax action type @return The process output
[ "This", "function", "executes", "the", "external", "command", "to", "send", "the", "fax", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/mac/MacFaxClientSpi.java#L304-L313
train
sagiegurari/fax4j
src/main/java/org/fax4j/common/AbstractLogger.java
AbstractLogger.formatLogMessage
protected String formatLogMessage(LogLevel level,Object[] message,Throwable throwable) { //get text String messageText=this.format(message); String throwableText=this.format(throwable); //init buffer StringBuilder buffer=new StringBuilder(); //append prefix buffer.append("[fax4j]["); buffer.append(level.getName()); buffer.append("] "); if(messageText!=null) { buffer.append(messageText); if(throwableText!=null) { buffer.append(Logger.SYSTEM_EOL); buffer.append(throwableText); } } else if(throwableText!=null) { buffer.append(throwableText); } //get text String text=buffer.toString(); return text; }
java
protected String formatLogMessage(LogLevel level,Object[] message,Throwable throwable) { //get text String messageText=this.format(message); String throwableText=this.format(throwable); //init buffer StringBuilder buffer=new StringBuilder(); //append prefix buffer.append("[fax4j]["); buffer.append(level.getName()); buffer.append("] "); if(messageText!=null) { buffer.append(messageText); if(throwableText!=null) { buffer.append(Logger.SYSTEM_EOL); buffer.append(throwableText); } } else if(throwableText!=null) { buffer.append(throwableText); } //get text String text=buffer.toString(); return text; }
[ "protected", "String", "formatLogMessage", "(", "LogLevel", "level", ",", "Object", "[", "]", "message", ",", "Throwable", "throwable", ")", "{", "//get text", "String", "messageText", "=", "this", ".", "format", "(", "message", ")", ";", "String", "throwableT...
Converts the provided data to string. @param level The log level @param message The message parts (may be null) @param throwable The throwable (may be null) @return The string
[ "Converts", "the", "provided", "data", "to", "string", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/common/AbstractLogger.java#L40-L73
train
sagiegurari/fax4j
src/main/java/org/fax4j/common/AbstractLogger.java
AbstractLogger.format
protected String format(Object[] message) { String text=null; if(message!=null) { //init buffer StringBuilder buffer=new StringBuilder(); //get array size int amount=message.length; Object object=null; for(int index=0;index<amount;index++) { //get next element object=message[index]; //append to buffer buffer.append(object); } //get text text=buffer.toString(); } return text; }
java
protected String format(Object[] message) { String text=null; if(message!=null) { //init buffer StringBuilder buffer=new StringBuilder(); //get array size int amount=message.length; Object object=null; for(int index=0;index<amount;index++) { //get next element object=message[index]; //append to buffer buffer.append(object); } //get text text=buffer.toString(); } return text; }
[ "protected", "String", "format", "(", "Object", "[", "]", "message", ")", "{", "String", "text", "=", "null", ";", "if", "(", "message", "!=", "null", ")", "{", "//init buffer", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "//ge...
Converts the provided message object array to string. @param message The message parts (may be null) @return The string
[ "Converts", "the", "provided", "message", "object", "array", "to", "string", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/common/AbstractLogger.java#L82-L108
train
sagiegurari/fax4j
src/main/java/org/fax4j/common/AbstractLogger.java
AbstractLogger.format
protected String format(Throwable throwable) { String text=null; if(throwable!=null) { //init writer StringWriter writer=new StringWriter(1500); //write throwable throwable.printStackTrace(new PrintWriter(writer)); //get text text=writer.toString(); } return text; }
java
protected String format(Throwable throwable) { String text=null; if(throwable!=null) { //init writer StringWriter writer=new StringWriter(1500); //write throwable throwable.printStackTrace(new PrintWriter(writer)); //get text text=writer.toString(); } return text; }
[ "protected", "String", "format", "(", "Throwable", "throwable", ")", "{", "String", "text", "=", "null", ";", "if", "(", "throwable", "!=", "null", ")", "{", "//init writer", "StringWriter", "writer", "=", "new", "StringWriter", "(", "1500", ")", ";", "//w...
Converts the provided throwable to string. @param throwable The throwable (may be null) @return The string
[ "Converts", "the", "provided", "throwable", "to", "string", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/common/AbstractLogger.java#L117-L133
train
sagiegurari/fax4j
src/main/java/org/fax4j/common/AbstractLogger.java
AbstractLogger.setLogLevel
public final void setLogLevel(LogLevel logLevel) { LogLevel updatedLogLevel=logLevel; if(updatedLogLevel==null) { updatedLogLevel=LogLevel.NONE; } this.logLevel=updatedLogLevel; }
java
public final void setLogLevel(LogLevel logLevel) { LogLevel updatedLogLevel=logLevel; if(updatedLogLevel==null) { updatedLogLevel=LogLevel.NONE; } this.logLevel=updatedLogLevel; }
[ "public", "final", "void", "setLogLevel", "(", "LogLevel", "logLevel", ")", "{", "LogLevel", "updatedLogLevel", "=", "logLevel", ";", "if", "(", "updatedLogLevel", "==", "null", ")", "{", "updatedLogLevel", "=", "LogLevel", ".", "NONE", ";", "}", "this", "."...
Sets the minimum log level. @param logLevel The log level
[ "Sets", "the", "minimum", "log", "level", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/common/AbstractLogger.java#L141-L150
train
sagiegurari/fax4j
src/main/java/org/fax4j/common/AbstractLogger.java
AbstractLogger.logDebug
public void logDebug(Object[] message,Throwable throwable) { this.log(LogLevel.DEBUG,message,throwable); }
java
public void logDebug(Object[] message,Throwable throwable) { this.log(LogLevel.DEBUG,message,throwable); }
[ "public", "void", "logDebug", "(", "Object", "[", "]", "message", ",", "Throwable", "throwable", ")", "{", "this", ".", "log", "(", "LogLevel", ".", "DEBUG", ",", "message", ",", "throwable", ")", ";", "}" ]
Logs the provided data at the debug level. @param message The message parts (may be null) @param throwable The error (may be null)
[ "Logs", "the", "provided", "data", "at", "the", "debug", "level", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/common/AbstractLogger.java#L170-L173
train
sagiegurari/fax4j
src/main/java/org/fax4j/common/AbstractLogger.java
AbstractLogger.logInfo
public void logInfo(Object[] message,Throwable throwable) { this.log(LogLevel.INFO,message,throwable); }
java
public void logInfo(Object[] message,Throwable throwable) { this.log(LogLevel.INFO,message,throwable); }
[ "public", "void", "logInfo", "(", "Object", "[", "]", "message", ",", "Throwable", "throwable", ")", "{", "this", ".", "log", "(", "LogLevel", ".", "INFO", ",", "message", ",", "throwable", ")", ";", "}" ]
Logs the provided data at the info level. @param message The message parts (may be null) @param throwable The error (may be null)
[ "Logs", "the", "provided", "data", "at", "the", "info", "level", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/common/AbstractLogger.java#L183-L186
train
sagiegurari/fax4j
src/main/java/org/fax4j/common/AbstractLogger.java
AbstractLogger.logError
public void logError(Object[] message,Throwable throwable) { this.log(LogLevel.ERROR,message,throwable); }
java
public void logError(Object[] message,Throwable throwable) { this.log(LogLevel.ERROR,message,throwable); }
[ "public", "void", "logError", "(", "Object", "[", "]", "message", ",", "Throwable", "throwable", ")", "{", "this", ".", "log", "(", "LogLevel", ".", "ERROR", ",", "message", ",", "throwable", ")", ";", "}" ]
Logs the provided data at the error level. @param message The message parts (may be null) @param throwable The error (may be null)
[ "Logs", "the", "provided", "data", "at", "the", "error", "level", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/common/AbstractLogger.java#L196-L199
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/AbstractFaxClientSpi.java
AbstractFaxClientSpi.fireFaxMonitorEvent
public final void fireFaxMonitorEvent(FaxMonitorEventID id,FaxJob faxJob,FaxJobStatus faxJobStatus) { this.fireFaxEvent(id,faxJob,faxJobStatus); }
java
public final void fireFaxMonitorEvent(FaxMonitorEventID id,FaxJob faxJob,FaxJobStatus faxJobStatus) { this.fireFaxEvent(id,faxJob,faxJobStatus); }
[ "public", "final", "void", "fireFaxMonitorEvent", "(", "FaxMonitorEventID", "id", ",", "FaxJob", "faxJob", ",", "FaxJobStatus", "faxJobStatus", ")", "{", "this", ".", "fireFaxEvent", "(", "id", ",", "faxJob", ",", "faxJobStatus", ")", ";", "}" ]
This function fires a new fax monitor event. @param id The fax monitor event ID @param faxJob The fax job @param faxJobStatus The fax job status
[ "This", "function", "fires", "a", "new", "fax", "monitor", "event", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/AbstractFaxClientSpi.java#L246-L249
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/AbstractFaxClientSpi.java
AbstractFaxClientSpi.invokeFaxJobIDValidation
protected void invokeFaxJobIDValidation(FaxJob faxJob) { //validate fax job is not null this.invokeFaxJobNullValidation(faxJob); //validate fax job ID String faxJobID=faxJob.getID(); if((faxJobID==null)||(faxJobID.length()==0)) { throw new FaxException("Fax job ID not provided."); } }
java
protected void invokeFaxJobIDValidation(FaxJob faxJob) { //validate fax job is not null this.invokeFaxJobNullValidation(faxJob); //validate fax job ID String faxJobID=faxJob.getID(); if((faxJobID==null)||(faxJobID.length()==0)) { throw new FaxException("Fax job ID not provided."); } }
[ "protected", "void", "invokeFaxJobIDValidation", "(", "FaxJob", "faxJob", ")", "{", "//validate fax job is not null", "this", ".", "invokeFaxJobNullValidation", "(", "faxJob", ")", ";", "//validate fax job ID", "String", "faxJobID", "=", "faxJob", ".", "getID", "(", "...
This function invokes the fax job null validation. @param faxJob The fax job
[ "This", "function", "invokes", "the", "fax", "job", "null", "validation", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/AbstractFaxClientSpi.java#L639-L650
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/HTTPRequest.java
HTTPRequest.setHeaderProperties
public final void setHeaderProperties(Properties headerProperties) { this.headerProperties=null; if(headerProperties!=null) { this.headerProperties=new Properties(); this.headerProperties.putAll(headerProperties); } }
java
public final void setHeaderProperties(Properties headerProperties) { this.headerProperties=null; if(headerProperties!=null) { this.headerProperties=new Properties(); this.headerProperties.putAll(headerProperties); } }
[ "public", "final", "void", "setHeaderProperties", "(", "Properties", "headerProperties", ")", "{", "this", ".", "headerProperties", "=", "null", ";", "if", "(", "headerProperties", "!=", "null", ")", "{", "this", ".", "headerProperties", "=", "new", "Properties"...
This function sets the header properties. @param headerProperties The new value for the header properties
[ "This", "function", "sets", "the", "header", "properties", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/HTTPRequest.java#L102-L110
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/AbstractHTTPClient.java
AbstractHTTPClient.createHTTPClientConfiguration
public HTTPClientConfiguration createHTTPClientConfiguration(ConfigurationHolder configurationHolder) { //get server values String hostName=configurationHolder.getConfigurationValue(HTTPClientConfigurationConstants.HOST_NAME_PROPERTY_KEY); if(hostName==null) { throw new FaxException("Host name not defined in property: "+HTTPClientConfigurationConstants.HOST_NAME_PROPERTY_KEY); } String value=configurationHolder.getConfigurationValue(HTTPClientConfigurationConstants.PORT_PROPERTY_KEY); if(value==null) { value=String.valueOf(-1); } int port=Integer.parseInt(value); boolean ssl=Boolean.parseBoolean(configurationHolder.getConfigurationValue(HTTPClientConfigurationConstants.SSL_PROPERTY_KEY)); //create configuration CommonHTTPClientConfiguration configuration=new CommonHTTPClientConfiguration(); //set values configuration.setHostName(hostName); configuration.setPort(port); configuration.setSSL(ssl); //set methods Enum<?>[] methodProperties=new Enum<?>[]{HTTPClientConfigurationConstants.SUBMIT_HTTP_METHOD_PROPERTY_KEY, HTTPClientConfigurationConstants.SUSPEND_HTTP_METHOD_PROPERTY_KEY, HTTPClientConfigurationConstants.RESUME_HTTP_METHOD_PROPERTY_KEY, HTTPClientConfigurationConstants.CANCEL_HTTP_METHOD_PROPERTY_KEY, HTTPClientConfigurationConstants.GET_STATUS_HTTP_METHOD_PROPERTY_KEY}; FaxActionType[] faxActionTypes=new FaxActionType[]{FaxActionType.SUBMIT_FAX_JOB, FaxActionType.SUSPEND_FAX_JOB, FaxActionType.RESUME_FAX_JOB, FaxActionType.CANCEL_FAX_JOB, FaxActionType.GET_FAX_JOB_STATUS}; HTTPMethod httpMethod=null; for(int index=0;index<methodProperties.length;index++) { //set next method value=configurationHolder.getConfigurationValue(methodProperties[index]); httpMethod=HTTPMethod.POST; if(value!=null) { httpMethod=HTTPMethod.valueOf(value); } configuration.setMethod(faxActionTypes[index],httpMethod); } return configuration; }
java
public HTTPClientConfiguration createHTTPClientConfiguration(ConfigurationHolder configurationHolder) { //get server values String hostName=configurationHolder.getConfigurationValue(HTTPClientConfigurationConstants.HOST_NAME_PROPERTY_KEY); if(hostName==null) { throw new FaxException("Host name not defined in property: "+HTTPClientConfigurationConstants.HOST_NAME_PROPERTY_KEY); } String value=configurationHolder.getConfigurationValue(HTTPClientConfigurationConstants.PORT_PROPERTY_KEY); if(value==null) { value=String.valueOf(-1); } int port=Integer.parseInt(value); boolean ssl=Boolean.parseBoolean(configurationHolder.getConfigurationValue(HTTPClientConfigurationConstants.SSL_PROPERTY_KEY)); //create configuration CommonHTTPClientConfiguration configuration=new CommonHTTPClientConfiguration(); //set values configuration.setHostName(hostName); configuration.setPort(port); configuration.setSSL(ssl); //set methods Enum<?>[] methodProperties=new Enum<?>[]{HTTPClientConfigurationConstants.SUBMIT_HTTP_METHOD_PROPERTY_KEY, HTTPClientConfigurationConstants.SUSPEND_HTTP_METHOD_PROPERTY_KEY, HTTPClientConfigurationConstants.RESUME_HTTP_METHOD_PROPERTY_KEY, HTTPClientConfigurationConstants.CANCEL_HTTP_METHOD_PROPERTY_KEY, HTTPClientConfigurationConstants.GET_STATUS_HTTP_METHOD_PROPERTY_KEY}; FaxActionType[] faxActionTypes=new FaxActionType[]{FaxActionType.SUBMIT_FAX_JOB, FaxActionType.SUSPEND_FAX_JOB, FaxActionType.RESUME_FAX_JOB, FaxActionType.CANCEL_FAX_JOB, FaxActionType.GET_FAX_JOB_STATUS}; HTTPMethod httpMethod=null; for(int index=0;index<methodProperties.length;index++) { //set next method value=configurationHolder.getConfigurationValue(methodProperties[index]); httpMethod=HTTPMethod.POST; if(value!=null) { httpMethod=HTTPMethod.valueOf(value); } configuration.setMethod(faxActionTypes[index],httpMethod); } return configuration; }
[ "public", "HTTPClientConfiguration", "createHTTPClientConfiguration", "(", "ConfigurationHolder", "configurationHolder", ")", "{", "//get server values", "String", "hostName", "=", "configurationHolder", ".", "getConfigurationValue", "(", "HTTPClientConfigurationConstants", ".", ...
This function creates the HTTP client configuration to be used later on by this HTTP client type. @param configurationHolder The configuration holder @return The HTTP client configuration
[ "This", "function", "creates", "the", "HTTP", "client", "configuration", "to", "be", "used", "later", "on", "by", "this", "HTTP", "client", "type", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/AbstractHTTPClient.java#L45-L94
train
hivemq/hivemq-spi
src/main/java/com/hivemq/spi/util/PathUtils.java
PathUtils.findAbsoluteAndRelative
public static File findAbsoluteAndRelative(final String fileLocation) { final File file = new File(fileLocation); if (file.isAbsolute()) { return file; } else { return new File(getHiveMQHomeFolder(), fileLocation); } }
java
public static File findAbsoluteAndRelative(final String fileLocation) { final File file = new File(fileLocation); if (file.isAbsolute()) { return file; } else { return new File(getHiveMQHomeFolder(), fileLocation); } }
[ "public", "static", "File", "findAbsoluteAndRelative", "(", "final", "String", "fileLocation", ")", "{", "final", "File", "file", "=", "new", "File", "(", "fileLocation", ")", ";", "if", "(", "file", ".", "isAbsolute", "(", ")", ")", "{", "return", "file",...
Tries to find a file in the given absolute path or relative to the HiveMQ home folder @param fileLocation the absolute or relative path @return a file
[ "Tries", "to", "find", "a", "file", "in", "the", "given", "absolute", "path", "or", "relative", "to", "the", "HiveMQ", "home", "folder" ]
55fa89ccb081ad5b6d46eaca02179272148e64ed
https://github.com/hivemq/hivemq-spi/blob/55fa89ccb081ad5b6d46eaca02179272148e64ed/src/main/java/com/hivemq/spi/util/PathUtils.java#L89-L96
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java
ApacheHTTPClient.createMethod
protected HttpMethodBase createMethod(String url,HTTPMethod httpMethod) { if(httpMethod==null) { throw new FaxException("HTTP method not provided."); } if((url==null)||(url.length()==0)) { throw new FaxException("HTTP URL not provided."); } //create method HttpMethodBase httpMethodClient=null; switch(httpMethod) { case POST: httpMethodClient=new PostMethod(url); break; case GET: httpMethodClient=new GetMethod(url); break; case PUT: httpMethodClient=new PutMethod(url); break; } return httpMethodClient; }
java
protected HttpMethodBase createMethod(String url,HTTPMethod httpMethod) { if(httpMethod==null) { throw new FaxException("HTTP method not provided."); } if((url==null)||(url.length()==0)) { throw new FaxException("HTTP URL not provided."); } //create method HttpMethodBase httpMethodClient=null; switch(httpMethod) { case POST: httpMethodClient=new PostMethod(url); break; case GET: httpMethodClient=new GetMethod(url); break; case PUT: httpMethodClient=new PutMethod(url); break; } return httpMethodClient; }
[ "protected", "HttpMethodBase", "createMethod", "(", "String", "url", ",", "HTTPMethod", "httpMethod", ")", "{", "if", "(", "httpMethod", "==", "null", ")", "{", "throw", "new", "FaxException", "(", "\"HTTP method not provided.\"", ")", ";", "}", "if", "(", "("...
This function creates and returns a new HTTP method. @param url The target URL @param httpMethod The HTTP method to use @return The new HTTP method
[ "This", "function", "creates", "and", "returns", "a", "new", "HTTP", "method", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java#L71-L98
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java
ApacheHTTPClient.createHTTPResponse
protected HTTPResponse createHTTPResponse(int statusCode,String responseContent) { //create HTTP response HTTPResponse httpResponse=new HTTPResponse(); httpResponse.setStatusCode(statusCode); httpResponse.setContent(responseContent); return httpResponse; }
java
protected HTTPResponse createHTTPResponse(int statusCode,String responseContent) { //create HTTP response HTTPResponse httpResponse=new HTTPResponse(); httpResponse.setStatusCode(statusCode); httpResponse.setContent(responseContent); return httpResponse; }
[ "protected", "HTTPResponse", "createHTTPResponse", "(", "int", "statusCode", ",", "String", "responseContent", ")", "{", "//create HTTP response", "HTTPResponse", "httpResponse", "=", "new", "HTTPResponse", "(", ")", ";", "httpResponse", ".", "setStatusCode", "(", "st...
This function creates and returns the HTTP response object. @param statusCode The HTTP response status code @param responseContent The response content as string @return The HTTP response object
[ "This", "function", "creates", "and", "returns", "the", "HTTP", "response", "object", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java#L109-L117
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java
ApacheHTTPClient.appendParameters
protected void appendParameters(StringBuilder buffer,String parameters) { if((parameters!=null)&&(parameters.length()>0)) { String updatedParameters=parameters; if(parameters.startsWith("?")) { updatedParameters=parameters.substring(1); } if(updatedParameters.length()>0) { int currentLength=buffer.length(); if((currentLength>0)&&(buffer.charAt(currentLength-1)=='/')) { int length=currentLength; buffer.delete(length-1,length); } //add separator buffer.append("?"); try { String[] parameterPairs=updatedParameters.split("&"); int amount=parameterPairs.length; String parameterPair=null; String[] values=null; boolean addedParameters=false; for(int index=0;index<amount;index++) { //get next element parameterPair=parameterPairs[index]; //split to key/value values=parameterPair.split("="); if(values.length==2) { if(addedParameters) { buffer.append("&"); } buffer.append(URLEncoder.encode(values[0],"UTF-8")); buffer.append("="); buffer.append(URLEncoder.encode(values[1],"UTF-8")); //set flag addedParameters=true; } } } catch(Exception exception) { throw new FaxException("Unable to encode parameters.",exception); } } } }
java
protected void appendParameters(StringBuilder buffer,String parameters) { if((parameters!=null)&&(parameters.length()>0)) { String updatedParameters=parameters; if(parameters.startsWith("?")) { updatedParameters=parameters.substring(1); } if(updatedParameters.length()>0) { int currentLength=buffer.length(); if((currentLength>0)&&(buffer.charAt(currentLength-1)=='/')) { int length=currentLength; buffer.delete(length-1,length); } //add separator buffer.append("?"); try { String[] parameterPairs=updatedParameters.split("&"); int amount=parameterPairs.length; String parameterPair=null; String[] values=null; boolean addedParameters=false; for(int index=0;index<amount;index++) { //get next element parameterPair=parameterPairs[index]; //split to key/value values=parameterPair.split("="); if(values.length==2) { if(addedParameters) { buffer.append("&"); } buffer.append(URLEncoder.encode(values[0],"UTF-8")); buffer.append("="); buffer.append(URLEncoder.encode(values[1],"UTF-8")); //set flag addedParameters=true; } } } catch(Exception exception) { throw new FaxException("Unable to encode parameters.",exception); } } } }
[ "protected", "void", "appendParameters", "(", "StringBuilder", "buffer", ",", "String", "parameters", ")", "{", "if", "(", "(", "parameters", "!=", "null", ")", "&&", "(", "parameters", ".", "length", "(", ")", ">", "0", ")", ")", "{", "String", "updated...
This function appends the parameters text to the base URL. @param buffer The buffer to update @param parameters The parameters line
[ "This", "function", "appends", "the", "parameters", "text", "to", "the", "base", "URL", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java#L163-L221
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java
ApacheHTTPClient.createURL
protected String createURL(HTTPRequest httpRequest,HTTPClientConfiguration configuration) { //init buffer StringBuilder buffer=new StringBuilder(100); //create URL String resource=httpRequest.getResource(); this.appendBaseURL(buffer,resource,configuration); String parameters=httpRequest.getParametersText(); this.appendParameters(buffer,parameters); String url=buffer.toString(); return url; }
java
protected String createURL(HTTPRequest httpRequest,HTTPClientConfiguration configuration) { //init buffer StringBuilder buffer=new StringBuilder(100); //create URL String resource=httpRequest.getResource(); this.appendBaseURL(buffer,resource,configuration); String parameters=httpRequest.getParametersText(); this.appendParameters(buffer,parameters); String url=buffer.toString(); return url; }
[ "protected", "String", "createURL", "(", "HTTPRequest", "httpRequest", ",", "HTTPClientConfiguration", "configuration", ")", "{", "//init buffer", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", "100", ")", ";", "//create URL", "String", "resource", "=", ...
This function creates the full URL from the provided values. @param httpRequest The HTTP request to send @param configuration HTTP client configuration @return The full URL
[ "This", "function", "creates", "the", "full", "URL", "from", "the", "provided", "values", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java#L232-L245
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java
ApacheHTTPClient.setupHTTPRequestHeaderProperties
protected void setupHTTPRequestHeaderProperties(HTTPRequest httpRequest,HttpMethodBase httpMethodClient) { //setup header properties Properties headerProperties=httpRequest.getHeaderProperties(); if(headerProperties!=null) { Iterator<Entry<Object,Object>> iterator=headerProperties.entrySet().iterator(); Entry<Object,Object> entry=null; while(iterator.hasNext()) { //get next entry entry=iterator.next(); //set header values httpMethodClient.addRequestHeader((String)entry.getKey(),(String)entry.getValue()); } } }
java
protected void setupHTTPRequestHeaderProperties(HTTPRequest httpRequest,HttpMethodBase httpMethodClient) { //setup header properties Properties headerProperties=httpRequest.getHeaderProperties(); if(headerProperties!=null) { Iterator<Entry<Object,Object>> iterator=headerProperties.entrySet().iterator(); Entry<Object,Object> entry=null; while(iterator.hasNext()) { //get next entry entry=iterator.next(); //set header values httpMethodClient.addRequestHeader((String)entry.getKey(),(String)entry.getValue()); } } }
[ "protected", "void", "setupHTTPRequestHeaderProperties", "(", "HTTPRequest", "httpRequest", ",", "HttpMethodBase", "httpMethodClient", ")", "{", "//setup header properties", "Properties", "headerProperties", "=", "httpRequest", ".", "getHeaderProperties", "(", ")", ";", "if...
This function sets the header properties in the HTTP method. @param httpRequest The HTTP request @param httpMethodClient The apache HTTP method
[ "This", "function", "sets", "the", "header", "properties", "in", "the", "HTTP", "method", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java#L255-L272
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java
ApacheHTTPClient.createStringRequestContent
protected RequestEntity createStringRequestContent(HTTPRequest httpRequest) { RequestEntity requestEntity=null; String contentString=httpRequest.getContentAsString(); if(contentString!=null) { try { requestEntity=new StringRequestEntity(contentString,"text/plain",null); } catch(UnsupportedEncodingException exception) { throw new FaxException("Unable to set string request entity.",exception); } } return requestEntity; }
java
protected RequestEntity createStringRequestContent(HTTPRequest httpRequest) { RequestEntity requestEntity=null; String contentString=httpRequest.getContentAsString(); if(contentString!=null) { try { requestEntity=new StringRequestEntity(contentString,"text/plain",null); } catch(UnsupportedEncodingException exception) { throw new FaxException("Unable to set string request entity.",exception); } } return requestEntity; }
[ "protected", "RequestEntity", "createStringRequestContent", "(", "HTTPRequest", "httpRequest", ")", "{", "RequestEntity", "requestEntity", "=", "null", ";", "String", "contentString", "=", "httpRequest", ".", "getContentAsString", "(", ")", ";", "if", "(", "contentStr...
This function creates a string type request entity and populates it with the data from the provided HTTP request. @param httpRequest The HTTP request @return The request entity
[ "This", "function", "creates", "a", "string", "type", "request", "entity", "and", "populates", "it", "with", "the", "data", "from", "the", "provided", "HTTP", "request", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java#L282-L299
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java
ApacheHTTPClient.createBinaryRequestContent
protected RequestEntity createBinaryRequestContent(HTTPRequest httpRequest) { RequestEntity requestEntity=null; byte[] contentBinary=httpRequest.getContentAsBinary(); if(contentBinary!=null) { requestEntity=new ByteArrayRequestEntity(contentBinary,"binary/octet-stream"); } return requestEntity; }
java
protected RequestEntity createBinaryRequestContent(HTTPRequest httpRequest) { RequestEntity requestEntity=null; byte[] contentBinary=httpRequest.getContentAsBinary(); if(contentBinary!=null) { requestEntity=new ByteArrayRequestEntity(contentBinary,"binary/octet-stream"); } return requestEntity; }
[ "protected", "RequestEntity", "createBinaryRequestContent", "(", "HTTPRequest", "httpRequest", ")", "{", "RequestEntity", "requestEntity", "=", "null", ";", "byte", "[", "]", "contentBinary", "=", "httpRequest", ".", "getContentAsBinary", "(", ")", ";", "if", "(", ...
This function creates a binary type request entity and populates it with the data from the provided HTTP request. @param httpRequest The HTTP request @return The request entity
[ "This", "function", "creates", "a", "binary", "type", "request", "entity", "and", "populates", "it", "with", "the", "data", "from", "the", "provided", "HTTP", "request", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java#L309-L319
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java
ApacheHTTPClient.createMultiPartRequestContent
protected RequestEntity createMultiPartRequestContent(HTTPRequest httpRequest,HttpMethodBase httpMethodClient) { RequestEntity requestEntity=null; ContentPart<?>[] contentParts=httpRequest.getContentAsParts(); if(contentParts!=null) { int partsAmount=contentParts.length; if(partsAmount>0) { //init array Part[] parts=new Part[partsAmount]; ContentPart<?> contentPart=null; String name=null; Object content=null; ContentPartType contentPartType=null; for(int index=0;index<partsAmount;index++) { //get next part contentPart=contentParts[index]; if(contentPart!=null) { //get part values name=contentPart.getName(); content=contentPart.getContent(); contentPartType=contentPart.getType(); //create new part switch(contentPartType) { case FILE: File file=(File)content; try { parts[index]=new FilePart(name,file); } catch(FileNotFoundException exception) { throw new FaxException("Fax file: "+file.getAbsolutePath()+" not found.",exception); } break; case STRING: parts[index]=new StringPart(name,(String)content); break; default: throw new FaxException("Unsupported content type provided: "+contentPartType); } } } requestEntity=new MultipartRequestEntity(parts,httpMethodClient.getParams()); } } return requestEntity; }
java
protected RequestEntity createMultiPartRequestContent(HTTPRequest httpRequest,HttpMethodBase httpMethodClient) { RequestEntity requestEntity=null; ContentPart<?>[] contentParts=httpRequest.getContentAsParts(); if(contentParts!=null) { int partsAmount=contentParts.length; if(partsAmount>0) { //init array Part[] parts=new Part[partsAmount]; ContentPart<?> contentPart=null; String name=null; Object content=null; ContentPartType contentPartType=null; for(int index=0;index<partsAmount;index++) { //get next part contentPart=contentParts[index]; if(contentPart!=null) { //get part values name=contentPart.getName(); content=contentPart.getContent(); contentPartType=contentPart.getType(); //create new part switch(contentPartType) { case FILE: File file=(File)content; try { parts[index]=new FilePart(name,file); } catch(FileNotFoundException exception) { throw new FaxException("Fax file: "+file.getAbsolutePath()+" not found.",exception); } break; case STRING: parts[index]=new StringPart(name,(String)content); break; default: throw new FaxException("Unsupported content type provided: "+contentPartType); } } } requestEntity=new MultipartRequestEntity(parts,httpMethodClient.getParams()); } } return requestEntity; }
[ "protected", "RequestEntity", "createMultiPartRequestContent", "(", "HTTPRequest", "httpRequest", ",", "HttpMethodBase", "httpMethodClient", ")", "{", "RequestEntity", "requestEntity", "=", "null", ";", "ContentPart", "<", "?", ">", "[", "]", "contentParts", "=", "htt...
This function creates a multi part type request entity and populates it with the data from the provided HTTP request. @param httpRequest The HTTP request @param httpMethodClient The apache HTTP method @return The request entity
[ "This", "function", "creates", "a", "multi", "part", "type", "request", "entity", "and", "populates", "it", "with", "the", "data", "from", "the", "provided", "HTTP", "request", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java#L331-L387
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java
ApacheHTTPClient.setRequestContent
protected void setRequestContent(HTTPRequest httpRequest,HttpMethodBase httpMethodClient) { //set content if(httpMethodClient instanceof EntityEnclosingMethod) { EntityEnclosingMethod pushMethod=(EntityEnclosingMethod)httpMethodClient; RequestEntity requestEntity=null; ContentType contentType=httpRequest.getContentType(); switch(contentType) { case STRING: requestEntity=this.createStringRequestContent(httpRequest); break; case BINARY: requestEntity=this.createBinaryRequestContent(httpRequest); break; case MULTI_PART: requestEntity=this.createMultiPartRequestContent(httpRequest,httpMethodClient); break; default: throw new FaxException("Unsupported content type: "+contentType); } //set request data if(requestEntity!=null) { pushMethod.setRequestEntity(requestEntity); pushMethod.setContentChunked(false); } } }
java
protected void setRequestContent(HTTPRequest httpRequest,HttpMethodBase httpMethodClient) { //set content if(httpMethodClient instanceof EntityEnclosingMethod) { EntityEnclosingMethod pushMethod=(EntityEnclosingMethod)httpMethodClient; RequestEntity requestEntity=null; ContentType contentType=httpRequest.getContentType(); switch(contentType) { case STRING: requestEntity=this.createStringRequestContent(httpRequest); break; case BINARY: requestEntity=this.createBinaryRequestContent(httpRequest); break; case MULTI_PART: requestEntity=this.createMultiPartRequestContent(httpRequest,httpMethodClient); break; default: throw new FaxException("Unsupported content type: "+contentType); } //set request data if(requestEntity!=null) { pushMethod.setRequestEntity(requestEntity); pushMethod.setContentChunked(false); } } }
[ "protected", "void", "setRequestContent", "(", "HTTPRequest", "httpRequest", ",", "HttpMethodBase", "httpMethodClient", ")", "{", "//set content", "if", "(", "httpMethodClient", "instanceof", "EntityEnclosingMethod", ")", "{", "EntityEnclosingMethod", "pushMethod", "=", "...
This function sets the request content. @param httpRequest The HTTP request @param httpMethodClient The apache HTTP method
[ "This", "function", "sets", "the", "request", "content", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/http/ApacheHTTPClient.java#L397-L428
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/AbstractConnectionFactory.java
AbstractConnectionFactory.releaseConnection
public void releaseConnection(Connection<T> connection) { if(connection!=null) { try { //log info this.LOGGER.logInfo(new Object[]{"Closing connection using factory type: ",this.getClass().getName()},null); //get resource T resource=connection.getResource(); //release resource this.releaseResource(resource); //unregister connection CloseableResourceManager.unregisterCloseable(connection); //log info this.LOGGER.logInfo(new Object[]{"Connection closed."},null); } catch(Exception exception) { //log error this.LOGGER.logInfo(new Object[]{"Unable to close connection."},exception); } } }
java
public void releaseConnection(Connection<T> connection) { if(connection!=null) { try { //log info this.LOGGER.logInfo(new Object[]{"Closing connection using factory type: ",this.getClass().getName()},null); //get resource T resource=connection.getResource(); //release resource this.releaseResource(resource); //unregister connection CloseableResourceManager.unregisterCloseable(connection); //log info this.LOGGER.logInfo(new Object[]{"Connection closed."},null); } catch(Exception exception) { //log error this.LOGGER.logInfo(new Object[]{"Unable to close connection."},exception); } } }
[ "public", "void", "releaseConnection", "(", "Connection", "<", "T", ">", "connection", ")", "{", "if", "(", "connection", "!=", "null", ")", "{", "try", "{", "//log info", "this", ".", "LOGGER", ".", "logInfo", "(", "new", "Object", "[", "]", "{", "\"C...
Releases the connection. @param connection The connection
[ "Releases", "the", "connection", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/AbstractConnectionFactory.java#L90-L117
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/hylafax/HylaFaxClientSpi.java
HylaFaxClientSpi.createHylaFAXClientConnectionFactory
protected final HylaFAXClientConnectionFactory createHylaFAXClientConnectionFactory(String className) { //create new instance HylaFAXClientConnectionFactory factory=(HylaFAXClientConnectionFactory)ReflectionHelper.createInstance(className); //initialize factory.initialize(this); return factory; }
java
protected final HylaFAXClientConnectionFactory createHylaFAXClientConnectionFactory(String className) { //create new instance HylaFAXClientConnectionFactory factory=(HylaFAXClientConnectionFactory)ReflectionHelper.createInstance(className); //initialize factory.initialize(this); return factory; }
[ "protected", "final", "HylaFAXClientConnectionFactory", "createHylaFAXClientConnectionFactory", "(", "String", "className", ")", "{", "//create new instance", "HylaFAXClientConnectionFactory", "factory", "=", "(", "HylaFAXClientConnectionFactory", ")", "ReflectionHelper", ".", "c...
Creates and returns the hylafax client connection factory. @param className The connection factory class name @return The hylafax client connection factory
[ "Creates", "and", "returns", "the", "hylafax", "client", "connection", "factory", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxClientSpi.java#L214-L223
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/hylafax/HylaFaxClientSpi.java
HylaFaxClientSpi.getHylaFAXClient
protected synchronized HylaFAXClient getHylaFAXClient() { HylaFAXClient client=null; if(this.connection==null) { //create new connection this.connection=this.connectionFactory.createConnection(); } //get client client=this.connection.getResource(); return client; }
java
protected synchronized HylaFAXClient getHylaFAXClient() { HylaFAXClient client=null; if(this.connection==null) { //create new connection this.connection=this.connectionFactory.createConnection(); } //get client client=this.connection.getResource(); return client; }
[ "protected", "synchronized", "HylaFAXClient", "getHylaFAXClient", "(", ")", "{", "HylaFAXClient", "client", "=", "null", ";", "if", "(", "this", ".", "connection", "==", "null", ")", "{", "//create new connection", "this", ".", "connection", "=", "this", ".", ...
Returns an instance of the hyla fax client. @return The client instance
[ "Returns", "an", "instance", "of", "the", "hyla", "fax", "client", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxClientSpi.java#L230-L243
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/ReflectionHelper.java
ReflectionHelper.getThreadContextClassLoader
public static ClassLoader getThreadContextClassLoader() { Thread thread=Thread.currentThread(); ClassLoader classLoader=thread.getContextClassLoader(); return classLoader; }
java
public static ClassLoader getThreadContextClassLoader() { Thread thread=Thread.currentThread(); ClassLoader classLoader=thread.getContextClassLoader(); return classLoader; }
[ "public", "static", "ClassLoader", "getThreadContextClassLoader", "(", ")", "{", "Thread", "thread", "=", "Thread", ".", "currentThread", "(", ")", ";", "ClassLoader", "classLoader", "=", "thread", ".", "getContextClassLoader", "(", ")", ";", "return", "classLoade...
This function returns the thread context class loader. @return The thread context class loader
[ "This", "function", "returns", "the", "thread", "context", "class", "loader", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/ReflectionHelper.java#L30-L36
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/ReflectionHelper.java
ReflectionHelper.getType
public static Class<?> getType(String className) { ClassLoader classLoader=ReflectionHelper.getThreadContextClassLoader(); Class<?> type=null; try { //load class definition type=classLoader.loadClass(className); } catch(ClassNotFoundException exception) { throw new FaxException("Unable to load class: "+className,exception); } return type; }
java
public static Class<?> getType(String className) { ClassLoader classLoader=ReflectionHelper.getThreadContextClassLoader(); Class<?> type=null; try { //load class definition type=classLoader.loadClass(className); } catch(ClassNotFoundException exception) { throw new FaxException("Unable to load class: "+className,exception); } return type; }
[ "public", "static", "Class", "<", "?", ">", "getType", "(", "String", "className", ")", "{", "ClassLoader", "classLoader", "=", "ReflectionHelper", ".", "getThreadContextClassLoader", "(", ")", ";", "Class", "<", "?", ">", "type", "=", "null", ";", "try", ...
This function returns the class based on the class name. @param className The class name of the requested type @return The type
[ "This", "function", "returns", "the", "class", "based", "on", "the", "class", "name", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/ReflectionHelper.java#L45-L60
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/ReflectionHelper.java
ReflectionHelper.invokeMethod
public static Object invokeMethod(Class<?> type,Object instance,String methodName,Class<?>[] inputTypes,Object[] input) { Method method=null; try { //get method method=type.getDeclaredMethod(methodName,inputTypes); } catch(Exception exception) { throw new FaxException("Unable to extract method: "+methodName+" from type: "+type,exception); } //set accessible method.setAccessible(true); Object output=null; try { //invoke method output=method.invoke(instance,input); } catch(Exception exception) { throw new FaxException("Unable to invoke method: "+methodName+" of type: "+type,exception); } return output; }
java
public static Object invokeMethod(Class<?> type,Object instance,String methodName,Class<?>[] inputTypes,Object[] input) { Method method=null; try { //get method method=type.getDeclaredMethod(methodName,inputTypes); } catch(Exception exception) { throw new FaxException("Unable to extract method: "+methodName+" from type: "+type,exception); } //set accessible method.setAccessible(true); Object output=null; try { //invoke method output=method.invoke(instance,input); } catch(Exception exception) { throw new FaxException("Unable to invoke method: "+methodName+" of type: "+type,exception); } return output; }
[ "public", "static", "Object", "invokeMethod", "(", "Class", "<", "?", ">", "type", ",", "Object", "instance", ",", "String", "methodName", ",", "Class", "<", "?", ">", "[", "]", "inputTypes", ",", "Object", "[", "]", "input", ")", "{", "Method", "metho...
This function invokes the requested method. @param type The class type @param instance The instance @param methodName The method name to invoke @param inputTypes An array of input types @param input The method input @return The method output
[ "This", "function", "invokes", "the", "requested", "method", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/ReflectionHelper.java#L118-L146
train
sagiegurari/fax4j
src/main/java/org/fax4j/util/ReflectionHelper.java
ReflectionHelper.getField
public static Field getField(Class<?> type,String fieldName) { Field field=null; try { //get field field=type.getDeclaredField(fieldName); } catch(Exception exception) { throw new FaxException("Unable to extract field: "+fieldName+" from type: "+type,exception); } //set accessible field.setAccessible(true); return field; }
java
public static Field getField(Class<?> type,String fieldName) { Field field=null; try { //get field field=type.getDeclaredField(fieldName); } catch(Exception exception) { throw new FaxException("Unable to extract field: "+fieldName+" from type: "+type,exception); } //set accessible field.setAccessible(true); return field; }
[ "public", "static", "Field", "getField", "(", "Class", "<", "?", ">", "type", ",", "String", "fieldName", ")", "{", "Field", "field", "=", "null", ";", "try", "{", "//get field", "field", "=", "type", ".", "getDeclaredField", "(", "fieldName", ")", ";", ...
This function returns the field wrapper for the requested field @param type The class type @param fieldName The field name @return The field
[ "This", "function", "returns", "the", "field", "wrapper", "for", "the", "requested", "field" ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/util/ReflectionHelper.java#L157-L174
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/process/ProcessFaxClientSpi.java
ProcessFaxClientSpi.createProcessOutputValidator
protected ProcessOutputValidator createProcessOutputValidator() { //get process output validator String className=this.getConfigurationValue(FaxClientSpiConfigurationConstants.PROCESS_OUTPUT_VALIDATOR_PRE_FORMAT_PROPERTY_KEY); ProcessOutputValidator validator=null; if(className==null) { className=ExitCodeProcessOutputValidator.class.getName(); } //create new instance validator=(ProcessOutputValidator)ReflectionHelper.createInstance(className); return validator; }
java
protected ProcessOutputValidator createProcessOutputValidator() { //get process output validator String className=this.getConfigurationValue(FaxClientSpiConfigurationConstants.PROCESS_OUTPUT_VALIDATOR_PRE_FORMAT_PROPERTY_KEY); ProcessOutputValidator validator=null; if(className==null) { className=ExitCodeProcessOutputValidator.class.getName(); } //create new instance validator=(ProcessOutputValidator)ReflectionHelper.createInstance(className); return validator; }
[ "protected", "ProcessOutputValidator", "createProcessOutputValidator", "(", ")", "{", "//get process output validator", "String", "className", "=", "this", ".", "getConfigurationValue", "(", "FaxClientSpiConfigurationConstants", ".", "PROCESS_OUTPUT_VALIDATOR_PRE_FORMAT_PROPERTY_KEY"...
This function creates and returns the process output validator. @return The process output validator
[ "This", "function", "creates", "and", "returns", "the", "process", "output", "validator", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/process/ProcessFaxClientSpi.java#L281-L295
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/process/ProcessFaxClientSpi.java
ProcessFaxClientSpi.createProcessOutputHandler
protected ProcessOutputHandler createProcessOutputHandler() { //get process output handler String className=this.getConfigurationValue(FaxClientSpiConfigurationConstants.PROCESS_OUTPUT_HANDLER_PRE_FORMAT_PROPERTY_KEY); ProcessOutputHandler handler=null; if(className!=null) { //create new instance handler=(ProcessOutputHandler)ReflectionHelper.createInstance(className); } return handler; }
java
protected ProcessOutputHandler createProcessOutputHandler() { //get process output handler String className=this.getConfigurationValue(FaxClientSpiConfigurationConstants.PROCESS_OUTPUT_HANDLER_PRE_FORMAT_PROPERTY_KEY); ProcessOutputHandler handler=null; if(className!=null) { //create new instance handler=(ProcessOutputHandler)ReflectionHelper.createInstance(className); } return handler; }
[ "protected", "ProcessOutputHandler", "createProcessOutputHandler", "(", ")", "{", "//get process output handler", "String", "className", "=", "this", ".", "getConfigurationValue", "(", "FaxClientSpiConfigurationConstants", ".", "PROCESS_OUTPUT_HANDLER_PRE_FORMAT_PROPERTY_KEY", ")",...
This function creates and returns the process output handler. @return The process output handler
[ "This", "function", "creates", "and", "returns", "the", "process", "output", "handler", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/process/ProcessFaxClientSpi.java#L302-L314
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/process/ProcessFaxClientSpi.java
ProcessFaxClientSpi.executeProcess
protected ProcessOutput executeProcess(FaxJob faxJob,String command,FaxActionType faxActionType) { if(command==null) { this.throwUnsupportedException(); } //update command String updatedCommand=command; if(this.useWindowsCommandPrefix) { //init buffer StringBuilder buffer=new StringBuilder(updatedCommand.length()+this.windowsCommandPrefix.length()+1); //update command buffer.append(this.windowsCommandPrefix); buffer.append(" "); buffer.append(updatedCommand); updatedCommand=buffer.toString(); } //execute process ProcessOutput processOutput=ProcessExecutorHelper.executeProcess(this,updatedCommand); //validate output (if not valid, an exception should be thrown) this.validateProcessOutput(processOutput,faxActionType); //update fax job this.updateFaxJob(faxJob,processOutput,faxActionType); return processOutput; }
java
protected ProcessOutput executeProcess(FaxJob faxJob,String command,FaxActionType faxActionType) { if(command==null) { this.throwUnsupportedException(); } //update command String updatedCommand=command; if(this.useWindowsCommandPrefix) { //init buffer StringBuilder buffer=new StringBuilder(updatedCommand.length()+this.windowsCommandPrefix.length()+1); //update command buffer.append(this.windowsCommandPrefix); buffer.append(" "); buffer.append(updatedCommand); updatedCommand=buffer.toString(); } //execute process ProcessOutput processOutput=ProcessExecutorHelper.executeProcess(this,updatedCommand); //validate output (if not valid, an exception should be thrown) this.validateProcessOutput(processOutput,faxActionType); //update fax job this.updateFaxJob(faxJob,processOutput,faxActionType); return processOutput; }
[ "protected", "ProcessOutput", "executeProcess", "(", "FaxJob", "faxJob", ",", "String", "command", ",", "FaxActionType", "faxActionType", ")", "{", "if", "(", "command", "==", "null", ")", "{", "this", ".", "throwUnsupportedException", "(", ")", ";", "}", "//u...
Executes the process and returns the output. @param faxJob The fax job object @param command The command to execute @param faxActionType The fax action type @return The process output
[ "Executes", "the", "process", "and", "returns", "the", "output", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/process/ProcessFaxClientSpi.java#L467-L498
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/AbstractFaxJob.java
AbstractFaxJob.getFilePath
public String getFilePath() { //get file File fileInstance=this.getFile(); String filePath=null; if(fileInstance!=null) { filePath=fileInstance.getPath(); } return filePath; }
java
public String getFilePath() { //get file File fileInstance=this.getFile(); String filePath=null; if(fileInstance!=null) { filePath=fileInstance.getPath(); } return filePath; }
[ "public", "String", "getFilePath", "(", ")", "{", "//get file", "File", "fileInstance", "=", "this", ".", "getFile", "(", ")", ";", "String", "filePath", "=", "null", ";", "if", "(", "fileInstance", "!=", "null", ")", "{", "filePath", "=", "fileInstance", ...
This function returns the path to the file to fax. @return The path to the file to fax
[ "This", "function", "returns", "the", "path", "to", "the", "file", "to", "fax", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/AbstractFaxJob.java#L29-L41
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/AbstractFaxJob.java
AbstractFaxJob.setFilePath
public void setFilePath(String filePath) { //create a new file File fileInstance=null; if(filePath!=null) { fileInstance=new File(filePath); } //set file this.setFile(fileInstance); }
java
public void setFilePath(String filePath) { //create a new file File fileInstance=null; if(filePath!=null) { fileInstance=new File(filePath); } //set file this.setFile(fileInstance); }
[ "public", "void", "setFilePath", "(", "String", "filePath", ")", "{", "//create a new file", "File", "fileInstance", "=", "null", ";", "if", "(", "filePath", "!=", "null", ")", "{", "fileInstance", "=", "new", "File", "(", "filePath", ")", ";", "}", "//set...
This function sets the path to the file to fax. @param filePath The path to the file to fax
[ "This", "function", "sets", "the", "path", "to", "the", "file", "to", "fax", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/AbstractFaxJob.java#L49-L60
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/AbstractFaxJob.java
AbstractFaxJob.addToStringAttributes
protected StringBuilder addToStringAttributes(String faxJobType) { //init buffer StringBuilder buffer=new StringBuilder(500); buffer.append(faxJobType); buffer.append(":"); //append values buffer.append(Logger.SYSTEM_EOL); buffer.append("ID: "); buffer.append(this.getID()); buffer.append(Logger.SYSTEM_EOL); buffer.append("File: "); buffer.append(this.getFilePath()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Priority: "); buffer.append(this.getPriority()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Target Address: "); buffer.append(this.getTargetAddress()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Target Name: "); buffer.append(this.getTargetName()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Sender Name: "); buffer.append(this.getSenderName()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Sender Fax Number: "); buffer.append(this.getSenderFaxNumber()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Sender Email: "); buffer.append(this.getSenderEmail()); return buffer; }
java
protected StringBuilder addToStringAttributes(String faxJobType) { //init buffer StringBuilder buffer=new StringBuilder(500); buffer.append(faxJobType); buffer.append(":"); //append values buffer.append(Logger.SYSTEM_EOL); buffer.append("ID: "); buffer.append(this.getID()); buffer.append(Logger.SYSTEM_EOL); buffer.append("File: "); buffer.append(this.getFilePath()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Priority: "); buffer.append(this.getPriority()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Target Address: "); buffer.append(this.getTargetAddress()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Target Name: "); buffer.append(this.getTargetName()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Sender Name: "); buffer.append(this.getSenderName()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Sender Fax Number: "); buffer.append(this.getSenderFaxNumber()); buffer.append(Logger.SYSTEM_EOL); buffer.append("Sender Email: "); buffer.append(this.getSenderEmail()); return buffer; }
[ "protected", "StringBuilder", "addToStringAttributes", "(", "String", "faxJobType", ")", "{", "//init buffer", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", "500", ")", ";", "buffer", ".", "append", "(", "faxJobType", ")", ";", "buffer", ".", "app...
This function adds the common attributes for the toString printing. @param faxJobType The fax job type @return The buffer used
[ "This", "function", "adds", "the", "common", "attributes", "for", "the", "toString", "printing", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/AbstractFaxJob.java#L69-L103
train
sagiegurari/fax4j
src/main/java/org/fax4j/spi/comm/CommFaxClientSpi.java
CommFaxClientSpi.createCommPortConnectionFactory
protected final CommPortConnectionFactory createCommPortConnectionFactory() { //create new instance CommPortConnectionFactory factory=(CommPortConnectionFactory)ReflectionHelper.createInstance(this.commConnectionFactoryClassName); //initialize factory.initialize(this); return factory; }
java
protected final CommPortConnectionFactory createCommPortConnectionFactory() { //create new instance CommPortConnectionFactory factory=(CommPortConnectionFactory)ReflectionHelper.createInstance(this.commConnectionFactoryClassName); //initialize factory.initialize(this); return factory; }
[ "protected", "final", "CommPortConnectionFactory", "createCommPortConnectionFactory", "(", ")", "{", "//create new instance", "CommPortConnectionFactory", "factory", "=", "(", "CommPortConnectionFactory", ")", "ReflectionHelper", ".", "createInstance", "(", "this", ".", "comm...
Creates and returns the COMM port connection factory. @return The COMM port connection factory
[ "Creates", "and", "returns", "the", "COMM", "port", "connection", "factory", "." ]
42fa51acabe7bf279e27ab3dd1cf76146b27955f
https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/comm/CommFaxClientSpi.java#L191-L200
train