id
int32
0
165k
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
159,300
intive-FDV/DynamicJasper
src/main/java/ar/com/fdvs/dj/domain/builders/ColumnBuilder.java
ColumnBuilder.addFieldProperty
public ColumnBuilder addFieldProperty(String propertyName, String value) { fieldProperties.put(propertyName, value); return this; }
java
public ColumnBuilder addFieldProperty(String propertyName, String value) { fieldProperties.put(propertyName, value); return this; }
[ "public", "ColumnBuilder", "addFieldProperty", "(", "String", "propertyName", ",", "String", "value", ")", "{", "fieldProperties", ".", "put", "(", "propertyName", ",", "value", ")", ";", "return", "this", ";", "}" ]
When the JRField needs properties, use this method. @param propertyName @param value @return
[ "When", "the", "JRField", "needs", "properties", "use", "this", "method", "." ]
63919574cc401ae40574d13129f628e66d1682a3
https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/builders/ColumnBuilder.java#L342-L345
159,301
intive-FDV/DynamicJasper
src/main/java/ar/com/fdvs/dj/util/Utils.java
Utils.copyProperties
public static void copyProperties(Object dest, Object orig){ try { if (orig != null && dest != null){ BeanUtils.copyProperties(dest, orig); PropertyUtils putils = new PropertyUtils(); PropertyDescriptor origDescriptors[] = putils.getPropertyDescriptors(orig); for (PropertyDescriptor origDescriptor : origDescriptors) { String name = origDescriptor.getName(); if ("class".equals(name)) { continue; // No point in trying to set an object's class } Class propertyType = origDescriptor.getPropertyType(); if (!Boolean.class.equals(propertyType) && !(Boolean.class.equals(propertyType))) continue; if (!putils.isReadable(orig, name)) { //because of bad convention Method m = orig.getClass().getMethod("is" + name.substring(0, 1).toUpperCase() + name.substring(1), (Class<?>[]) null); Object value = m.invoke(orig, (Object[]) null); if (putils.isWriteable(dest, name)) { BeanUtilsBean.getInstance().copyProperty(dest, name, value); } } } } } catch (Exception e) { throw new DJException("Could not copy properties for shared object: " + orig +", message: " + e.getMessage(),e); } }
java
public static void copyProperties(Object dest, Object orig){ try { if (orig != null && dest != null){ BeanUtils.copyProperties(dest, orig); PropertyUtils putils = new PropertyUtils(); PropertyDescriptor origDescriptors[] = putils.getPropertyDescriptors(orig); for (PropertyDescriptor origDescriptor : origDescriptors) { String name = origDescriptor.getName(); if ("class".equals(name)) { continue; // No point in trying to set an object's class } Class propertyType = origDescriptor.getPropertyType(); if (!Boolean.class.equals(propertyType) && !(Boolean.class.equals(propertyType))) continue; if (!putils.isReadable(orig, name)) { //because of bad convention Method m = orig.getClass().getMethod("is" + name.substring(0, 1).toUpperCase() + name.substring(1), (Class<?>[]) null); Object value = m.invoke(orig, (Object[]) null); if (putils.isWriteable(dest, name)) { BeanUtilsBean.getInstance().copyProperty(dest, name, value); } } } } } catch (Exception e) { throw new DJException("Could not copy properties for shared object: " + orig +", message: " + e.getMessage(),e); } }
[ "public", "static", "void", "copyProperties", "(", "Object", "dest", ",", "Object", "orig", ")", "{", "try", "{", "if", "(", "orig", "!=", "null", "&&", "dest", "!=", "null", ")", "{", "BeanUtils", ".", "copyProperties", "(", "dest", ",", "orig", ")", ";", "PropertyUtils", "putils", "=", "new", "PropertyUtils", "(", ")", ";", "PropertyDescriptor", "origDescriptors", "[", "]", "=", "putils", ".", "getPropertyDescriptors", "(", "orig", ")", ";", "for", "(", "PropertyDescriptor", "origDescriptor", ":", "origDescriptors", ")", "{", "String", "name", "=", "origDescriptor", ".", "getName", "(", ")", ";", "if", "(", "\"class\"", ".", "equals", "(", "name", ")", ")", "{", "continue", ";", "// No point in trying to set an object's class", "}", "Class", "propertyType", "=", "origDescriptor", ".", "getPropertyType", "(", ")", ";", "if", "(", "!", "Boolean", ".", "class", ".", "equals", "(", "propertyType", ")", "&&", "!", "(", "Boolean", ".", "class", ".", "equals", "(", "propertyType", ")", ")", ")", "continue", ";", "if", "(", "!", "putils", ".", "isReadable", "(", "orig", ",", "name", ")", ")", "{", "//because of bad convention", "Method", "m", "=", "orig", ".", "getClass", "(", ")", ".", "getMethod", "(", "\"is\"", "+", "name", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "name", ".", "substring", "(", "1", ")", ",", "(", "Class", "<", "?", ">", "[", "]", ")", "null", ")", ";", "Object", "value", "=", "m", ".", "invoke", "(", "orig", ",", "(", "Object", "[", "]", ")", "null", ")", ";", "if", "(", "putils", ".", "isWriteable", "(", "dest", ",", "name", ")", ")", "{", "BeanUtilsBean", ".", "getInstance", "(", ")", ".", "copyProperty", "(", "dest", ",", "name", ",", "value", ")", ";", "}", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "DJException", "(", "\"Could not copy properties for shared object: \"", "+", "orig", "+", "\", message: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
This takes into account objects that breaks the JavaBean convention and have as getter for Boolean objects an "isXXX" method. @param dest @param orig
[ "This", "takes", "into", "account", "objects", "that", "breaks", "the", "JavaBean", "convention", "and", "have", "as", "getter", "for", "Boolean", "objects", "an", "isXXX", "method", "." ]
63919574cc401ae40574d13129f628e66d1682a3
https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/util/Utils.java#L45-L77
159,302
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionParser.java
ConfigOptionParser.printSuggestion
private void printSuggestion( String arg, List<ConfigOption> co ) { List<ConfigOption> sortedList = new ArrayList<ConfigOption>( co ); Collections.sort( sortedList, new ConfigOptionLevenshteinDistance( arg ) ); System.err.println( "Parse error for argument \"" + arg + "\", did you mean " + sortedList.get( 0 ).getCommandLineOption() .showFlagInfo() + "? Ignoring for now." ); }
java
private void printSuggestion( String arg, List<ConfigOption> co ) { List<ConfigOption> sortedList = new ArrayList<ConfigOption>( co ); Collections.sort( sortedList, new ConfigOptionLevenshteinDistance( arg ) ); System.err.println( "Parse error for argument \"" + arg + "\", did you mean " + sortedList.get( 0 ).getCommandLineOption() .showFlagInfo() + "? Ignoring for now." ); }
[ "private", "void", "printSuggestion", "(", "String", "arg", ",", "List", "<", "ConfigOption", ">", "co", ")", "{", "List", "<", "ConfigOption", ">", "sortedList", "=", "new", "ArrayList", "<", "ConfigOption", ">", "(", "co", ")", ";", "Collections", ".", "sort", "(", "sortedList", ",", "new", "ConfigOptionLevenshteinDistance", "(", "arg", ")", ")", ";", "System", ".", "err", ".", "println", "(", "\"Parse error for argument \\\"\"", "+", "arg", "+", "\"\\\", did you mean \"", "+", "sortedList", ".", "get", "(", "0", ")", ".", "getCommandLineOption", "(", ")", ".", "showFlagInfo", "(", ")", "+", "\"? Ignoring for now.\"", ")", ";", "}" ]
Prints a suggestion to stderr for the argument based on the levenshtein distance metric @param arg the argument which could not be assigned to a flag @param co the {@link ConfigOption} List where every flag is stored
[ "Prints", "a", "suggestion", "to", "stderr", "for", "the", "argument", "based", "on", "the", "levenshtein", "distance", "metric" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionParser.java#L149-L155
159,303
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionParser.java
ConfigOptionParser.getFormat
public static ReportGenerator.Format getFormat( String... args ) { ConfigOptionParser configParser = new ConfigOptionParser(); List<ConfigOption> configOptions = Arrays.asList( format, help ); for( ConfigOption co : configOptions ) { if( co.hasDefault() ) { configParser.parsedOptions.put( co.getLongName(), co.getValue() ); } } for( String arg : args ) { configParser.commandLineLookup( arg, format, configOptions ); } // TODO properties // TODO environment if( !configParser.hasValue( format ) ) { configParser.printUsageAndExit( configOptions ); } return (ReportGenerator.Format) configParser.getValue( format ); }
java
public static ReportGenerator.Format getFormat( String... args ) { ConfigOptionParser configParser = new ConfigOptionParser(); List<ConfigOption> configOptions = Arrays.asList( format, help ); for( ConfigOption co : configOptions ) { if( co.hasDefault() ) { configParser.parsedOptions.put( co.getLongName(), co.getValue() ); } } for( String arg : args ) { configParser.commandLineLookup( arg, format, configOptions ); } // TODO properties // TODO environment if( !configParser.hasValue( format ) ) { configParser.printUsageAndExit( configOptions ); } return (ReportGenerator.Format) configParser.getValue( format ); }
[ "public", "static", "ReportGenerator", ".", "Format", "getFormat", "(", "String", "...", "args", ")", "{", "ConfigOptionParser", "configParser", "=", "new", "ConfigOptionParser", "(", ")", ";", "List", "<", "ConfigOption", ">", "configOptions", "=", "Arrays", ".", "asList", "(", "format", ",", "help", ")", ";", "for", "(", "ConfigOption", "co", ":", "configOptions", ")", "{", "if", "(", "co", ".", "hasDefault", "(", ")", ")", "{", "configParser", ".", "parsedOptions", ".", "put", "(", "co", ".", "getLongName", "(", ")", ",", "co", ".", "getValue", "(", ")", ")", ";", "}", "}", "for", "(", "String", "arg", ":", "args", ")", "{", "configParser", ".", "commandLineLookup", "(", "arg", ",", "format", ",", "configOptions", ")", ";", "}", "// TODO properties", "// TODO environment", "if", "(", "!", "configParser", ".", "hasValue", "(", "format", ")", ")", "{", "configParser", ".", "printUsageAndExit", "(", "configOptions", ")", ";", "}", "return", "(", "ReportGenerator", ".", "Format", ")", "configParser", ".", "getValue", "(", "format", ")", ";", "}" ]
Terminates with a help message if the parse is not successful @param args command line arguments to @return the format in a correct state
[ "Terminates", "with", "a", "help", "message", "if", "the", "parse", "is", "not", "successful" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionParser.java#L227-L248
159,304
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/text/PlainTextTableWriter.java
PlainTextTableWriter.handleNewLines
static List<List<String>> handleNewLines( List<List<String>> tableModel ) { List<List<String>> result = Lists.newArrayListWithExpectedSize( tableModel.size() ); for( List<String> row : tableModel ) { if( hasNewline( row ) ) { result.addAll( splitRow( row ) ); } else { result.add( row ); } } return result; }
java
static List<List<String>> handleNewLines( List<List<String>> tableModel ) { List<List<String>> result = Lists.newArrayListWithExpectedSize( tableModel.size() ); for( List<String> row : tableModel ) { if( hasNewline( row ) ) { result.addAll( splitRow( row ) ); } else { result.add( row ); } } return result; }
[ "static", "List", "<", "List", "<", "String", ">", ">", "handleNewLines", "(", "List", "<", "List", "<", "String", ">", ">", "tableModel", ")", "{", "List", "<", "List", "<", "String", ">>", "result", "=", "Lists", ".", "newArrayListWithExpectedSize", "(", "tableModel", ".", "size", "(", ")", ")", ";", "for", "(", "List", "<", "String", ">", "row", ":", "tableModel", ")", "{", "if", "(", "hasNewline", "(", "row", ")", ")", "{", "result", ".", "addAll", "(", "splitRow", "(", "row", ")", ")", ";", "}", "else", "{", "result", ".", "add", "(", "row", ")", ";", "}", "}", "return", "result", ";", "}" ]
Handles newlines by removing them and add new rows instead
[ "Handles", "newlines", "by", "removing", "them", "and", "add", "new", "rows", "instead" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/text/PlainTextTableWriter.java#L64-L76
159,305
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/ReportGenerator.java
ReportGenerator.generateHtml5Report
public static AbstractReportGenerator generateHtml5Report() { AbstractReportGenerator report; try { Class<?> aClass = new ReportGenerator().getClass().getClassLoader() .loadClass( "com.tngtech.jgiven.report.html5.Html5ReportGenerator" ); report = (AbstractReportGenerator) aClass.newInstance(); } catch( ClassNotFoundException e ) { throw new JGivenInstallationException( "The JGiven HTML5 Report Generator seems not to be on the classpath.\n" + "Ensure that you have a dependency to jgiven-html5-report." ); } catch( Exception e ) { throw new JGivenInternalDefectException( "The HTML5 Report Generator could not be instantiated.", e ); } return report; }
java
public static AbstractReportGenerator generateHtml5Report() { AbstractReportGenerator report; try { Class<?> aClass = new ReportGenerator().getClass().getClassLoader() .loadClass( "com.tngtech.jgiven.report.html5.Html5ReportGenerator" ); report = (AbstractReportGenerator) aClass.newInstance(); } catch( ClassNotFoundException e ) { throw new JGivenInstallationException( "The JGiven HTML5 Report Generator seems not to be on the classpath.\n" + "Ensure that you have a dependency to jgiven-html5-report." ); } catch( Exception e ) { throw new JGivenInternalDefectException( "The HTML5 Report Generator could not be instantiated.", e ); } return report; }
[ "public", "static", "AbstractReportGenerator", "generateHtml5Report", "(", ")", "{", "AbstractReportGenerator", "report", ";", "try", "{", "Class", "<", "?", ">", "aClass", "=", "new", "ReportGenerator", "(", ")", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ".", "loadClass", "(", "\"com.tngtech.jgiven.report.html5.Html5ReportGenerator\"", ")", ";", "report", "=", "(", "AbstractReportGenerator", ")", "aClass", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "JGivenInstallationException", "(", "\"The JGiven HTML5 Report Generator seems not to be on the classpath.\\n\"", "+", "\"Ensure that you have a dependency to jgiven-html5-report.\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "JGivenInternalDefectException", "(", "\"The HTML5 Report Generator could not be instantiated.\"", ",", "e", ")", ";", "}", "return", "report", ";", "}" ]
Searches the Html5ReportGenerator in Java path and instantiates the report
[ "Searches", "the", "Html5ReportGenerator", "in", "Java", "path", "and", "instantiates", "the", "report" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/ReportGenerator.java#L67-L80
159,306
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/model/StepFormatter.java
StepFormatter.flushCurrentWord
private static void flushCurrentWord( StringBuilder currentWords, List<Word> formattedWords, boolean cutWhitespace ) { if( currentWords.length() > 0 ) { if( cutWhitespace && currentWords.charAt( currentWords.length() - 1 ) == ' ' ) { currentWords.setLength( currentWords.length() - 1 ); } formattedWords.add( new Word( currentWords.toString() ) ); currentWords.setLength( 0 ); } }
java
private static void flushCurrentWord( StringBuilder currentWords, List<Word> formattedWords, boolean cutWhitespace ) { if( currentWords.length() > 0 ) { if( cutWhitespace && currentWords.charAt( currentWords.length() - 1 ) == ' ' ) { currentWords.setLength( currentWords.length() - 1 ); } formattedWords.add( new Word( currentWords.toString() ) ); currentWords.setLength( 0 ); } }
[ "private", "static", "void", "flushCurrentWord", "(", "StringBuilder", "currentWords", ",", "List", "<", "Word", ">", "formattedWords", ",", "boolean", "cutWhitespace", ")", "{", "if", "(", "currentWords", ".", "length", "(", ")", ">", "0", ")", "{", "if", "(", "cutWhitespace", "&&", "currentWords", ".", "charAt", "(", "currentWords", ".", "length", "(", ")", "-", "1", ")", "==", "'", "'", ")", "{", "currentWords", ".", "setLength", "(", "currentWords", ".", "length", "(", ")", "-", "1", ")", ";", "}", "formattedWords", ".", "add", "(", "new", "Word", "(", "currentWords", ".", "toString", "(", ")", ")", ")", ";", "currentWords", ".", "setLength", "(", "0", ")", ";", "}", "}" ]
Appends the accumulated words to the resulting words. Trailing whitespace is removed because of the postprocessing that inserts custom whitespace @param currentWords is the {@link StringBuilder} of the accumulated words @param formattedWords is the list that is being appended to
[ "Appends", "the", "accumulated", "words", "to", "the", "resulting", "words", ".", "Trailing", "whitespace", "is", "removed", "because", "of", "the", "postprocessing", "that", "inserts", "custom", "whitespace" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/model/StepFormatter.java#L302-L310
159,307
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/model/StepFormatter.java
StepFormatter.nextIndex
private static int nextIndex( String description, int defaultIndex ) { Pattern startsWithNumber = Pattern.compile( "(\\d+).*" ); Matcher matcher = startsWithNumber.matcher( description ); if( matcher.matches() ) { return Integer.parseInt( matcher.group( 1 ) ) - 1; } return defaultIndex; }
java
private static int nextIndex( String description, int defaultIndex ) { Pattern startsWithNumber = Pattern.compile( "(\\d+).*" ); Matcher matcher = startsWithNumber.matcher( description ); if( matcher.matches() ) { return Integer.parseInt( matcher.group( 1 ) ) - 1; } return defaultIndex; }
[ "private", "static", "int", "nextIndex", "(", "String", "description", ",", "int", "defaultIndex", ")", "{", "Pattern", "startsWithNumber", "=", "Pattern", ".", "compile", "(", "\"(\\\\d+).*\"", ")", ";", "Matcher", "matcher", "=", "startsWithNumber", ".", "matcher", "(", "description", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "return", "Integer", ".", "parseInt", "(", "matcher", ".", "group", "(", "1", ")", ")", "-", "1", ";", "}", "return", "defaultIndex", ";", "}" ]
Returns the next index of the argument by decrementing 1 from the possibly parsed number @param description this String will be searched from the start for a number @param defaultIndex this will be returned if the match does not succeed @return the parsed index or the defaultIndex
[ "Returns", "the", "next", "index", "of", "the", "argument", "by", "decrementing", "1", "from", "the", "possibly", "parsed", "number" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/model/StepFormatter.java#L319-L328
159,308
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/impl/util/WordUtil.java
WordUtil.capitalize
public static String capitalize( String text ) { if( text == null || text.isEmpty() ) { return text; } return text.substring( 0, 1 ).toUpperCase().concat( text.substring( 1, text.length() ) ); }
java
public static String capitalize( String text ) { if( text == null || text.isEmpty() ) { return text; } return text.substring( 0, 1 ).toUpperCase().concat( text.substring( 1, text.length() ) ); }
[ "public", "static", "String", "capitalize", "(", "String", "text", ")", "{", "if", "(", "text", "==", "null", "||", "text", ".", "isEmpty", "(", ")", ")", "{", "return", "text", ";", "}", "return", "text", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", ".", "concat", "(", "text", ".", "substring", "(", "1", ",", "text", ".", "length", "(", ")", ")", ")", ";", "}" ]
Returns the given text with the first letter in upper case. <h2>Examples:</h2> <pre> capitalize("hi") == "Hi" capitalize("Hi") == "Hi" capitalize("hi there") == "hi there" capitalize("") == "" capitalize(null) == null </pre> @param text the text to capitalize @return text with the first letter in upper case
[ "Returns", "the", "given", "text", "with", "the", "first", "letter", "in", "upper", "case", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/impl/util/WordUtil.java#L24-L29
159,309
TNG/JGiven
jgiven-html5-report/src/main/java/com/tngtech/jgiven/report/html5/Html5ReportGenerator.java
Html5ReportGenerator.deleteUnusedCaseSteps
private void deleteUnusedCaseSteps( ReportModel model ) { for( ScenarioModel scenarioModel : model.getScenarios() ) { if( scenarioModel.isCasesAsTable() && !hasAttachment( scenarioModel ) ) { List<ScenarioCaseModel> cases = scenarioModel.getScenarioCases(); for( int i = 1; i < cases.size(); i++ ) { ScenarioCaseModel caseModel = cases.get( i ); caseModel.setSteps( Collections.<StepModel>emptyList() ); } } } }
java
private void deleteUnusedCaseSteps( ReportModel model ) { for( ScenarioModel scenarioModel : model.getScenarios() ) { if( scenarioModel.isCasesAsTable() && !hasAttachment( scenarioModel ) ) { List<ScenarioCaseModel> cases = scenarioModel.getScenarioCases(); for( int i = 1; i < cases.size(); i++ ) { ScenarioCaseModel caseModel = cases.get( i ); caseModel.setSteps( Collections.<StepModel>emptyList() ); } } } }
[ "private", "void", "deleteUnusedCaseSteps", "(", "ReportModel", "model", ")", "{", "for", "(", "ScenarioModel", "scenarioModel", ":", "model", ".", "getScenarios", "(", ")", ")", "{", "if", "(", "scenarioModel", ".", "isCasesAsTable", "(", ")", "&&", "!", "hasAttachment", "(", "scenarioModel", ")", ")", "{", "List", "<", "ScenarioCaseModel", ">", "cases", "=", "scenarioModel", ".", "getScenarioCases", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "cases", ".", "size", "(", ")", ";", "i", "++", ")", "{", "ScenarioCaseModel", "caseModel", "=", "cases", ".", "get", "(", "i", ")", ";", "caseModel", ".", "setSteps", "(", "Collections", ".", "<", "StepModel", ">", "emptyList", "(", ")", ")", ";", "}", "}", "}", "}" ]
Deletes all steps of scenario cases where a data table is generated to reduce the size of the data file. In this case only the steps of the first scenario case are actually needed.
[ "Deletes", "all", "steps", "of", "scenario", "cases", "where", "a", "data", "table", "is", "generated", "to", "reduce", "the", "size", "of", "the", "data", "file", ".", "In", "this", "case", "only", "the", "steps", "of", "the", "first", "scenario", "case", "are", "actually", "needed", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-html5-report/src/main/java/com/tngtech/jgiven/report/html5/Html5ReportGenerator.java#L124-L135
159,310
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/analysis/CaseArgumentAnalyser.java
CaseArgumentAnalyser.attachmentsAreStructurallyDifferent
boolean attachmentsAreStructurallyDifferent( List<AttachmentModel> firstAttachments, List<AttachmentModel> otherAttachments ) { if( firstAttachments.size() != otherAttachments.size() ) { return true; } for( int i = 0; i < firstAttachments.size(); i++ ) { if( attachmentIsStructurallyDifferent( firstAttachments.get( i ), otherAttachments.get( i ) ) ) { return true; } } return false; }
java
boolean attachmentsAreStructurallyDifferent( List<AttachmentModel> firstAttachments, List<AttachmentModel> otherAttachments ) { if( firstAttachments.size() != otherAttachments.size() ) { return true; } for( int i = 0; i < firstAttachments.size(); i++ ) { if( attachmentIsStructurallyDifferent( firstAttachments.get( i ), otherAttachments.get( i ) ) ) { return true; } } return false; }
[ "boolean", "attachmentsAreStructurallyDifferent", "(", "List", "<", "AttachmentModel", ">", "firstAttachments", ",", "List", "<", "AttachmentModel", ">", "otherAttachments", ")", "{", "if", "(", "firstAttachments", ".", "size", "(", ")", "!=", "otherAttachments", ".", "size", "(", ")", ")", "{", "return", "true", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "firstAttachments", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "attachmentIsStructurallyDifferent", "(", "firstAttachments", ".", "get", "(", "i", ")", ",", "otherAttachments", ".", "get", "(", "i", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Attachments are only structurally different if one step has an inline attachment and the other step either has no inline attachment or the inline attachment is different.
[ "Attachments", "are", "only", "structurally", "different", "if", "one", "step", "has", "an", "inline", "attachment", "and", "the", "other", "step", "either", "has", "no", "inline", "attachment", "or", "the", "inline", "attachment", "is", "different", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/analysis/CaseArgumentAnalyser.java#L281-L292
159,311
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/analysis/CaseArgumentAnalyser.java
CaseArgumentAnalyser.getDifferentArguments
List<List<Word>> getDifferentArguments( List<List<Word>> argumentWords ) { List<List<Word>> result = Lists.newArrayList(); for( int i = 0; i < argumentWords.size(); i++ ) { result.add( Lists.<Word>newArrayList() ); } int nWords = argumentWords.get( 0 ).size(); for( int iWord = 0; iWord < nWords; iWord++ ) { Word wordOfFirstCase = argumentWords.get( 0 ).get( iWord ); // data tables have equal here, otherwise // the cases would be structurally different if( wordOfFirstCase.isDataTable() ) { continue; } boolean different = false; for( int iCase = 1; iCase < argumentWords.size(); iCase++ ) { Word wordOfCase = argumentWords.get( iCase ).get( iWord ); if( !wordOfCase.getFormattedValue().equals( wordOfFirstCase.getFormattedValue() ) ) { different = true; break; } } if( different ) { for( int iCase = 0; iCase < argumentWords.size(); iCase++ ) { result.get( iCase ).add( argumentWords.get( iCase ).get( iWord ) ); } } } return result; }
java
List<List<Word>> getDifferentArguments( List<List<Word>> argumentWords ) { List<List<Word>> result = Lists.newArrayList(); for( int i = 0; i < argumentWords.size(); i++ ) { result.add( Lists.<Word>newArrayList() ); } int nWords = argumentWords.get( 0 ).size(); for( int iWord = 0; iWord < nWords; iWord++ ) { Word wordOfFirstCase = argumentWords.get( 0 ).get( iWord ); // data tables have equal here, otherwise // the cases would be structurally different if( wordOfFirstCase.isDataTable() ) { continue; } boolean different = false; for( int iCase = 1; iCase < argumentWords.size(); iCase++ ) { Word wordOfCase = argumentWords.get( iCase ).get( iWord ); if( !wordOfCase.getFormattedValue().equals( wordOfFirstCase.getFormattedValue() ) ) { different = true; break; } } if( different ) { for( int iCase = 0; iCase < argumentWords.size(); iCase++ ) { result.get( iCase ).add( argumentWords.get( iCase ).get( iWord ) ); } } } return result; }
[ "List", "<", "List", "<", "Word", ">", ">", "getDifferentArguments", "(", "List", "<", "List", "<", "Word", ">", ">", "argumentWords", ")", "{", "List", "<", "List", "<", "Word", ">>", "result", "=", "Lists", ".", "newArrayList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "argumentWords", ".", "size", "(", ")", ";", "i", "++", ")", "{", "result", ".", "add", "(", "Lists", ".", "<", "Word", ">", "newArrayList", "(", ")", ")", ";", "}", "int", "nWords", "=", "argumentWords", ".", "get", "(", "0", ")", ".", "size", "(", ")", ";", "for", "(", "int", "iWord", "=", "0", ";", "iWord", "<", "nWords", ";", "iWord", "++", ")", "{", "Word", "wordOfFirstCase", "=", "argumentWords", ".", "get", "(", "0", ")", ".", "get", "(", "iWord", ")", ";", "// data tables have equal here, otherwise", "// the cases would be structurally different", "if", "(", "wordOfFirstCase", ".", "isDataTable", "(", ")", ")", "{", "continue", ";", "}", "boolean", "different", "=", "false", ";", "for", "(", "int", "iCase", "=", "1", ";", "iCase", "<", "argumentWords", ".", "size", "(", ")", ";", "iCase", "++", ")", "{", "Word", "wordOfCase", "=", "argumentWords", ".", "get", "(", "iCase", ")", ".", "get", "(", "iWord", ")", ";", "if", "(", "!", "wordOfCase", ".", "getFormattedValue", "(", ")", ".", "equals", "(", "wordOfFirstCase", ".", "getFormattedValue", "(", ")", ")", ")", "{", "different", "=", "true", ";", "break", ";", "}", "}", "if", "(", "different", ")", "{", "for", "(", "int", "iCase", "=", "0", ";", "iCase", "<", "argumentWords", ".", "size", "(", ")", ";", "iCase", "++", ")", "{", "result", ".", "get", "(", "iCase", ")", ".", "add", "(", "argumentWords", ".", "get", "(", "iCase", ")", ".", "get", "(", "iWord", ")", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
Returns a list with argument words that are not equal in all cases
[ "Returns", "a", "list", "with", "argument", "words", "that", "are", "not", "equal", "in", "all", "cases" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/analysis/CaseArgumentAnalyser.java#L355-L389
159,312
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/config/AbstractJGivenConfiguration.java
AbstractJGivenConfiguration.configureTag
public final TagConfiguration.Builder configureTag( Class<? extends Annotation> tagAnnotation ) { TagConfiguration configuration = new TagConfiguration( tagAnnotation ); tagConfigurations.put( tagAnnotation, configuration ); return new TagConfiguration.Builder( configuration ); }
java
public final TagConfiguration.Builder configureTag( Class<? extends Annotation> tagAnnotation ) { TagConfiguration configuration = new TagConfiguration( tagAnnotation ); tagConfigurations.put( tagAnnotation, configuration ); return new TagConfiguration.Builder( configuration ); }
[ "public", "final", "TagConfiguration", ".", "Builder", "configureTag", "(", "Class", "<", "?", "extends", "Annotation", ">", "tagAnnotation", ")", "{", "TagConfiguration", "configuration", "=", "new", "TagConfiguration", "(", "tagAnnotation", ")", ";", "tagConfigurations", ".", "put", "(", "tagAnnotation", ",", "configuration", ")", ";", "return", "new", "TagConfiguration", ".", "Builder", "(", "configuration", ")", ";", "}" ]
Configures the given annotation as a tag. This is useful if you want to treat annotations as tags in JGiven that you cannot or want not to be annotated with the {@link com.tngtech.jgiven.annotation.IsTag} annotation. @param tagAnnotation the tag to be configured @return a configuration builder for configuring the tag
[ "Configures", "the", "given", "annotation", "as", "a", "tag", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/config/AbstractJGivenConfiguration.java#L24-L28
159,313
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/impl/format/ParameterFormattingUtil.java
ParameterFormattingUtil.getFormatting
private StepFormatter.Formatting<?, ?> getFormatting( Annotation[] annotations, Set<Class<?>> visitedTypes, Annotation originalAnnotation, String parameterName ) { List<StepFormatter.Formatting<?, ?>> foundFormatting = Lists.newArrayList(); Table tableAnnotation = null; for( Annotation annotation : annotations ) { try { if( annotation instanceof Format ) { Format arg = (Format) annotation; foundFormatting.add( new StepFormatter.ArgumentFormatting( ReflectionUtil.newInstance( arg.value() ), arg.args() ) ); } else if( annotation instanceof Table ) { tableAnnotation = (Table) annotation; } else if( annotation instanceof AnnotationFormat ) { AnnotationFormat arg = (AnnotationFormat) annotation; foundFormatting.add( new StepFormatter.ArgumentFormatting( new StepFormatter.AnnotationBasedFormatter( arg.value().newInstance(), originalAnnotation ) ) ); } else { Class<? extends Annotation> annotationType = annotation.annotationType(); if( !visitedTypes.contains( annotationType ) ) { visitedTypes.add( annotationType ); StepFormatter.Formatting<?, ?> formatting = getFormatting( annotationType.getAnnotations(), visitedTypes, annotation, parameterName ); if( formatting != null ) { foundFormatting.add( formatting ); } } } } catch( Exception e ) { throw Throwables.propagate( e ); } } if( foundFormatting.size() > 1 ) { Formatting<?, ?> innerFormatting = Iterables.getLast( foundFormatting ); foundFormatting.remove( innerFormatting ); ChainedFormatting<?> chainedFormatting = new StepFormatter.ChainedFormatting<Object>( (ObjectFormatter<Object>) innerFormatting ); for( StepFormatter.Formatting<?, ?> formatting : Lists.reverse( foundFormatting ) ) { chainedFormatting.addFormatting( (StepFormatter.Formatting<?, String>) formatting ); } foundFormatting.clear(); foundFormatting.add( chainedFormatting ); } if( tableAnnotation != null ) { ObjectFormatter<?> objectFormatter = foundFormatting.isEmpty() ? DefaultFormatter.INSTANCE : foundFormatting.get( 0 ); return getTableFormatting( annotations, parameterName, tableAnnotation, objectFormatter ); } if( foundFormatting.isEmpty() ) { return null; } return foundFormatting.get( 0 ); }
java
private StepFormatter.Formatting<?, ?> getFormatting( Annotation[] annotations, Set<Class<?>> visitedTypes, Annotation originalAnnotation, String parameterName ) { List<StepFormatter.Formatting<?, ?>> foundFormatting = Lists.newArrayList(); Table tableAnnotation = null; for( Annotation annotation : annotations ) { try { if( annotation instanceof Format ) { Format arg = (Format) annotation; foundFormatting.add( new StepFormatter.ArgumentFormatting( ReflectionUtil.newInstance( arg.value() ), arg.args() ) ); } else if( annotation instanceof Table ) { tableAnnotation = (Table) annotation; } else if( annotation instanceof AnnotationFormat ) { AnnotationFormat arg = (AnnotationFormat) annotation; foundFormatting.add( new StepFormatter.ArgumentFormatting( new StepFormatter.AnnotationBasedFormatter( arg.value().newInstance(), originalAnnotation ) ) ); } else { Class<? extends Annotation> annotationType = annotation.annotationType(); if( !visitedTypes.contains( annotationType ) ) { visitedTypes.add( annotationType ); StepFormatter.Formatting<?, ?> formatting = getFormatting( annotationType.getAnnotations(), visitedTypes, annotation, parameterName ); if( formatting != null ) { foundFormatting.add( formatting ); } } } } catch( Exception e ) { throw Throwables.propagate( e ); } } if( foundFormatting.size() > 1 ) { Formatting<?, ?> innerFormatting = Iterables.getLast( foundFormatting ); foundFormatting.remove( innerFormatting ); ChainedFormatting<?> chainedFormatting = new StepFormatter.ChainedFormatting<Object>( (ObjectFormatter<Object>) innerFormatting ); for( StepFormatter.Formatting<?, ?> formatting : Lists.reverse( foundFormatting ) ) { chainedFormatting.addFormatting( (StepFormatter.Formatting<?, String>) formatting ); } foundFormatting.clear(); foundFormatting.add( chainedFormatting ); } if( tableAnnotation != null ) { ObjectFormatter<?> objectFormatter = foundFormatting.isEmpty() ? DefaultFormatter.INSTANCE : foundFormatting.get( 0 ); return getTableFormatting( annotations, parameterName, tableAnnotation, objectFormatter ); } if( foundFormatting.isEmpty() ) { return null; } return foundFormatting.get( 0 ); }
[ "private", "StepFormatter", ".", "Formatting", "<", "?", ",", "?", ">", "getFormatting", "(", "Annotation", "[", "]", "annotations", ",", "Set", "<", "Class", "<", "?", ">", ">", "visitedTypes", ",", "Annotation", "originalAnnotation", ",", "String", "parameterName", ")", "{", "List", "<", "StepFormatter", ".", "Formatting", "<", "?", ",", "?", ">", ">", "foundFormatting", "=", "Lists", ".", "newArrayList", "(", ")", ";", "Table", "tableAnnotation", "=", "null", ";", "for", "(", "Annotation", "annotation", ":", "annotations", ")", "{", "try", "{", "if", "(", "annotation", "instanceof", "Format", ")", "{", "Format", "arg", "=", "(", "Format", ")", "annotation", ";", "foundFormatting", ".", "add", "(", "new", "StepFormatter", ".", "ArgumentFormatting", "(", "ReflectionUtil", ".", "newInstance", "(", "arg", ".", "value", "(", ")", ")", ",", "arg", ".", "args", "(", ")", ")", ")", ";", "}", "else", "if", "(", "annotation", "instanceof", "Table", ")", "{", "tableAnnotation", "=", "(", "Table", ")", "annotation", ";", "}", "else", "if", "(", "annotation", "instanceof", "AnnotationFormat", ")", "{", "AnnotationFormat", "arg", "=", "(", "AnnotationFormat", ")", "annotation", ";", "foundFormatting", ".", "add", "(", "new", "StepFormatter", ".", "ArgumentFormatting", "(", "new", "StepFormatter", ".", "AnnotationBasedFormatter", "(", "arg", ".", "value", "(", ")", ".", "newInstance", "(", ")", ",", "originalAnnotation", ")", ")", ")", ";", "}", "else", "{", "Class", "<", "?", "extends", "Annotation", ">", "annotationType", "=", "annotation", ".", "annotationType", "(", ")", ";", "if", "(", "!", "visitedTypes", ".", "contains", "(", "annotationType", ")", ")", "{", "visitedTypes", ".", "add", "(", "annotationType", ")", ";", "StepFormatter", ".", "Formatting", "<", "?", ",", "?", ">", "formatting", "=", "getFormatting", "(", "annotationType", ".", "getAnnotations", "(", ")", ",", "visitedTypes", ",", "annotation", ",", "parameterName", ")", ";", "if", "(", "formatting", "!=", "null", ")", "{", "foundFormatting", ".", "add", "(", "formatting", ")", ";", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "Throwables", ".", "propagate", "(", "e", ")", ";", "}", "}", "if", "(", "foundFormatting", ".", "size", "(", ")", ">", "1", ")", "{", "Formatting", "<", "?", ",", "?", ">", "innerFormatting", "=", "Iterables", ".", "getLast", "(", "foundFormatting", ")", ";", "foundFormatting", ".", "remove", "(", "innerFormatting", ")", ";", "ChainedFormatting", "<", "?", ">", "chainedFormatting", "=", "new", "StepFormatter", ".", "ChainedFormatting", "<", "Object", ">", "(", "(", "ObjectFormatter", "<", "Object", ">", ")", "innerFormatting", ")", ";", "for", "(", "StepFormatter", ".", "Formatting", "<", "?", ",", "?", ">", "formatting", ":", "Lists", ".", "reverse", "(", "foundFormatting", ")", ")", "{", "chainedFormatting", ".", "addFormatting", "(", "(", "StepFormatter", ".", "Formatting", "<", "?", ",", "String", ">", ")", "formatting", ")", ";", "}", "foundFormatting", ".", "clear", "(", ")", ";", "foundFormatting", ".", "add", "(", "chainedFormatting", ")", ";", "}", "if", "(", "tableAnnotation", "!=", "null", ")", "{", "ObjectFormatter", "<", "?", ">", "objectFormatter", "=", "foundFormatting", ".", "isEmpty", "(", ")", "?", "DefaultFormatter", ".", "INSTANCE", ":", "foundFormatting", ".", "get", "(", "0", ")", ";", "return", "getTableFormatting", "(", "annotations", ",", "parameterName", ",", "tableAnnotation", ",", "objectFormatter", ")", ";", "}", "if", "(", "foundFormatting", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "return", "foundFormatting", ".", "get", "(", "0", ")", ";", "}" ]
Recursively searches for formatting annotations. @param visitedTypes used to prevent an endless loop @param parameterName
[ "Recursively", "searches", "for", "formatting", "annotations", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/impl/format/ParameterFormattingUtil.java#L59-L115
159,314
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/impl/Scenario.java
Scenario.create
public static <GIVEN, WHEN, THEN> Scenario<GIVEN, WHEN, THEN> create( Class<GIVEN> givenClass, Class<WHEN> whenClass, Class<THEN> thenClass ) { return new Scenario<GIVEN, WHEN, THEN>( givenClass, whenClass, thenClass ); }
java
public static <GIVEN, WHEN, THEN> Scenario<GIVEN, WHEN, THEN> create( Class<GIVEN> givenClass, Class<WHEN> whenClass, Class<THEN> thenClass ) { return new Scenario<GIVEN, WHEN, THEN>( givenClass, whenClass, thenClass ); }
[ "public", "static", "<", "GIVEN", ",", "WHEN", ",", "THEN", ">", "Scenario", "<", "GIVEN", ",", "WHEN", ",", "THEN", ">", "create", "(", "Class", "<", "GIVEN", ">", "givenClass", ",", "Class", "<", "WHEN", ">", "whenClass", ",", "Class", "<", "THEN", ">", "thenClass", ")", "{", "return", "new", "Scenario", "<", "GIVEN", ",", "WHEN", ",", "THEN", ">", "(", "givenClass", ",", "whenClass", ",", "thenClass", ")", ";", "}" ]
Creates a scenario with 3 different steps classes. To share state between the different steps instances use the {@link com.tngtech.jgiven.annotation.ScenarioState} annotation @param givenClass the Given steps class @param whenClass the When steps class @param thenClass the Then steps class @return the new scenario
[ "Creates", "a", "scenario", "with", "3", "different", "steps", "classes", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/impl/Scenario.java#L59-L62
159,315
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/impl/Scenario.java
Scenario.startScenario
@Override public Scenario<GIVEN, WHEN, THEN> startScenario( String description ) { super.startScenario( description ); return this; }
java
@Override public Scenario<GIVEN, WHEN, THEN> startScenario( String description ) { super.startScenario( description ); return this; }
[ "@", "Override", "public", "Scenario", "<", "GIVEN", ",", "WHEN", ",", "THEN", ">", "startScenario", "(", "String", "description", ")", "{", "super", ".", "startScenario", "(", "description", ")", ";", "return", "this", ";", "}" ]
Describes the scenario. Must be called before any step invocation. @param description the description @return this for a fluent interface
[ "Describes", "the", "scenario", ".", "Must", "be", "called", "before", "any", "step", "invocation", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/impl/Scenario.java#L82-L87
159,316
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/impl/ScenarioExecutor.java
ScenarioExecutor.wireSteps
public void wireSteps( CanWire canWire ) { for( StageState steps : stages.values() ) { canWire.wire( steps.instance ); } }
java
public void wireSteps( CanWire canWire ) { for( StageState steps : stages.values() ) { canWire.wire( steps.instance ); } }
[ "public", "void", "wireSteps", "(", "CanWire", "canWire", ")", "{", "for", "(", "StageState", "steps", ":", "stages", ".", "values", "(", ")", ")", "{", "canWire", ".", "wire", "(", "steps", ".", "instance", ")", ";", "}", "}" ]
Used for DI frameworks to inject values into stages.
[ "Used", "for", "DI", "frameworks", "to", "inject", "values", "into", "stages", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/impl/ScenarioExecutor.java#L338-L342
159,317
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/impl/ScenarioExecutor.java
ScenarioExecutor.finished
public void finished() throws Throwable { if( state == FINISHED ) { return; } State previousState = state; state = FINISHED; methodInterceptor.enableMethodInterception( false ); try { if( previousState == STARTED ) { callFinishLifeCycleMethods(); } } finally { listener.scenarioFinished(); } }
java
public void finished() throws Throwable { if( state == FINISHED ) { return; } State previousState = state; state = FINISHED; methodInterceptor.enableMethodInterception( false ); try { if( previousState == STARTED ) { callFinishLifeCycleMethods(); } } finally { listener.scenarioFinished(); } }
[ "public", "void", "finished", "(", ")", "throws", "Throwable", "{", "if", "(", "state", "==", "FINISHED", ")", "{", "return", ";", "}", "State", "previousState", "=", "state", ";", "state", "=", "FINISHED", ";", "methodInterceptor", ".", "enableMethodInterception", "(", "false", ")", ";", "try", "{", "if", "(", "previousState", "==", "STARTED", ")", "{", "callFinishLifeCycleMethods", "(", ")", ";", "}", "}", "finally", "{", "listener", ".", "scenarioFinished", "(", ")", ";", "}", "}" ]
Has to be called when the scenario is finished in order to execute after methods.
[ "Has", "to", "be", "called", "when", "the", "scenario", "is", "finished", "in", "order", "to", "execute", "after", "methods", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/impl/ScenarioExecutor.java#L347-L364
159,318
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/impl/ScenarioExecutor.java
ScenarioExecutor.startScenario
public void startScenario( Class<?> testClass, Method method, List<NamedArgument> arguments ) { listener.scenarioStarted( testClass, method, arguments ); if( method.isAnnotationPresent( Pending.class ) ) { Pending annotation = method.getAnnotation( Pending.class ); if( annotation.failIfPass() ) { failIfPass(); } else if( !annotation.executeSteps() ) { methodInterceptor.disableMethodExecution(); executeLifeCycleMethods = false; } suppressExceptions = true; } else if( method.isAnnotationPresent( NotImplementedYet.class ) ) { NotImplementedYet annotation = method.getAnnotation( NotImplementedYet.class ); if( annotation.failIfPass() ) { failIfPass(); } else if( !annotation.executeSteps() ) { methodInterceptor.disableMethodExecution(); executeLifeCycleMethods = false; } suppressExceptions = true; } }
java
public void startScenario( Class<?> testClass, Method method, List<NamedArgument> arguments ) { listener.scenarioStarted( testClass, method, arguments ); if( method.isAnnotationPresent( Pending.class ) ) { Pending annotation = method.getAnnotation( Pending.class ); if( annotation.failIfPass() ) { failIfPass(); } else if( !annotation.executeSteps() ) { methodInterceptor.disableMethodExecution(); executeLifeCycleMethods = false; } suppressExceptions = true; } else if( method.isAnnotationPresent( NotImplementedYet.class ) ) { NotImplementedYet annotation = method.getAnnotation( NotImplementedYet.class ); if( annotation.failIfPass() ) { failIfPass(); } else if( !annotation.executeSteps() ) { methodInterceptor.disableMethodExecution(); executeLifeCycleMethods = false; } suppressExceptions = true; } }
[ "public", "void", "startScenario", "(", "Class", "<", "?", ">", "testClass", ",", "Method", "method", ",", "List", "<", "NamedArgument", ">", "arguments", ")", "{", "listener", ".", "scenarioStarted", "(", "testClass", ",", "method", ",", "arguments", ")", ";", "if", "(", "method", ".", "isAnnotationPresent", "(", "Pending", ".", "class", ")", ")", "{", "Pending", "annotation", "=", "method", ".", "getAnnotation", "(", "Pending", ".", "class", ")", ";", "if", "(", "annotation", ".", "failIfPass", "(", ")", ")", "{", "failIfPass", "(", ")", ";", "}", "else", "if", "(", "!", "annotation", ".", "executeSteps", "(", ")", ")", "{", "methodInterceptor", ".", "disableMethodExecution", "(", ")", ";", "executeLifeCycleMethods", "=", "false", ";", "}", "suppressExceptions", "=", "true", ";", "}", "else", "if", "(", "method", ".", "isAnnotationPresent", "(", "NotImplementedYet", ".", "class", ")", ")", "{", "NotImplementedYet", "annotation", "=", "method", ".", "getAnnotation", "(", "NotImplementedYet", ".", "class", ")", ";", "if", "(", "annotation", ".", "failIfPass", "(", ")", ")", "{", "failIfPass", "(", ")", ";", "}", "else", "if", "(", "!", "annotation", ".", "executeSteps", "(", ")", ")", "{", "methodInterceptor", ".", "disableMethodExecution", "(", ")", ";", "executeLifeCycleMethods", "=", "false", ";", "}", "suppressExceptions", "=", "true", ";", "}", "}" ]
Starts the scenario with the given method and arguments. Derives the description from the method name. @param method the method that started the scenario @param arguments the test arguments with their parameter names
[ "Starts", "the", "scenario", "with", "the", "given", "method", "and", "arguments", ".", "Derives", "the", "description", "from", "the", "method", "name", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/impl/ScenarioExecutor.java#L461-L486
159,319
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionBuilder.java
ConfigOptionBuilder.setCommandLineOptionWithArgument
public ConfigOptionBuilder setCommandLineOptionWithArgument( CommandLineOption commandLineOption, StringConverter converter ) { co.setCommandLineOption( commandLineOption ); return setStringConverter( converter ); }
java
public ConfigOptionBuilder setCommandLineOptionWithArgument( CommandLineOption commandLineOption, StringConverter converter ) { co.setCommandLineOption( commandLineOption ); return setStringConverter( converter ); }
[ "public", "ConfigOptionBuilder", "setCommandLineOptionWithArgument", "(", "CommandLineOption", "commandLineOption", ",", "StringConverter", "converter", ")", "{", "co", ".", "setCommandLineOption", "(", "commandLineOption", ")", ";", "return", "setStringConverter", "(", "converter", ")", ";", "}" ]
if you want to parse an argument, you need a converter from String to Object @param commandLineOption specification of the command line options @param converter how to convert your String value to a castable Object
[ "if", "you", "want", "to", "parse", "an", "argument", "you", "need", "a", "converter", "from", "String", "to", "Object" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionBuilder.java#L30-L33
159,320
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionBuilder.java
ConfigOptionBuilder.setCommandLineOptionWithoutArgument
public ConfigOptionBuilder setCommandLineOptionWithoutArgument( CommandLineOption commandLineOption, Object value ) { co.setCommandLineOption( commandLineOption ); co.setValue( value ); return this; }
java
public ConfigOptionBuilder setCommandLineOptionWithoutArgument( CommandLineOption commandLineOption, Object value ) { co.setCommandLineOption( commandLineOption ); co.setValue( value ); return this; }
[ "public", "ConfigOptionBuilder", "setCommandLineOptionWithoutArgument", "(", "CommandLineOption", "commandLineOption", ",", "Object", "value", ")", "{", "co", ".", "setCommandLineOption", "(", "commandLineOption", ")", ";", "co", ".", "setValue", "(", "value", ")", ";", "return", "this", ";", "}" ]
if you don't have an argument, choose the value that is going to be inserted into the map instead @param commandLineOption specification of the command line options @param value the value that is going to be inserted into the map instead of the argument
[ "if", "you", "don", "t", "have", "an", "argument", "choose", "the", "value", "that", "is", "going", "to", "be", "inserted", "into", "the", "map", "instead" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionBuilder.java#L41-L45
159,321
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionBuilder.java
ConfigOptionBuilder.setDefaultWith
public ConfigOptionBuilder setDefaultWith( Object defaultValue ) { co.setHasDefault( true ); co.setValue( defaultValue ); return setOptional(); }
java
public ConfigOptionBuilder setDefaultWith( Object defaultValue ) { co.setHasDefault( true ); co.setValue( defaultValue ); return setOptional(); }
[ "public", "ConfigOptionBuilder", "setDefaultWith", "(", "Object", "defaultValue", ")", "{", "co", ".", "setHasDefault", "(", "true", ")", ";", "co", ".", "setValue", "(", "defaultValue", ")", ";", "return", "setOptional", "(", ")", ";", "}" ]
if you have a default, it's automatically optional
[ "if", "you", "have", "a", "default", "it", "s", "automatically", "optional" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionBuilder.java#L77-L81
159,322
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionBuilder.java
ConfigOptionBuilder.setStringConverter
public ConfigOptionBuilder setStringConverter( StringConverter converter ) { co.setConverter( converter ); co.setHasArgument( true ); return this; }
java
public ConfigOptionBuilder setStringConverter( StringConverter converter ) { co.setConverter( converter ); co.setHasArgument( true ); return this; }
[ "public", "ConfigOptionBuilder", "setStringConverter", "(", "StringConverter", "converter", ")", "{", "co", ".", "setConverter", "(", "converter", ")", ";", "co", ".", "setHasArgument", "(", "true", ")", ";", "return", "this", ";", "}" ]
if you want to convert some string to an object, you have an argument to parse
[ "if", "you", "want", "to", "convert", "some", "string", "to", "an", "object", "you", "have", "an", "argument", "to", "parse" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/report/config/ConfigOptionBuilder.java#L86-L90
159,323
TNG/JGiven
jgiven-junit5/src/main/java/com/tngtech/jgiven/junit5/ArgumentReflectionUtil.java
ArgumentReflectionUtil.getNamedArgs
static List<NamedArgument> getNamedArgs( ExtensionContext context ) { List<NamedArgument> namedArgs = new ArrayList<>(); if( context.getTestMethod().get().getParameterCount() > 0 ) { try { if( context.getClass().getCanonicalName().equals( METHOD_EXTENSION_CONTEXT ) ) { Field field = context.getClass().getSuperclass().getDeclaredField( "testDescriptor" ); Object testDescriptor = ReflectionUtil.getFieldValueOrNull( field, context, ERROR ); if( testDescriptor != null && testDescriptor.getClass().getCanonicalName().equals( TEST_TEMPLATE_INVOCATION_TEST_DESCRIPTOR ) ) { Object invocationContext = ReflectionUtil.getFieldValueOrNull( "invocationContext", testDescriptor, ERROR ); if( invocationContext != null && invocationContext.getClass().getCanonicalName().equals( PARAMETERIZED_TEST_INVOCATION_CONTEXT ) ) { Object arguments = ReflectionUtil.getFieldValueOrNull( "arguments", invocationContext, ERROR ); List<Object> args = Arrays.asList( (Object[]) arguments ); namedArgs = ParameterNameUtil.mapArgumentsWithParameterNames( context.getTestMethod().get(), args ); } } } } catch( Exception e ) { log.warn( ERROR, e ); } } return namedArgs; }
java
static List<NamedArgument> getNamedArgs( ExtensionContext context ) { List<NamedArgument> namedArgs = new ArrayList<>(); if( context.getTestMethod().get().getParameterCount() > 0 ) { try { if( context.getClass().getCanonicalName().equals( METHOD_EXTENSION_CONTEXT ) ) { Field field = context.getClass().getSuperclass().getDeclaredField( "testDescriptor" ); Object testDescriptor = ReflectionUtil.getFieldValueOrNull( field, context, ERROR ); if( testDescriptor != null && testDescriptor.getClass().getCanonicalName().equals( TEST_TEMPLATE_INVOCATION_TEST_DESCRIPTOR ) ) { Object invocationContext = ReflectionUtil.getFieldValueOrNull( "invocationContext", testDescriptor, ERROR ); if( invocationContext != null && invocationContext.getClass().getCanonicalName().equals( PARAMETERIZED_TEST_INVOCATION_CONTEXT ) ) { Object arguments = ReflectionUtil.getFieldValueOrNull( "arguments", invocationContext, ERROR ); List<Object> args = Arrays.asList( (Object[]) arguments ); namedArgs = ParameterNameUtil.mapArgumentsWithParameterNames( context.getTestMethod().get(), args ); } } } } catch( Exception e ) { log.warn( ERROR, e ); } } return namedArgs; }
[ "static", "List", "<", "NamedArgument", ">", "getNamedArgs", "(", "ExtensionContext", "context", ")", "{", "List", "<", "NamedArgument", ">", "namedArgs", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "context", ".", "getTestMethod", "(", ")", ".", "get", "(", ")", ".", "getParameterCount", "(", ")", ">", "0", ")", "{", "try", "{", "if", "(", "context", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", ".", "equals", "(", "METHOD_EXTENSION_CONTEXT", ")", ")", "{", "Field", "field", "=", "context", ".", "getClass", "(", ")", ".", "getSuperclass", "(", ")", ".", "getDeclaredField", "(", "\"testDescriptor\"", ")", ";", "Object", "testDescriptor", "=", "ReflectionUtil", ".", "getFieldValueOrNull", "(", "field", ",", "context", ",", "ERROR", ")", ";", "if", "(", "testDescriptor", "!=", "null", "&&", "testDescriptor", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", ".", "equals", "(", "TEST_TEMPLATE_INVOCATION_TEST_DESCRIPTOR", ")", ")", "{", "Object", "invocationContext", "=", "ReflectionUtil", ".", "getFieldValueOrNull", "(", "\"invocationContext\"", ",", "testDescriptor", ",", "ERROR", ")", ";", "if", "(", "invocationContext", "!=", "null", "&&", "invocationContext", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", ".", "equals", "(", "PARAMETERIZED_TEST_INVOCATION_CONTEXT", ")", ")", "{", "Object", "arguments", "=", "ReflectionUtil", ".", "getFieldValueOrNull", "(", "\"arguments\"", ",", "invocationContext", ",", "ERROR", ")", ";", "List", "<", "Object", ">", "args", "=", "Arrays", ".", "asList", "(", "(", "Object", "[", "]", ")", "arguments", ")", ";", "namedArgs", "=", "ParameterNameUtil", ".", "mapArgumentsWithParameterNames", "(", "context", ".", "getTestMethod", "(", ")", ".", "get", "(", ")", ",", "args", ")", ";", "}", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "warn", "(", "ERROR", ",", "e", ")", ";", "}", "}", "return", "namedArgs", ";", "}" ]
This is a very ugly workaround to get the method arguments from the JUnit 5 context via reflection.
[ "This", "is", "a", "very", "ugly", "workaround", "to", "get", "the", "method", "arguments", "from", "the", "JUnit", "5", "context", "via", "reflection", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-junit5/src/main/java/com/tngtech/jgiven/junit5/ArgumentReflectionUtil.java#L29-L54
159,324
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/attachment/Attachment.java
Attachment.fromBinaryBytes
public static Attachment fromBinaryBytes( byte[] bytes, MediaType mediaType ) { if( !mediaType.isBinary() ) { throw new IllegalArgumentException( "MediaType must be binary" ); } return new Attachment(BaseEncoding.base64().encode( bytes ), mediaType, null ); }
java
public static Attachment fromBinaryBytes( byte[] bytes, MediaType mediaType ) { if( !mediaType.isBinary() ) { throw new IllegalArgumentException( "MediaType must be binary" ); } return new Attachment(BaseEncoding.base64().encode( bytes ), mediaType, null ); }
[ "public", "static", "Attachment", "fromBinaryBytes", "(", "byte", "[", "]", "bytes", ",", "MediaType", "mediaType", ")", "{", "if", "(", "!", "mediaType", ".", "isBinary", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"MediaType must be binary\"", ")", ";", "}", "return", "new", "Attachment", "(", "BaseEncoding", ".", "base64", "(", ")", ".", "encode", "(", "bytes", ")", ",", "mediaType", ",", "null", ")", ";", "}" ]
Creates an attachment from a given array of bytes. The bytes will be Base64 encoded. @throws java.lang.IllegalArgumentException if mediaType is not binary
[ "Creates", "an", "attachment", "from", "a", "given", "array", "of", "bytes", ".", "The", "bytes", "will", "be", "Base64", "encoded", "." ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/attachment/Attachment.java#L163-L168
159,325
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/attachment/Attachment.java
Attachment.fromBinaryInputStream
public static Attachment fromBinaryInputStream( InputStream inputStream, MediaType mediaType ) throws IOException { return fromBinaryBytes( ByteStreams.toByteArray( inputStream ), mediaType ); }
java
public static Attachment fromBinaryInputStream( InputStream inputStream, MediaType mediaType ) throws IOException { return fromBinaryBytes( ByteStreams.toByteArray( inputStream ), mediaType ); }
[ "public", "static", "Attachment", "fromBinaryInputStream", "(", "InputStream", "inputStream", ",", "MediaType", "mediaType", ")", "throws", "IOException", "{", "return", "fromBinaryBytes", "(", "ByteStreams", ".", "toByteArray", "(", "inputStream", ")", ",", "mediaType", ")", ";", "}" ]
Creates an attachment from a binary input stream. The content of the stream will be transformed into a Base64 encoded string @throws IOException if an I/O error occurs @throws java.lang.IllegalArgumentException if mediaType is not binary
[ "Creates", "an", "attachment", "from", "a", "binary", "input", "stream", ".", "The", "content", "of", "the", "stream", "will", "be", "transformed", "into", "a", "Base64", "encoded", "string" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/attachment/Attachment.java#L176-L178
159,326
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/attachment/MediaType.java
MediaType.binary
public static MediaType binary( MediaType.Type type, String subType ) { return new MediaType( type, subType, true ); }
java
public static MediaType binary( MediaType.Type type, String subType ) { return new MediaType( type, subType, true ); }
[ "public", "static", "MediaType", "binary", "(", "MediaType", ".", "Type", "type", ",", "String", "subType", ")", "{", "return", "new", "MediaType", "(", "type", ",", "subType", ",", "true", ")", ";", "}" ]
Creates a binary media type with the given type and subtype @throws com.tngtech.jgiven.exception.JGivenWrongUsageException if any of the given arguments is {@code null}
[ "Creates", "a", "binary", "media", "type", "with", "the", "given", "type", "and", "subtype" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/attachment/MediaType.java#L177-L179
159,327
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/attachment/MediaType.java
MediaType.nonBinary
public static MediaType nonBinary( MediaType.Type type, String subType, Charset charSet ) { ApiUtil.notNull( charSet, "charset must not be null" ); return new MediaType( type, subType, charSet ); }
java
public static MediaType nonBinary( MediaType.Type type, String subType, Charset charSet ) { ApiUtil.notNull( charSet, "charset must not be null" ); return new MediaType( type, subType, charSet ); }
[ "public", "static", "MediaType", "nonBinary", "(", "MediaType", ".", "Type", "type", ",", "String", "subType", ",", "Charset", "charSet", ")", "{", "ApiUtil", ".", "notNull", "(", "charSet", ",", "\"charset must not be null\"", ")", ";", "return", "new", "MediaType", "(", "type", ",", "subType", ",", "charSet", ")", ";", "}" ]
Creates a non-binary media type with the given type, subtype, and charSet @throws com.tngtech.jgiven.exception.JGivenWrongUsageException if any of the given arguments is {@code null}
[ "Creates", "a", "non", "-", "binary", "media", "type", "with", "the", "given", "type", "subtype", "and", "charSet" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/attachment/MediaType.java#L185-L188
159,328
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/attachment/MediaType.java
MediaType.nonBinaryUtf8
public static MediaType nonBinaryUtf8( MediaType.Type type, String subType ) { return new MediaType( type, subType, UTF_8 ); }
java
public static MediaType nonBinaryUtf8( MediaType.Type type, String subType ) { return new MediaType( type, subType, UTF_8 ); }
[ "public", "static", "MediaType", "nonBinaryUtf8", "(", "MediaType", ".", "Type", "type", ",", "String", "subType", ")", "{", "return", "new", "MediaType", "(", "type", ",", "subType", ",", "UTF_8", ")", ";", "}" ]
Creates a non-binary media type with the given type, subtype, and UTF-8 encoding @throws com.tngtech.jgiven.exception.JGivenWrongUsageException if any of the given arguments is {@code null}
[ "Creates", "a", "non", "-", "binary", "media", "type", "with", "the", "given", "type", "subtype", "and", "UTF", "-", "8", "encoding" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/attachment/MediaType.java#L194-L196
159,329
TNG/JGiven
jgiven-core/src/main/java/com/tngtech/jgiven/attachment/MediaType.java
MediaType.text
public static MediaType text( String subType, Charset charset ) { return nonBinary( TEXT, subType, charset ); }
java
public static MediaType text( String subType, Charset charset ) { return nonBinary( TEXT, subType, charset ); }
[ "public", "static", "MediaType", "text", "(", "String", "subType", ",", "Charset", "charset", ")", "{", "return", "nonBinary", "(", "TEXT", ",", "subType", ",", "charset", ")", ";", "}" ]
Creates a non-binary text media type with the given subtype and a specified encoding
[ "Creates", "a", "non", "-", "binary", "text", "media", "type", "with", "the", "given", "subtype", "and", "a", "specified", "encoding" ]
1a69248fc6d7eb380cdc4542e3be273842889748
https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/attachment/MediaType.java#L252-L254
159,330
mojohaus/build-helper-maven-plugin
src/main/java/org/codehaus/mojo/buildhelper/ParseVersionMojo.java
ParseVersionMojo.parseVersion
public void parseVersion( String version ) { DefaultVersioning artifactVersion = new DefaultVersioning( version ); getLog().debug( "Parsed Version" ); getLog().debug( " major: " + artifactVersion.getMajor() ); getLog().debug( " minor: " + artifactVersion.getMinor() ); getLog().debug( " incremental: " + artifactVersion.getPatch() ); getLog().debug( " buildnumber: " + artifactVersion.getBuildNumber() ); getLog().debug( " qualifier: " + artifactVersion.getQualifier() ); defineVersionProperty( "majorVersion", artifactVersion.getMajor() ); defineVersionProperty( "minorVersion", artifactVersion.getMinor() ); defineVersionProperty( "incrementalVersion", artifactVersion.getPatch() ); defineVersionProperty( "buildNumber", artifactVersion.getBuildNumber() ); defineVersionProperty( "nextMajorVersion", artifactVersion.getMajor() + 1 ); defineVersionProperty( "nextMinorVersion", artifactVersion.getMinor() + 1 ); defineVersionProperty( "nextIncrementalVersion", artifactVersion.getPatch() + 1 ); defineVersionProperty( "nextBuildNumber", artifactVersion.getBuildNumber() + 1 ); defineFormattedVersionProperty( "majorVersion", String.format( formatMajor, artifactVersion.getMajor() ) ); defineFormattedVersionProperty( "minorVersion", String.format( formatMinor, artifactVersion.getMinor() ) ); defineFormattedVersionProperty( "incrementalVersion", String.format( formatIncremental, artifactVersion.getPatch() ) ); defineFormattedVersionProperty( "buildNumber", String.format( formatBuildNumber, artifactVersion.getBuildNumber() )); defineFormattedVersionProperty( "nextMajorVersion", String.format( formatMajor, artifactVersion.getMajor() + 1 )); defineFormattedVersionProperty( "nextMinorVersion", String.format( formatMinor, artifactVersion.getMinor() + 1 )); defineFormattedVersionProperty( "nextIncrementalVersion", String.format( formatIncremental, artifactVersion.getPatch() + 1 )); defineFormattedVersionProperty( "nextBuildNumber", String.format( formatBuildNumber, artifactVersion.getBuildNumber() + 1 )); String osgi = artifactVersion.getAsOSGiVersion(); String qualifier = artifactVersion.getQualifier(); String qualifierQuestion = ""; if ( qualifier == null ) { qualifier = ""; } else { qualifierQuestion = qualifierPrefix; } defineVersionProperty( "qualifier", qualifier ); defineVersionProperty( "qualifier?", qualifierQuestion + qualifier ); defineVersionProperty( "osgiVersion", osgi ); }
java
public void parseVersion( String version ) { DefaultVersioning artifactVersion = new DefaultVersioning( version ); getLog().debug( "Parsed Version" ); getLog().debug( " major: " + artifactVersion.getMajor() ); getLog().debug( " minor: " + artifactVersion.getMinor() ); getLog().debug( " incremental: " + artifactVersion.getPatch() ); getLog().debug( " buildnumber: " + artifactVersion.getBuildNumber() ); getLog().debug( " qualifier: " + artifactVersion.getQualifier() ); defineVersionProperty( "majorVersion", artifactVersion.getMajor() ); defineVersionProperty( "minorVersion", artifactVersion.getMinor() ); defineVersionProperty( "incrementalVersion", artifactVersion.getPatch() ); defineVersionProperty( "buildNumber", artifactVersion.getBuildNumber() ); defineVersionProperty( "nextMajorVersion", artifactVersion.getMajor() + 1 ); defineVersionProperty( "nextMinorVersion", artifactVersion.getMinor() + 1 ); defineVersionProperty( "nextIncrementalVersion", artifactVersion.getPatch() + 1 ); defineVersionProperty( "nextBuildNumber", artifactVersion.getBuildNumber() + 1 ); defineFormattedVersionProperty( "majorVersion", String.format( formatMajor, artifactVersion.getMajor() ) ); defineFormattedVersionProperty( "minorVersion", String.format( formatMinor, artifactVersion.getMinor() ) ); defineFormattedVersionProperty( "incrementalVersion", String.format( formatIncremental, artifactVersion.getPatch() ) ); defineFormattedVersionProperty( "buildNumber", String.format( formatBuildNumber, artifactVersion.getBuildNumber() )); defineFormattedVersionProperty( "nextMajorVersion", String.format( formatMajor, artifactVersion.getMajor() + 1 )); defineFormattedVersionProperty( "nextMinorVersion", String.format( formatMinor, artifactVersion.getMinor() + 1 )); defineFormattedVersionProperty( "nextIncrementalVersion", String.format( formatIncremental, artifactVersion.getPatch() + 1 )); defineFormattedVersionProperty( "nextBuildNumber", String.format( formatBuildNumber, artifactVersion.getBuildNumber() + 1 )); String osgi = artifactVersion.getAsOSGiVersion(); String qualifier = artifactVersion.getQualifier(); String qualifierQuestion = ""; if ( qualifier == null ) { qualifier = ""; } else { qualifierQuestion = qualifierPrefix; } defineVersionProperty( "qualifier", qualifier ); defineVersionProperty( "qualifier?", qualifierQuestion + qualifier ); defineVersionProperty( "osgiVersion", osgi ); }
[ "public", "void", "parseVersion", "(", "String", "version", ")", "{", "DefaultVersioning", "artifactVersion", "=", "new", "DefaultVersioning", "(", "version", ")", ";", "getLog", "(", ")", ".", "debug", "(", "\"Parsed Version\"", ")", ";", "getLog", "(", ")", ".", "debug", "(", "\" major: \"", "+", "artifactVersion", ".", "getMajor", "(", ")", ")", ";", "getLog", "(", ")", ".", "debug", "(", "\" minor: \"", "+", "artifactVersion", ".", "getMinor", "(", ")", ")", ";", "getLog", "(", ")", ".", "debug", "(", "\" incremental: \"", "+", "artifactVersion", ".", "getPatch", "(", ")", ")", ";", "getLog", "(", ")", ".", "debug", "(", "\" buildnumber: \"", "+", "artifactVersion", ".", "getBuildNumber", "(", ")", ")", ";", "getLog", "(", ")", ".", "debug", "(", "\" qualifier: \"", "+", "artifactVersion", ".", "getQualifier", "(", ")", ")", ";", "defineVersionProperty", "(", "\"majorVersion\"", ",", "artifactVersion", ".", "getMajor", "(", ")", ")", ";", "defineVersionProperty", "(", "\"minorVersion\"", ",", "artifactVersion", ".", "getMinor", "(", ")", ")", ";", "defineVersionProperty", "(", "\"incrementalVersion\"", ",", "artifactVersion", ".", "getPatch", "(", ")", ")", ";", "defineVersionProperty", "(", "\"buildNumber\"", ",", "artifactVersion", ".", "getBuildNumber", "(", ")", ")", ";", "defineVersionProperty", "(", "\"nextMajorVersion\"", ",", "artifactVersion", ".", "getMajor", "(", ")", "+", "1", ")", ";", "defineVersionProperty", "(", "\"nextMinorVersion\"", ",", "artifactVersion", ".", "getMinor", "(", ")", "+", "1", ")", ";", "defineVersionProperty", "(", "\"nextIncrementalVersion\"", ",", "artifactVersion", ".", "getPatch", "(", ")", "+", "1", ")", ";", "defineVersionProperty", "(", "\"nextBuildNumber\"", ",", "artifactVersion", ".", "getBuildNumber", "(", ")", "+", "1", ")", ";", "defineFormattedVersionProperty", "(", "\"majorVersion\"", ",", "String", ".", "format", "(", "formatMajor", ",", "artifactVersion", ".", "getMajor", "(", ")", ")", ")", ";", "defineFormattedVersionProperty", "(", "\"minorVersion\"", ",", "String", ".", "format", "(", "formatMinor", ",", "artifactVersion", ".", "getMinor", "(", ")", ")", ")", ";", "defineFormattedVersionProperty", "(", "\"incrementalVersion\"", ",", "String", ".", "format", "(", "formatIncremental", ",", "artifactVersion", ".", "getPatch", "(", ")", ")", ")", ";", "defineFormattedVersionProperty", "(", "\"buildNumber\"", ",", "String", ".", "format", "(", "formatBuildNumber", ",", "artifactVersion", ".", "getBuildNumber", "(", ")", ")", ")", ";", "defineFormattedVersionProperty", "(", "\"nextMajorVersion\"", ",", "String", ".", "format", "(", "formatMajor", ",", "artifactVersion", ".", "getMajor", "(", ")", "+", "1", ")", ")", ";", "defineFormattedVersionProperty", "(", "\"nextMinorVersion\"", ",", "String", ".", "format", "(", "formatMinor", ",", "artifactVersion", ".", "getMinor", "(", ")", "+", "1", ")", ")", ";", "defineFormattedVersionProperty", "(", "\"nextIncrementalVersion\"", ",", "String", ".", "format", "(", "formatIncremental", ",", "artifactVersion", ".", "getPatch", "(", ")", "+", "1", ")", ")", ";", "defineFormattedVersionProperty", "(", "\"nextBuildNumber\"", ",", "String", ".", "format", "(", "formatBuildNumber", ",", "artifactVersion", ".", "getBuildNumber", "(", ")", "+", "1", ")", ")", ";", "String", "osgi", "=", "artifactVersion", ".", "getAsOSGiVersion", "(", ")", ";", "String", "qualifier", "=", "artifactVersion", ".", "getQualifier", "(", ")", ";", "String", "qualifierQuestion", "=", "\"\"", ";", "if", "(", "qualifier", "==", "null", ")", "{", "qualifier", "=", "\"\"", ";", "}", "else", "{", "qualifierQuestion", "=", "qualifierPrefix", ";", "}", "defineVersionProperty", "(", "\"qualifier\"", ",", "qualifier", ")", ";", "defineVersionProperty", "(", "\"qualifier?\"", ",", "qualifierQuestion", "+", "qualifier", ")", ";", "defineVersionProperty", "(", "\"osgiVersion\"", ",", "osgi", ")", ";", "}" ]
Parse a version String and add the components to a properties object. @param version the version to parse
[ "Parse", "a", "version", "String", "and", "add", "the", "components", "to", "a", "properties", "object", "." ]
9b5f82fb04c9824917f8b29d8e12d804e3c36cf0
https://github.com/mojohaus/build-helper-maven-plugin/blob/9b5f82fb04c9824917f8b29d8e12d804e3c36cf0/src/main/java/org/codehaus/mojo/buildhelper/ParseVersionMojo.java#L188-L234
159,331
mojohaus/build-helper-maven-plugin
src/main/java/org/codehaus/mojo/buildhelper/ReserveListenerPortMojo.java
ReserveListenerPortMojo.findAvailablePortNumber
private int findAvailablePortNumber( Integer portNumberStartingPoint, List<Integer> reservedPorts ) { assert portNumberStartingPoint != null; int candidate = portNumberStartingPoint; while ( reservedPorts.contains( candidate ) ) { candidate++; } return candidate; }
java
private int findAvailablePortNumber( Integer portNumberStartingPoint, List<Integer> reservedPorts ) { assert portNumberStartingPoint != null; int candidate = portNumberStartingPoint; while ( reservedPorts.contains( candidate ) ) { candidate++; } return candidate; }
[ "private", "int", "findAvailablePortNumber", "(", "Integer", "portNumberStartingPoint", ",", "List", "<", "Integer", ">", "reservedPorts", ")", "{", "assert", "portNumberStartingPoint", "!=", "null", ";", "int", "candidate", "=", "portNumberStartingPoint", ";", "while", "(", "reservedPorts", ".", "contains", "(", "candidate", ")", ")", "{", "candidate", "++", ";", "}", "return", "candidate", ";", "}" ]
Returns the first number available, starting at portNumberStartingPoint that's not already in the reservedPorts list. @param portNumberStartingPoint first port number to start from. @param reservedPorts the ports already reserved. @return first number available not in the given list, starting at the given parameter.
[ "Returns", "the", "first", "number", "available", "starting", "at", "portNumberStartingPoint", "that", "s", "not", "already", "in", "the", "reservedPorts", "list", "." ]
9b5f82fb04c9824917f8b29d8e12d804e3c36cf0
https://github.com/mojohaus/build-helper-maven-plugin/blob/9b5f82fb04c9824917f8b29d8e12d804e3c36cf0/src/main/java/org/codehaus/mojo/buildhelper/ReserveListenerPortMojo.java#L366-L375
159,332
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/output/Values.java
Values.populateFromAttributes
public void populateFromAttributes( @Nonnull final Template template, @Nonnull final Map<String, Attribute> attributes, @Nonnull final PObject requestJsonAttributes) { if (requestJsonAttributes.has(JSON_REQUEST_HEADERS) && requestJsonAttributes.getObject(JSON_REQUEST_HEADERS).has(JSON_REQUEST_HEADERS) && !attributes.containsKey(JSON_REQUEST_HEADERS)) { attributes.put(JSON_REQUEST_HEADERS, new HttpRequestHeadersAttribute()); } for (Map.Entry<String, Attribute> attribute: attributes.entrySet()) { try { put(attribute.getKey(), attribute.getValue().getValue(template, attribute.getKey(), requestJsonAttributes)); } catch (ObjectMissingException | IllegalArgumentException e) { throw e; } catch (Throwable e) { String templateName = "unknown"; for (Map.Entry<String, Template> entry: template.getConfiguration().getTemplates() .entrySet()) { if (entry.getValue() == template) { templateName = entry.getKey(); break; } } String defaults = ""; if (attribute instanceof ReflectiveAttribute<?>) { ReflectiveAttribute<?> reflectiveAttribute = (ReflectiveAttribute<?>) attribute; defaults = "\n\n The attribute defaults are: " + reflectiveAttribute.getDefaultValue(); } String errorMsg = "An error occurred when creating a value from the '" + attribute.getKey() + "' attribute for the '" + templateName + "' template.\n\nThe JSON is: \n" + requestJsonAttributes + defaults + "\n" + e.toString(); throw new AttributeParsingException(errorMsg, e); } } if (template.getConfiguration().isThrowErrorOnExtraParameters()) { final List<String> extraProperties = new ArrayList<>(); for (Iterator<String> it = requestJsonAttributes.keys(); it.hasNext(); ) { final String attributeName = it.next(); if (!attributes.containsKey(attributeName)) { extraProperties.add(attributeName); } } if (!extraProperties.isEmpty()) { throw new ExtraPropertyException("Extra properties found in the request attributes", extraProperties, attributes.keySet()); } } }
java
public void populateFromAttributes( @Nonnull final Template template, @Nonnull final Map<String, Attribute> attributes, @Nonnull final PObject requestJsonAttributes) { if (requestJsonAttributes.has(JSON_REQUEST_HEADERS) && requestJsonAttributes.getObject(JSON_REQUEST_HEADERS).has(JSON_REQUEST_HEADERS) && !attributes.containsKey(JSON_REQUEST_HEADERS)) { attributes.put(JSON_REQUEST_HEADERS, new HttpRequestHeadersAttribute()); } for (Map.Entry<String, Attribute> attribute: attributes.entrySet()) { try { put(attribute.getKey(), attribute.getValue().getValue(template, attribute.getKey(), requestJsonAttributes)); } catch (ObjectMissingException | IllegalArgumentException e) { throw e; } catch (Throwable e) { String templateName = "unknown"; for (Map.Entry<String, Template> entry: template.getConfiguration().getTemplates() .entrySet()) { if (entry.getValue() == template) { templateName = entry.getKey(); break; } } String defaults = ""; if (attribute instanceof ReflectiveAttribute<?>) { ReflectiveAttribute<?> reflectiveAttribute = (ReflectiveAttribute<?>) attribute; defaults = "\n\n The attribute defaults are: " + reflectiveAttribute.getDefaultValue(); } String errorMsg = "An error occurred when creating a value from the '" + attribute.getKey() + "' attribute for the '" + templateName + "' template.\n\nThe JSON is: \n" + requestJsonAttributes + defaults + "\n" + e.toString(); throw new AttributeParsingException(errorMsg, e); } } if (template.getConfiguration().isThrowErrorOnExtraParameters()) { final List<String> extraProperties = new ArrayList<>(); for (Iterator<String> it = requestJsonAttributes.keys(); it.hasNext(); ) { final String attributeName = it.next(); if (!attributes.containsKey(attributeName)) { extraProperties.add(attributeName); } } if (!extraProperties.isEmpty()) { throw new ExtraPropertyException("Extra properties found in the request attributes", extraProperties, attributes.keySet()); } } }
[ "public", "void", "populateFromAttributes", "(", "@", "Nonnull", "final", "Template", "template", ",", "@", "Nonnull", "final", "Map", "<", "String", ",", "Attribute", ">", "attributes", ",", "@", "Nonnull", "final", "PObject", "requestJsonAttributes", ")", "{", "if", "(", "requestJsonAttributes", ".", "has", "(", "JSON_REQUEST_HEADERS", ")", "&&", "requestJsonAttributes", ".", "getObject", "(", "JSON_REQUEST_HEADERS", ")", ".", "has", "(", "JSON_REQUEST_HEADERS", ")", "&&", "!", "attributes", ".", "containsKey", "(", "JSON_REQUEST_HEADERS", ")", ")", "{", "attributes", ".", "put", "(", "JSON_REQUEST_HEADERS", ",", "new", "HttpRequestHeadersAttribute", "(", ")", ")", ";", "}", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Attribute", ">", "attribute", ":", "attributes", ".", "entrySet", "(", ")", ")", "{", "try", "{", "put", "(", "attribute", ".", "getKey", "(", ")", ",", "attribute", ".", "getValue", "(", ")", ".", "getValue", "(", "template", ",", "attribute", ".", "getKey", "(", ")", ",", "requestJsonAttributes", ")", ")", ";", "}", "catch", "(", "ObjectMissingException", "|", "IllegalArgumentException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "String", "templateName", "=", "\"unknown\"", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Template", ">", "entry", ":", "template", ".", "getConfiguration", "(", ")", ".", "getTemplates", "(", ")", ".", "entrySet", "(", ")", ")", "{", "if", "(", "entry", ".", "getValue", "(", ")", "==", "template", ")", "{", "templateName", "=", "entry", ".", "getKey", "(", ")", ";", "break", ";", "}", "}", "String", "defaults", "=", "\"\"", ";", "if", "(", "attribute", "instanceof", "ReflectiveAttribute", "<", "?", ">", ")", "{", "ReflectiveAttribute", "<", "?", ">", "reflectiveAttribute", "=", "(", "ReflectiveAttribute", "<", "?", ">", ")", "attribute", ";", "defaults", "=", "\"\\n\\n The attribute defaults are: \"", "+", "reflectiveAttribute", ".", "getDefaultValue", "(", ")", ";", "}", "String", "errorMsg", "=", "\"An error occurred when creating a value from the '\"", "+", "attribute", ".", "getKey", "(", ")", "+", "\"' attribute for the '\"", "+", "templateName", "+", "\"' template.\\n\\nThe JSON is: \\n\"", "+", "requestJsonAttributes", "+", "defaults", "+", "\"\\n\"", "+", "e", ".", "toString", "(", ")", ";", "throw", "new", "AttributeParsingException", "(", "errorMsg", ",", "e", ")", ";", "}", "}", "if", "(", "template", ".", "getConfiguration", "(", ")", ".", "isThrowErrorOnExtraParameters", "(", ")", ")", "{", "final", "List", "<", "String", ">", "extraProperties", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "String", ">", "it", "=", "requestJsonAttributes", ".", "keys", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "final", "String", "attributeName", "=", "it", ".", "next", "(", ")", ";", "if", "(", "!", "attributes", ".", "containsKey", "(", "attributeName", ")", ")", "{", "extraProperties", ".", "add", "(", "attributeName", ")", ";", "}", "}", "if", "(", "!", "extraProperties", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "ExtraPropertyException", "(", "\"Extra properties found in the request attributes\"", ",", "extraProperties", ",", "attributes", ".", "keySet", "(", ")", ")", ";", "}", "}", "}" ]
Process the requestJsonAttributes using the attributes and the MapfishParser and add all resulting values to this values object. @param template the template of the current request. @param attributes the attributes that will be used to add values to this values object @param requestJsonAttributes the json data for populating the attribute values
[ "Process", "the", "requestJsonAttributes", "using", "the", "attributes", "and", "the", "MapfishParser", "and", "add", "all", "resulting", "values", "to", "this", "values", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/output/Values.java#L191-L247
159,333
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/output/Values.java
Values.addRequiredValues
public void addRequiredValues(@Nonnull final Values sourceValues) { Object taskDirectory = sourceValues.getObject(TASK_DIRECTORY_KEY, Object.class); MfClientHttpRequestFactoryProvider requestFactoryProvider = sourceValues.getObject(CLIENT_HTTP_REQUEST_FACTORY_KEY, MfClientHttpRequestFactoryProvider.class); Template template = sourceValues.getObject(TEMPLATE_KEY, Template.class); PDFConfig pdfConfig = sourceValues.getObject(PDF_CONFIG_KEY, PDFConfig.class); String subReportDir = sourceValues.getString(SUBREPORT_DIR_KEY); this.values.put(TASK_DIRECTORY_KEY, taskDirectory); this.values.put(CLIENT_HTTP_REQUEST_FACTORY_KEY, requestFactoryProvider); this.values.put(TEMPLATE_KEY, template); this.values.put(PDF_CONFIG_KEY, pdfConfig); this.values.put(SUBREPORT_DIR_KEY, subReportDir); this.values.put(VALUES_KEY, this); this.values.put(JOB_ID_KEY, sourceValues.getString(JOB_ID_KEY)); this.values.put(LOCALE_KEY, sourceValues.getObject(LOCALE_KEY, Locale.class)); }
java
public void addRequiredValues(@Nonnull final Values sourceValues) { Object taskDirectory = sourceValues.getObject(TASK_DIRECTORY_KEY, Object.class); MfClientHttpRequestFactoryProvider requestFactoryProvider = sourceValues.getObject(CLIENT_HTTP_REQUEST_FACTORY_KEY, MfClientHttpRequestFactoryProvider.class); Template template = sourceValues.getObject(TEMPLATE_KEY, Template.class); PDFConfig pdfConfig = sourceValues.getObject(PDF_CONFIG_KEY, PDFConfig.class); String subReportDir = sourceValues.getString(SUBREPORT_DIR_KEY); this.values.put(TASK_DIRECTORY_KEY, taskDirectory); this.values.put(CLIENT_HTTP_REQUEST_FACTORY_KEY, requestFactoryProvider); this.values.put(TEMPLATE_KEY, template); this.values.put(PDF_CONFIG_KEY, pdfConfig); this.values.put(SUBREPORT_DIR_KEY, subReportDir); this.values.put(VALUES_KEY, this); this.values.put(JOB_ID_KEY, sourceValues.getString(JOB_ID_KEY)); this.values.put(LOCALE_KEY, sourceValues.getObject(LOCALE_KEY, Locale.class)); }
[ "public", "void", "addRequiredValues", "(", "@", "Nonnull", "final", "Values", "sourceValues", ")", "{", "Object", "taskDirectory", "=", "sourceValues", ".", "getObject", "(", "TASK_DIRECTORY_KEY", ",", "Object", ".", "class", ")", ";", "MfClientHttpRequestFactoryProvider", "requestFactoryProvider", "=", "sourceValues", ".", "getObject", "(", "CLIENT_HTTP_REQUEST_FACTORY_KEY", ",", "MfClientHttpRequestFactoryProvider", ".", "class", ")", ";", "Template", "template", "=", "sourceValues", ".", "getObject", "(", "TEMPLATE_KEY", ",", "Template", ".", "class", ")", ";", "PDFConfig", "pdfConfig", "=", "sourceValues", ".", "getObject", "(", "PDF_CONFIG_KEY", ",", "PDFConfig", ".", "class", ")", ";", "String", "subReportDir", "=", "sourceValues", ".", "getString", "(", "SUBREPORT_DIR_KEY", ")", ";", "this", ".", "values", ".", "put", "(", "TASK_DIRECTORY_KEY", ",", "taskDirectory", ")", ";", "this", ".", "values", ".", "put", "(", "CLIENT_HTTP_REQUEST_FACTORY_KEY", ",", "requestFactoryProvider", ")", ";", "this", ".", "values", ".", "put", "(", "TEMPLATE_KEY", ",", "template", ")", ";", "this", ".", "values", ".", "put", "(", "PDF_CONFIG_KEY", ",", "pdfConfig", ")", ";", "this", ".", "values", ".", "put", "(", "SUBREPORT_DIR_KEY", ",", "subReportDir", ")", ";", "this", ".", "values", ".", "put", "(", "VALUES_KEY", ",", "this", ")", ";", "this", ".", "values", ".", "put", "(", "JOB_ID_KEY", ",", "sourceValues", ".", "getString", "(", "JOB_ID_KEY", ")", ")", ";", "this", ".", "values", ".", "put", "(", "LOCALE_KEY", ",", "sourceValues", ".", "getObject", "(", "LOCALE_KEY", ",", "Locale", ".", "class", ")", ")", ";", "}" ]
Add the elements that all values objects require from the provided values object. @param sourceValues the values object containing the required elements
[ "Add", "the", "elements", "that", "all", "values", "objects", "require", "from", "the", "provided", "values", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/output/Values.java#L254-L271
159,334
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/output/Values.java
Values.put
public void put(final String key, final Object value) { if (TASK_DIRECTORY_KEY.equals(key) && this.values.keySet().contains(TASK_DIRECTORY_KEY)) { // ensure that no one overwrites the task directory throw new IllegalArgumentException("Invalid key: " + key); } if (value == null) { throw new IllegalArgumentException( "A null value was attempted to be put into the values object under key: " + key); } this.values.put(key, value); }
java
public void put(final String key, final Object value) { if (TASK_DIRECTORY_KEY.equals(key) && this.values.keySet().contains(TASK_DIRECTORY_KEY)) { // ensure that no one overwrites the task directory throw new IllegalArgumentException("Invalid key: " + key); } if (value == null) { throw new IllegalArgumentException( "A null value was attempted to be put into the values object under key: " + key); } this.values.put(key, value); }
[ "public", "void", "put", "(", "final", "String", "key", ",", "final", "Object", "value", ")", "{", "if", "(", "TASK_DIRECTORY_KEY", ".", "equals", "(", "key", ")", "&&", "this", ".", "values", ".", "keySet", "(", ")", ".", "contains", "(", "TASK_DIRECTORY_KEY", ")", ")", "{", "// ensure that no one overwrites the task directory", "throw", "new", "IllegalArgumentException", "(", "\"Invalid key: \"", "+", "key", ")", ";", "}", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"A null value was attempted to be put into the values object under key: \"", "+", "key", ")", ";", "}", "this", ".", "values", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
Put a new value in map. @param key id of the value for looking up. @param value the value.
[ "Put", "a", "new", "value", "in", "map", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/output/Values.java#L279-L290
159,335
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/output/Values.java
Values.getObject
public <V> V getObject(final String key, final Class<V> type) { final Object obj = this.values.get(key); return type.cast(obj); }
java
public <V> V getObject(final String key, final Class<V> type) { final Object obj = this.values.get(key); return type.cast(obj); }
[ "public", "<", "V", ">", "V", "getObject", "(", "final", "String", "key", ",", "final", "Class", "<", "V", ">", "type", ")", "{", "final", "Object", "obj", "=", "this", ".", "values", ".", "get", "(", "key", ")", ";", "return", "type", ".", "cast", "(", "obj", ")", ";", "}" ]
Get a value as a string. @param key the key for looking up the value. @param type the type of the object @param <V> the type
[ "Get", "a", "value", "as", "a", "string", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/output/Values.java#L333-L336
159,336
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/output/Values.java
Values.getBoolean
@Nullable public Boolean getBoolean(@Nonnull final String key) { return (Boolean) this.values.get(key); }
java
@Nullable public Boolean getBoolean(@Nonnull final String key) { return (Boolean) this.values.get(key); }
[ "@", "Nullable", "public", "Boolean", "getBoolean", "(", "@", "Nonnull", "final", "String", "key", ")", "{", "return", "(", "Boolean", ")", "this", ".", "values", ".", "get", "(", "key", ")", ";", "}" ]
Get a boolean value from the values or null. @param key the look up key of the value
[ "Get", "a", "boolean", "value", "from", "the", "values", "or", "null", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/output/Values.java#L352-L355
159,337
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/output/Values.java
Values.find
@SuppressWarnings("unchecked") public <T> Map<String, T> find(final Class<T> valueTypeToFind) { return (Map<String, T>) this.values.entrySet().stream() .filter(input -> valueTypeToFind.isInstance(input.getValue())) .collect( Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }
java
@SuppressWarnings("unchecked") public <T> Map<String, T> find(final Class<T> valueTypeToFind) { return (Map<String, T>) this.values.entrySet().stream() .filter(input -> valueTypeToFind.isInstance(input.getValue())) .collect( Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "Map", "<", "String", ",", "T", ">", "find", "(", "final", "Class", "<", "T", ">", "valueTypeToFind", ")", "{", "return", "(", "Map", "<", "String", ",", "T", ">", ")", "this", ".", "values", ".", "entrySet", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "input", "->", "valueTypeToFind", ".", "isInstance", "(", "input", ".", "getValue", "(", ")", ")", ")", ".", "collect", "(", "Collectors", ".", "toMap", "(", "Map", ".", "Entry", "::", "getKey", ",", "Map", ".", "Entry", "::", "getValue", ")", ")", ";", "}" ]
Find all the values of the requested type. @param valueTypeToFind the type of the value to return. @param <T> the type of the value to find. @return the key, value pairs found.
[ "Find", "all", "the", "values", "of", "the", "requested", "type", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/output/Values.java#L373-L379
159,338
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/http/MfClientHttpRequestFactoryImpl.java
MfClientHttpRequestFactoryImpl.createRequest
@Override public ConfigurableRequest createRequest( @Nonnull final URI uri, @Nonnull final HttpMethod httpMethod) throws IOException { HttpRequestBase httpRequest = (HttpRequestBase) createHttpUriRequest(httpMethod, uri); return new Request(getHttpClient(), httpRequest, createHttpContext(httpMethod, uri)); }
java
@Override public ConfigurableRequest createRequest( @Nonnull final URI uri, @Nonnull final HttpMethod httpMethod) throws IOException { HttpRequestBase httpRequest = (HttpRequestBase) createHttpUriRequest(httpMethod, uri); return new Request(getHttpClient(), httpRequest, createHttpContext(httpMethod, uri)); }
[ "@", "Override", "public", "ConfigurableRequest", "createRequest", "(", "@", "Nonnull", "final", "URI", "uri", ",", "@", "Nonnull", "final", "HttpMethod", "httpMethod", ")", "throws", "IOException", "{", "HttpRequestBase", "httpRequest", "=", "(", "HttpRequestBase", ")", "createHttpUriRequest", "(", "httpMethod", ",", "uri", ")", ";", "return", "new", "Request", "(", "getHttpClient", "(", ")", ",", "httpRequest", ",", "createHttpContext", "(", "httpMethod", ",", "uri", ")", ")", ";", "}" ]
allow extension only for testing
[ "allow", "extension", "only", "for", "testing" ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/http/MfClientHttpRequestFactoryImpl.java#L93-L99
159,339
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/yaml/PYamlObject.java
PYamlObject.toJSON
public final PJsonObject toJSON() { try { JSONObject json = new JSONObject(); for (String key: this.obj.keySet()) { Object opt = opt(key); if (opt instanceof PYamlObject) { opt = ((PYamlObject) opt).toJSON().getInternalObj(); } else if (opt instanceof PYamlArray) { opt = ((PYamlArray) opt).toJSON().getInternalArray(); } json.put(key, opt); } return new PJsonObject(json, this.getContextName()); } catch (Throwable e) { throw ExceptionUtils.getRuntimeException(e); } }
java
public final PJsonObject toJSON() { try { JSONObject json = new JSONObject(); for (String key: this.obj.keySet()) { Object opt = opt(key); if (opt instanceof PYamlObject) { opt = ((PYamlObject) opt).toJSON().getInternalObj(); } else if (opt instanceof PYamlArray) { opt = ((PYamlArray) opt).toJSON().getInternalArray(); } json.put(key, opt); } return new PJsonObject(json, this.getContextName()); } catch (Throwable e) { throw ExceptionUtils.getRuntimeException(e); } }
[ "public", "final", "PJsonObject", "toJSON", "(", ")", "{", "try", "{", "JSONObject", "json", "=", "new", "JSONObject", "(", ")", ";", "for", "(", "String", "key", ":", "this", ".", "obj", ".", "keySet", "(", ")", ")", "{", "Object", "opt", "=", "opt", "(", "key", ")", ";", "if", "(", "opt", "instanceof", "PYamlObject", ")", "{", "opt", "=", "(", "(", "PYamlObject", ")", "opt", ")", ".", "toJSON", "(", ")", ".", "getInternalObj", "(", ")", ";", "}", "else", "if", "(", "opt", "instanceof", "PYamlArray", ")", "{", "opt", "=", "(", "(", "PYamlArray", ")", "opt", ")", ".", "toJSON", "(", ")", ".", "getInternalArray", "(", ")", ";", "}", "json", ".", "put", "(", "key", ",", "opt", ")", ";", "}", "return", "new", "PJsonObject", "(", "json", ",", "this", ".", "getContextName", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "ExceptionUtils", ".", "getRuntimeException", "(", "e", ")", ";", "}", "}" ]
Convert this object to a json object.
[ "Convert", "this", "object", "to", "a", "json", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/yaml/PYamlObject.java#L150-L166
159,340
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/http/matcher/MatchInfo.java
MatchInfo.fromUri
public static MatchInfo fromUri(final URI uri, final HttpMethod method) { int newPort = uri.getPort(); if (newPort < 0) { try { newPort = uri.toURL().getDefaultPort(); } catch (MalformedURLException | IllegalArgumentException e) { newPort = ANY_PORT; } } return new MatchInfo(uri.getScheme(), uri.getHost(), newPort, uri.getPath(), uri.getQuery(), uri.getFragment(), ANY_REALM, method); }
java
public static MatchInfo fromUri(final URI uri, final HttpMethod method) { int newPort = uri.getPort(); if (newPort < 0) { try { newPort = uri.toURL().getDefaultPort(); } catch (MalformedURLException | IllegalArgumentException e) { newPort = ANY_PORT; } } return new MatchInfo(uri.getScheme(), uri.getHost(), newPort, uri.getPath(), uri.getQuery(), uri.getFragment(), ANY_REALM, method); }
[ "public", "static", "MatchInfo", "fromUri", "(", "final", "URI", "uri", ",", "final", "HttpMethod", "method", ")", "{", "int", "newPort", "=", "uri", ".", "getPort", "(", ")", ";", "if", "(", "newPort", "<", "0", ")", "{", "try", "{", "newPort", "=", "uri", ".", "toURL", "(", ")", ".", "getDefaultPort", "(", ")", ";", "}", "catch", "(", "MalformedURLException", "|", "IllegalArgumentException", "e", ")", "{", "newPort", "=", "ANY_PORT", ";", "}", "}", "return", "new", "MatchInfo", "(", "uri", ".", "getScheme", "(", ")", ",", "uri", ".", "getHost", "(", ")", ",", "newPort", ",", "uri", ".", "getPath", "(", ")", ",", "uri", ".", "getQuery", "(", ")", ",", "uri", ".", "getFragment", "(", ")", ",", "ANY_REALM", ",", "method", ")", ";", "}" ]
Create an info object from a uri and the http method object. @param uri the uri @param method the method
[ "Create", "an", "info", "object", "from", "a", "uri", "and", "the", "http", "method", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/matcher/MatchInfo.java#L95-L107
159,341
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/http/matcher/MatchInfo.java
MatchInfo.fromAuthScope
@SuppressWarnings("StringEquality") public static MatchInfo fromAuthScope(final AuthScope authscope) { String newScheme = StringUtils.equals(authscope.getScheme(), AuthScope.ANY_SCHEME) ? ANY_SCHEME : authscope.getScheme(); String newHost = StringUtils.equals(authscope.getHost(), AuthScope.ANY_HOST) ? ANY_HOST : authscope.getHost(); int newPort = authscope.getPort() == AuthScope.ANY_PORT ? ANY_PORT : authscope.getPort(); String newRealm = StringUtils.equals(authscope.getRealm(), AuthScope.ANY_REALM) ? ANY_REALM : authscope.getRealm(); return new MatchInfo(newScheme, newHost, newPort, ANY_PATH, ANY_QUERY, ANY_FRAGMENT, newRealm, ANY_METHOD); }
java
@SuppressWarnings("StringEquality") public static MatchInfo fromAuthScope(final AuthScope authscope) { String newScheme = StringUtils.equals(authscope.getScheme(), AuthScope.ANY_SCHEME) ? ANY_SCHEME : authscope.getScheme(); String newHost = StringUtils.equals(authscope.getHost(), AuthScope.ANY_HOST) ? ANY_HOST : authscope.getHost(); int newPort = authscope.getPort() == AuthScope.ANY_PORT ? ANY_PORT : authscope.getPort(); String newRealm = StringUtils.equals(authscope.getRealm(), AuthScope.ANY_REALM) ? ANY_REALM : authscope.getRealm(); return new MatchInfo(newScheme, newHost, newPort, ANY_PATH, ANY_QUERY, ANY_FRAGMENT, newRealm, ANY_METHOD); }
[ "@", "SuppressWarnings", "(", "\"StringEquality\"", ")", "public", "static", "MatchInfo", "fromAuthScope", "(", "final", "AuthScope", "authscope", ")", "{", "String", "newScheme", "=", "StringUtils", ".", "equals", "(", "authscope", ".", "getScheme", "(", ")", ",", "AuthScope", ".", "ANY_SCHEME", ")", "?", "ANY_SCHEME", ":", "authscope", ".", "getScheme", "(", ")", ";", "String", "newHost", "=", "StringUtils", ".", "equals", "(", "authscope", ".", "getHost", "(", ")", ",", "AuthScope", ".", "ANY_HOST", ")", "?", "ANY_HOST", ":", "authscope", ".", "getHost", "(", ")", ";", "int", "newPort", "=", "authscope", ".", "getPort", "(", ")", "==", "AuthScope", ".", "ANY_PORT", "?", "ANY_PORT", ":", "authscope", ".", "getPort", "(", ")", ";", "String", "newRealm", "=", "StringUtils", ".", "equals", "(", "authscope", ".", "getRealm", "(", ")", ",", "AuthScope", ".", "ANY_REALM", ")", "?", "ANY_REALM", ":", "authscope", ".", "getRealm", "(", ")", ";", "return", "new", "MatchInfo", "(", "newScheme", ",", "newHost", ",", "newPort", ",", "ANY_PATH", ",", "ANY_QUERY", ",", "ANY_FRAGMENT", ",", "newRealm", ",", "ANY_METHOD", ")", ";", "}" ]
Create an info object from an authscope object. @param authscope the authscope
[ "Create", "an", "info", "object", "from", "an", "authscope", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/matcher/MatchInfo.java#L114-L126
159,342
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/style/json/JsonStyleParserHelper.java
JsonStyleParserHelper.createStyle
public Style createStyle(final List<Rule> styleRules) { final Rule[] rulesArray = styleRules.toArray(new Rule[0]); final FeatureTypeStyle featureTypeStyle = this.styleBuilder.createFeatureTypeStyle(null, rulesArray); final Style style = this.styleBuilder.createStyle(); style.featureTypeStyles().add(featureTypeStyle); return style; }
java
public Style createStyle(final List<Rule> styleRules) { final Rule[] rulesArray = styleRules.toArray(new Rule[0]); final FeatureTypeStyle featureTypeStyle = this.styleBuilder.createFeatureTypeStyle(null, rulesArray); final Style style = this.styleBuilder.createStyle(); style.featureTypeStyles().add(featureTypeStyle); return style; }
[ "public", "Style", "createStyle", "(", "final", "List", "<", "Rule", ">", "styleRules", ")", "{", "final", "Rule", "[", "]", "rulesArray", "=", "styleRules", ".", "toArray", "(", "new", "Rule", "[", "0", "]", ")", ";", "final", "FeatureTypeStyle", "featureTypeStyle", "=", "this", ".", "styleBuilder", ".", "createFeatureTypeStyle", "(", "null", ",", "rulesArray", ")", ";", "final", "Style", "style", "=", "this", ".", "styleBuilder", ".", "createStyle", "(", ")", ";", "style", ".", "featureTypeStyles", "(", ")", ".", "add", "(", "featureTypeStyle", ")", ";", "return", "style", ";", "}" ]
Create a style from a list of rules. @param styleRules the rules
[ "Create", "a", "style", "from", "a", "list", "of", "rules", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/style/json/JsonStyleParserHelper.java#L165-L171
159,343
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/style/json/JsonStyleParserHelper.java
JsonStyleParserHelper.createLineSymbolizer
@VisibleForTesting @Nullable protected LineSymbolizer createLineSymbolizer(final PJsonObject styleJson) { final Stroke stroke = createStroke(styleJson, true); if (stroke == null) { return null; } else { return this.styleBuilder.createLineSymbolizer(stroke); } }
java
@VisibleForTesting @Nullable protected LineSymbolizer createLineSymbolizer(final PJsonObject styleJson) { final Stroke stroke = createStroke(styleJson, true); if (stroke == null) { return null; } else { return this.styleBuilder.createLineSymbolizer(stroke); } }
[ "@", "VisibleForTesting", "@", "Nullable", "protected", "LineSymbolizer", "createLineSymbolizer", "(", "final", "PJsonObject", "styleJson", ")", "{", "final", "Stroke", "stroke", "=", "createStroke", "(", "styleJson", ",", "true", ")", ";", "if", "(", "stroke", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "return", "this", ".", "styleBuilder", ".", "createLineSymbolizer", "(", "stroke", ")", ";", "}", "}" ]
Add a line symbolizer definition to the rule. @param styleJson The old style.
[ "Add", "a", "line", "symbolizer", "definition", "to", "the", "rule", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/style/json/JsonStyleParserHelper.java#L298-L307
159,344
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/style/json/JsonStyleParserHelper.java
JsonStyleParserHelper.createPolygonSymbolizer
@Nullable @VisibleForTesting protected PolygonSymbolizer createPolygonSymbolizer(final PJsonObject styleJson) { if (this.allowNullSymbolizer && !styleJson.has(JSON_FILL_COLOR)) { return null; } final PolygonSymbolizer symbolizer = this.styleBuilder.createPolygonSymbolizer(); symbolizer.setFill(createFill(styleJson)); symbolizer.setStroke(createStroke(styleJson, false)); return symbolizer; }
java
@Nullable @VisibleForTesting protected PolygonSymbolizer createPolygonSymbolizer(final PJsonObject styleJson) { if (this.allowNullSymbolizer && !styleJson.has(JSON_FILL_COLOR)) { return null; } final PolygonSymbolizer symbolizer = this.styleBuilder.createPolygonSymbolizer(); symbolizer.setFill(createFill(styleJson)); symbolizer.setStroke(createStroke(styleJson, false)); return symbolizer; }
[ "@", "Nullable", "@", "VisibleForTesting", "protected", "PolygonSymbolizer", "createPolygonSymbolizer", "(", "final", "PJsonObject", "styleJson", ")", "{", "if", "(", "this", ".", "allowNullSymbolizer", "&&", "!", "styleJson", ".", "has", "(", "JSON_FILL_COLOR", ")", ")", "{", "return", "null", ";", "}", "final", "PolygonSymbolizer", "symbolizer", "=", "this", ".", "styleBuilder", ".", "createPolygonSymbolizer", "(", ")", ";", "symbolizer", ".", "setFill", "(", "createFill", "(", "styleJson", ")", ")", ";", "symbolizer", ".", "setStroke", "(", "createStroke", "(", "styleJson", ",", "false", ")", ")", ";", "return", "symbolizer", ";", "}" ]
Add a polygon symbolizer definition to the rule. @param styleJson The old style.
[ "Add", "a", "polygon", "symbolizer", "definition", "to", "the", "rule", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/style/json/JsonStyleParserHelper.java#L314-L327
159,345
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/style/json/JsonStyleParserHelper.java
JsonStyleParserHelper.createTextSymbolizer
@VisibleForTesting protected TextSymbolizer createTextSymbolizer(final PJsonObject styleJson) { final TextSymbolizer textSymbolizer = this.styleBuilder.createTextSymbolizer(); // make sure that labels are also rendered if a part of the text would be outside // the view context, see http://docs.geoserver.org/stable/en/user/styling/sld-reference/labeling // .html#partials textSymbolizer.getOptions().put("partials", "true"); if (styleJson.has(JSON_LABEL)) { final Expression label = parseExpression(null, styleJson, JSON_LABEL, (final String labelValue) -> labelValue.replace("${", "") .replace("}", "")); textSymbolizer.setLabel(label); } else { return null; } textSymbolizer.setFont(createFont(textSymbolizer.getFont(), styleJson)); if (styleJson.has(JSON_LABEL_ANCHOR_POINT_X) || styleJson.has(JSON_LABEL_ANCHOR_POINT_Y) || styleJson.has(JSON_LABEL_ALIGN) || styleJson.has(JSON_LABEL_X_OFFSET) || styleJson.has(JSON_LABEL_Y_OFFSET) || styleJson.has(JSON_LABEL_ROTATION) || styleJson.has(JSON_LABEL_PERPENDICULAR_OFFSET)) { textSymbolizer.setLabelPlacement(createLabelPlacement(styleJson)); } if (!StringUtils.isEmpty(styleJson.optString(JSON_HALO_RADIUS)) || !StringUtils.isEmpty(styleJson.optString(JSON_HALO_COLOR)) || !StringUtils.isEmpty(styleJson.optString(JSON_HALO_OPACITY)) || !StringUtils.isEmpty(styleJson.optString(JSON_LABEL_OUTLINE_WIDTH)) || !StringUtils.isEmpty(styleJson.optString(JSON_LABEL_OUTLINE_COLOR))) { textSymbolizer.setHalo(createHalo(styleJson)); } if (!StringUtils.isEmpty(styleJson.optString(JSON_FONT_COLOR)) || !StringUtils.isEmpty(styleJson.optString(JSON_FONT_OPACITY))) { textSymbolizer.setFill(addFill( styleJson.optString(JSON_FONT_COLOR, "black"), styleJson.optString(JSON_FONT_OPACITY, "1.0"))); } this.addVendorOptions(JSON_LABEL_ALLOW_OVERRUNS, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_AUTO_WRAP, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_CONFLICT_RESOLUTION, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_FOLLOW_LINE, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_GOODNESS_OF_FIT, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_GROUP, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_MAX_DISPLACEMENT, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_SPACE_AROUND, styleJson, textSymbolizer); return textSymbolizer; }
java
@VisibleForTesting protected TextSymbolizer createTextSymbolizer(final PJsonObject styleJson) { final TextSymbolizer textSymbolizer = this.styleBuilder.createTextSymbolizer(); // make sure that labels are also rendered if a part of the text would be outside // the view context, see http://docs.geoserver.org/stable/en/user/styling/sld-reference/labeling // .html#partials textSymbolizer.getOptions().put("partials", "true"); if (styleJson.has(JSON_LABEL)) { final Expression label = parseExpression(null, styleJson, JSON_LABEL, (final String labelValue) -> labelValue.replace("${", "") .replace("}", "")); textSymbolizer.setLabel(label); } else { return null; } textSymbolizer.setFont(createFont(textSymbolizer.getFont(), styleJson)); if (styleJson.has(JSON_LABEL_ANCHOR_POINT_X) || styleJson.has(JSON_LABEL_ANCHOR_POINT_Y) || styleJson.has(JSON_LABEL_ALIGN) || styleJson.has(JSON_LABEL_X_OFFSET) || styleJson.has(JSON_LABEL_Y_OFFSET) || styleJson.has(JSON_LABEL_ROTATION) || styleJson.has(JSON_LABEL_PERPENDICULAR_OFFSET)) { textSymbolizer.setLabelPlacement(createLabelPlacement(styleJson)); } if (!StringUtils.isEmpty(styleJson.optString(JSON_HALO_RADIUS)) || !StringUtils.isEmpty(styleJson.optString(JSON_HALO_COLOR)) || !StringUtils.isEmpty(styleJson.optString(JSON_HALO_OPACITY)) || !StringUtils.isEmpty(styleJson.optString(JSON_LABEL_OUTLINE_WIDTH)) || !StringUtils.isEmpty(styleJson.optString(JSON_LABEL_OUTLINE_COLOR))) { textSymbolizer.setHalo(createHalo(styleJson)); } if (!StringUtils.isEmpty(styleJson.optString(JSON_FONT_COLOR)) || !StringUtils.isEmpty(styleJson.optString(JSON_FONT_OPACITY))) { textSymbolizer.setFill(addFill( styleJson.optString(JSON_FONT_COLOR, "black"), styleJson.optString(JSON_FONT_OPACITY, "1.0"))); } this.addVendorOptions(JSON_LABEL_ALLOW_OVERRUNS, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_AUTO_WRAP, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_CONFLICT_RESOLUTION, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_FOLLOW_LINE, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_GOODNESS_OF_FIT, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_GROUP, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_MAX_DISPLACEMENT, styleJson, textSymbolizer); this.addVendorOptions(JSON_LABEL_SPACE_AROUND, styleJson, textSymbolizer); return textSymbolizer; }
[ "@", "VisibleForTesting", "protected", "TextSymbolizer", "createTextSymbolizer", "(", "final", "PJsonObject", "styleJson", ")", "{", "final", "TextSymbolizer", "textSymbolizer", "=", "this", ".", "styleBuilder", ".", "createTextSymbolizer", "(", ")", ";", "// make sure that labels are also rendered if a part of the text would be outside", "// the view context, see http://docs.geoserver.org/stable/en/user/styling/sld-reference/labeling", "// .html#partials", "textSymbolizer", ".", "getOptions", "(", ")", ".", "put", "(", "\"partials\"", ",", "\"true\"", ")", ";", "if", "(", "styleJson", ".", "has", "(", "JSON_LABEL", ")", ")", "{", "final", "Expression", "label", "=", "parseExpression", "(", "null", ",", "styleJson", ",", "JSON_LABEL", ",", "(", "final", "String", "labelValue", ")", "->", "labelValue", ".", "replace", "(", "\"${\"", ",", "\"\"", ")", ".", "replace", "(", "\"}\"", ",", "\"\"", ")", ")", ";", "textSymbolizer", ".", "setLabel", "(", "label", ")", ";", "}", "else", "{", "return", "null", ";", "}", "textSymbolizer", ".", "setFont", "(", "createFont", "(", "textSymbolizer", ".", "getFont", "(", ")", ",", "styleJson", ")", ")", ";", "if", "(", "styleJson", ".", "has", "(", "JSON_LABEL_ANCHOR_POINT_X", ")", "||", "styleJson", ".", "has", "(", "JSON_LABEL_ANCHOR_POINT_Y", ")", "||", "styleJson", ".", "has", "(", "JSON_LABEL_ALIGN", ")", "||", "styleJson", ".", "has", "(", "JSON_LABEL_X_OFFSET", ")", "||", "styleJson", ".", "has", "(", "JSON_LABEL_Y_OFFSET", ")", "||", "styleJson", ".", "has", "(", "JSON_LABEL_ROTATION", ")", "||", "styleJson", ".", "has", "(", "JSON_LABEL_PERPENDICULAR_OFFSET", ")", ")", "{", "textSymbolizer", ".", "setLabelPlacement", "(", "createLabelPlacement", "(", "styleJson", ")", ")", ";", "}", "if", "(", "!", "StringUtils", ".", "isEmpty", "(", "styleJson", ".", "optString", "(", "JSON_HALO_RADIUS", ")", ")", "||", "!", "StringUtils", ".", "isEmpty", "(", "styleJson", ".", "optString", "(", "JSON_HALO_COLOR", ")", ")", "||", "!", "StringUtils", ".", "isEmpty", "(", "styleJson", ".", "optString", "(", "JSON_HALO_OPACITY", ")", ")", "||", "!", "StringUtils", ".", "isEmpty", "(", "styleJson", ".", "optString", "(", "JSON_LABEL_OUTLINE_WIDTH", ")", ")", "||", "!", "StringUtils", ".", "isEmpty", "(", "styleJson", ".", "optString", "(", "JSON_LABEL_OUTLINE_COLOR", ")", ")", ")", "{", "textSymbolizer", ".", "setHalo", "(", "createHalo", "(", "styleJson", ")", ")", ";", "}", "if", "(", "!", "StringUtils", ".", "isEmpty", "(", "styleJson", ".", "optString", "(", "JSON_FONT_COLOR", ")", ")", "||", "!", "StringUtils", ".", "isEmpty", "(", "styleJson", ".", "optString", "(", "JSON_FONT_OPACITY", ")", ")", ")", "{", "textSymbolizer", ".", "setFill", "(", "addFill", "(", "styleJson", ".", "optString", "(", "JSON_FONT_COLOR", ",", "\"black\"", ")", ",", "styleJson", ".", "optString", "(", "JSON_FONT_OPACITY", ",", "\"1.0\"", ")", ")", ")", ";", "}", "this", ".", "addVendorOptions", "(", "JSON_LABEL_ALLOW_OVERRUNS", ",", "styleJson", ",", "textSymbolizer", ")", ";", "this", ".", "addVendorOptions", "(", "JSON_LABEL_AUTO_WRAP", ",", "styleJson", ",", "textSymbolizer", ")", ";", "this", ".", "addVendorOptions", "(", "JSON_LABEL_CONFLICT_RESOLUTION", ",", "styleJson", ",", "textSymbolizer", ")", ";", "this", ".", "addVendorOptions", "(", "JSON_LABEL_FOLLOW_LINE", ",", "styleJson", ",", "textSymbolizer", ")", ";", "this", ".", "addVendorOptions", "(", "JSON_LABEL_GOODNESS_OF_FIT", ",", "styleJson", ",", "textSymbolizer", ")", ";", "this", ".", "addVendorOptions", "(", "JSON_LABEL_GROUP", ",", "styleJson", ",", "textSymbolizer", ")", ";", "this", ".", "addVendorOptions", "(", "JSON_LABEL_MAX_DISPLACEMENT", ",", "styleJson", ",", "textSymbolizer", ")", ";", "this", ".", "addVendorOptions", "(", "JSON_LABEL_SPACE_AROUND", ",", "styleJson", ",", "textSymbolizer", ")", ";", "return", "textSymbolizer", ";", "}" ]
Add a text symbolizer definition to the rule. @param styleJson The old style.
[ "Add", "a", "text", "symbolizer", "definition", "to", "the", "rule", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/style/json/JsonStyleParserHelper.java#L334-L391
159,346
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/url/data/Handler.java
Handler.configureProtocolHandler
public static void configureProtocolHandler() { final String pkgs = System.getProperty("java.protocol.handler.pkgs"); String newValue = "org.mapfish.print.url"; if (pkgs != null && !pkgs.contains(newValue)) { newValue = newValue + "|" + pkgs; } else if (pkgs != null) { newValue = pkgs; } System.setProperty("java.protocol.handler.pkgs", newValue); }
java
public static void configureProtocolHandler() { final String pkgs = System.getProperty("java.protocol.handler.pkgs"); String newValue = "org.mapfish.print.url"; if (pkgs != null && !pkgs.contains(newValue)) { newValue = newValue + "|" + pkgs; } else if (pkgs != null) { newValue = pkgs; } System.setProperty("java.protocol.handler.pkgs", newValue); }
[ "public", "static", "void", "configureProtocolHandler", "(", ")", "{", "final", "String", "pkgs", "=", "System", ".", "getProperty", "(", "\"java.protocol.handler.pkgs\"", ")", ";", "String", "newValue", "=", "\"org.mapfish.print.url\"", ";", "if", "(", "pkgs", "!=", "null", "&&", "!", "pkgs", ".", "contains", "(", "newValue", ")", ")", "{", "newValue", "=", "newValue", "+", "\"|\"", "+", "pkgs", ";", "}", "else", "if", "(", "pkgs", "!=", "null", ")", "{", "newValue", "=", "pkgs", ";", "}", "System", ".", "setProperty", "(", "\"java.protocol.handler.pkgs\"", ",", "newValue", ")", ";", "}" ]
Adds the parent package to the java.protocol.handler.pkgs system property.
[ "Adds", "the", "parent", "package", "to", "the", "java", ".", "protocol", ".", "handler", ".", "pkgs", "system", "property", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/url/data/Handler.java#L16-L25
159,347
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/AbstractFeatureSourceLayerPlugin.java
AbstractFeatureSourceLayerPlugin.createStyleFunction
protected final StyleSupplier<FeatureSource> createStyleFunction( final Template template, final String styleString) { return new StyleSupplier<FeatureSource>() { @Override public Style load( final MfClientHttpRequestFactory requestFactory, final FeatureSource featureSource) { if (featureSource == null) { throw new IllegalArgumentException("Feature source cannot be null"); } final String geomType = featureSource.getSchema() == null ? Geometry.class.getSimpleName().toLowerCase() : featureSource.getSchema().getGeometryDescriptor().getType().getBinding() .getSimpleName(); final String styleRef = styleString != null ? styleString : geomType; final StyleParser styleParser = AbstractFeatureSourceLayerPlugin.this.parser; return OptionalUtils.or( () -> template.getStyle(styleRef), () -> styleParser.loadStyle(template.getConfiguration(), requestFactory, styleRef)) .orElseGet(() -> template.getConfiguration().getDefaultStyle(geomType)); } }; }
java
protected final StyleSupplier<FeatureSource> createStyleFunction( final Template template, final String styleString) { return new StyleSupplier<FeatureSource>() { @Override public Style load( final MfClientHttpRequestFactory requestFactory, final FeatureSource featureSource) { if (featureSource == null) { throw new IllegalArgumentException("Feature source cannot be null"); } final String geomType = featureSource.getSchema() == null ? Geometry.class.getSimpleName().toLowerCase() : featureSource.getSchema().getGeometryDescriptor().getType().getBinding() .getSimpleName(); final String styleRef = styleString != null ? styleString : geomType; final StyleParser styleParser = AbstractFeatureSourceLayerPlugin.this.parser; return OptionalUtils.or( () -> template.getStyle(styleRef), () -> styleParser.loadStyle(template.getConfiguration(), requestFactory, styleRef)) .orElseGet(() -> template.getConfiguration().getDefaultStyle(geomType)); } }; }
[ "protected", "final", "StyleSupplier", "<", "FeatureSource", ">", "createStyleFunction", "(", "final", "Template", "template", ",", "final", "String", "styleString", ")", "{", "return", "new", "StyleSupplier", "<", "FeatureSource", ">", "(", ")", "{", "@", "Override", "public", "Style", "load", "(", "final", "MfClientHttpRequestFactory", "requestFactory", ",", "final", "FeatureSource", "featureSource", ")", "{", "if", "(", "featureSource", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Feature source cannot be null\"", ")", ";", "}", "final", "String", "geomType", "=", "featureSource", ".", "getSchema", "(", ")", "==", "null", "?", "Geometry", ".", "class", ".", "getSimpleName", "(", ")", ".", "toLowerCase", "(", ")", ":", "featureSource", ".", "getSchema", "(", ")", ".", "getGeometryDescriptor", "(", ")", ".", "getType", "(", ")", ".", "getBinding", "(", ")", ".", "getSimpleName", "(", ")", ";", "final", "String", "styleRef", "=", "styleString", "!=", "null", "?", "styleString", ":", "geomType", ";", "final", "StyleParser", "styleParser", "=", "AbstractFeatureSourceLayerPlugin", ".", "this", ".", "parser", ";", "return", "OptionalUtils", ".", "or", "(", "(", ")", "->", "template", ".", "getStyle", "(", "styleRef", ")", ",", "(", ")", "->", "styleParser", ".", "loadStyle", "(", "template", ".", "getConfiguration", "(", ")", ",", "requestFactory", ",", "styleRef", ")", ")", ".", "orElseGet", "(", "(", ")", "->", "template", ".", "getConfiguration", "(", ")", ".", "getDefaultStyle", "(", "geomType", ")", ")", ";", "}", "}", ";", "}" ]
Create a function that will create the style on demand. This is called later in a separate thread so any blocking calls will not block the parsing of the layer attributes. @param template the template for this map @param styleString a string that identifies a style.
[ "Create", "a", "function", "that", "will", "create", "the", "style", "on", "demand", ".", "This", "is", "called", "later", "in", "a", "separate", "thread", "so", "any", "blocking", "calls", "will", "not", "block", "the", "parsing", "of", "the", "layer", "attributes", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/AbstractFeatureSourceLayerPlugin.java#L60-L85
159,348
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/image/wms/WmsUtilities.java
WmsUtilities.makeWmsGetLayerRequest
public static URI makeWmsGetLayerRequest( final WmsLayerParam wmsLayerParam, final URI commonURI, final Dimension imageSize, final double dpi, final double angle, final ReferencedEnvelope bounds) throws FactoryException, URISyntaxException, IOException { if (commonURI == null || commonURI.getAuthority() == null) { throw new RuntimeException("Invalid WMS URI: " + commonURI); } String[] authority = commonURI.getAuthority().split(":"); URL url; if (authority.length == 2) { url = new URL( commonURI.getScheme(), authority[0], Integer.parseInt(authority[1]), commonURI.getPath() ); } else { url = new URL( commonURI.getScheme(), authority[0], commonURI.getPath() ); } final GetMapRequest getMapRequest = WmsVersion.lookup(wmsLayerParam.version). getGetMapRequest(url); getMapRequest.setBBox(bounds); getMapRequest.setDimensions(imageSize.width, imageSize.height); getMapRequest.setFormat(wmsLayerParam.imageFormat); getMapRequest.setSRS(CRS.lookupIdentifier(bounds.getCoordinateReferenceSystem(), false)); for (int i = wmsLayerParam.layers.length - 1; i > -1; i--) { String layer = wmsLayerParam.layers[i]; String style = ""; if (wmsLayerParam.styles != null) { style = wmsLayerParam.styles[i]; } getMapRequest.addLayer(layer, style); } final URI getMapUri = getMapRequest.getFinalURL().toURI(); Multimap<String, String> extraParams = HashMultimap.create(); if (commonURI.getQuery() != null) { for (NameValuePair pair: URLEncodedUtils.parse(commonURI, Charset.forName("UTF-8"))) { extraParams.put(pair.getName(), pair.getValue()); } } extraParams.putAll(wmsLayerParam.getMergeableParams()); extraParams.putAll(wmsLayerParam.getCustomParams()); if (wmsLayerParam.serverType != null) { addDpiParam(extraParams, (int) Math.round(dpi), wmsLayerParam.serverType); if (wmsLayerParam.useNativeAngle && angle != 0.0) { addAngleParam(extraParams, angle, wmsLayerParam.serverType); } } return URIUtils.addParams(getMapUri, extraParams, Collections.emptySet()); }
java
public static URI makeWmsGetLayerRequest( final WmsLayerParam wmsLayerParam, final URI commonURI, final Dimension imageSize, final double dpi, final double angle, final ReferencedEnvelope bounds) throws FactoryException, URISyntaxException, IOException { if (commonURI == null || commonURI.getAuthority() == null) { throw new RuntimeException("Invalid WMS URI: " + commonURI); } String[] authority = commonURI.getAuthority().split(":"); URL url; if (authority.length == 2) { url = new URL( commonURI.getScheme(), authority[0], Integer.parseInt(authority[1]), commonURI.getPath() ); } else { url = new URL( commonURI.getScheme(), authority[0], commonURI.getPath() ); } final GetMapRequest getMapRequest = WmsVersion.lookup(wmsLayerParam.version). getGetMapRequest(url); getMapRequest.setBBox(bounds); getMapRequest.setDimensions(imageSize.width, imageSize.height); getMapRequest.setFormat(wmsLayerParam.imageFormat); getMapRequest.setSRS(CRS.lookupIdentifier(bounds.getCoordinateReferenceSystem(), false)); for (int i = wmsLayerParam.layers.length - 1; i > -1; i--) { String layer = wmsLayerParam.layers[i]; String style = ""; if (wmsLayerParam.styles != null) { style = wmsLayerParam.styles[i]; } getMapRequest.addLayer(layer, style); } final URI getMapUri = getMapRequest.getFinalURL().toURI(); Multimap<String, String> extraParams = HashMultimap.create(); if (commonURI.getQuery() != null) { for (NameValuePair pair: URLEncodedUtils.parse(commonURI, Charset.forName("UTF-8"))) { extraParams.put(pair.getName(), pair.getValue()); } } extraParams.putAll(wmsLayerParam.getMergeableParams()); extraParams.putAll(wmsLayerParam.getCustomParams()); if (wmsLayerParam.serverType != null) { addDpiParam(extraParams, (int) Math.round(dpi), wmsLayerParam.serverType); if (wmsLayerParam.useNativeAngle && angle != 0.0) { addAngleParam(extraParams, angle, wmsLayerParam.serverType); } } return URIUtils.addParams(getMapUri, extraParams, Collections.emptySet()); }
[ "public", "static", "URI", "makeWmsGetLayerRequest", "(", "final", "WmsLayerParam", "wmsLayerParam", ",", "final", "URI", "commonURI", ",", "final", "Dimension", "imageSize", ",", "final", "double", "dpi", ",", "final", "double", "angle", ",", "final", "ReferencedEnvelope", "bounds", ")", "throws", "FactoryException", ",", "URISyntaxException", ",", "IOException", "{", "if", "(", "commonURI", "==", "null", "||", "commonURI", ".", "getAuthority", "(", ")", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"Invalid WMS URI: \"", "+", "commonURI", ")", ";", "}", "String", "[", "]", "authority", "=", "commonURI", ".", "getAuthority", "(", ")", ".", "split", "(", "\":\"", ")", ";", "URL", "url", ";", "if", "(", "authority", ".", "length", "==", "2", ")", "{", "url", "=", "new", "URL", "(", "commonURI", ".", "getScheme", "(", ")", ",", "authority", "[", "0", "]", ",", "Integer", ".", "parseInt", "(", "authority", "[", "1", "]", ")", ",", "commonURI", ".", "getPath", "(", ")", ")", ";", "}", "else", "{", "url", "=", "new", "URL", "(", "commonURI", ".", "getScheme", "(", ")", ",", "authority", "[", "0", "]", ",", "commonURI", ".", "getPath", "(", ")", ")", ";", "}", "final", "GetMapRequest", "getMapRequest", "=", "WmsVersion", ".", "lookup", "(", "wmsLayerParam", ".", "version", ")", ".", "getGetMapRequest", "(", "url", ")", ";", "getMapRequest", ".", "setBBox", "(", "bounds", ")", ";", "getMapRequest", ".", "setDimensions", "(", "imageSize", ".", "width", ",", "imageSize", ".", "height", ")", ";", "getMapRequest", ".", "setFormat", "(", "wmsLayerParam", ".", "imageFormat", ")", ";", "getMapRequest", ".", "setSRS", "(", "CRS", ".", "lookupIdentifier", "(", "bounds", ".", "getCoordinateReferenceSystem", "(", ")", ",", "false", ")", ")", ";", "for", "(", "int", "i", "=", "wmsLayerParam", ".", "layers", ".", "length", "-", "1", ";", "i", ">", "-", "1", ";", "i", "--", ")", "{", "String", "layer", "=", "wmsLayerParam", ".", "layers", "[", "i", "]", ";", "String", "style", "=", "\"\"", ";", "if", "(", "wmsLayerParam", ".", "styles", "!=", "null", ")", "{", "style", "=", "wmsLayerParam", ".", "styles", "[", "i", "]", ";", "}", "getMapRequest", ".", "addLayer", "(", "layer", ",", "style", ")", ";", "}", "final", "URI", "getMapUri", "=", "getMapRequest", ".", "getFinalURL", "(", ")", ".", "toURI", "(", ")", ";", "Multimap", "<", "String", ",", "String", ">", "extraParams", "=", "HashMultimap", ".", "create", "(", ")", ";", "if", "(", "commonURI", ".", "getQuery", "(", ")", "!=", "null", ")", "{", "for", "(", "NameValuePair", "pair", ":", "URLEncodedUtils", ".", "parse", "(", "commonURI", ",", "Charset", ".", "forName", "(", "\"UTF-8\"", ")", ")", ")", "{", "extraParams", ".", "put", "(", "pair", ".", "getName", "(", ")", ",", "pair", ".", "getValue", "(", ")", ")", ";", "}", "}", "extraParams", ".", "putAll", "(", "wmsLayerParam", ".", "getMergeableParams", "(", ")", ")", ";", "extraParams", ".", "putAll", "(", "wmsLayerParam", ".", "getCustomParams", "(", ")", ")", ";", "if", "(", "wmsLayerParam", ".", "serverType", "!=", "null", ")", "{", "addDpiParam", "(", "extraParams", ",", "(", "int", ")", "Math", ".", "round", "(", "dpi", ")", ",", "wmsLayerParam", ".", "serverType", ")", ";", "if", "(", "wmsLayerParam", ".", "useNativeAngle", "&&", "angle", "!=", "0.0", ")", "{", "addAngleParam", "(", "extraParams", ",", "angle", ",", "wmsLayerParam", ".", "serverType", ")", ";", "}", "}", "return", "URIUtils", ".", "addParams", "(", "getMapUri", ",", "extraParams", ",", "Collections", ".", "emptySet", "(", ")", ")", ";", "}" ]
Make a WMS getLayer request and return the image read from the server. @param wmsLayerParam the wms request parameters @param commonURI the uri to use for the requests (excepting parameters of course.) @param imageSize the size of the image to request @param dpi the dpi of the image to request @param angle the angle of the image to request @param bounds the area and projection of the request on the world.
[ "Make", "a", "WMS", "getLayer", "request", "and", "return", "the", "image", "read", "from", "the", "server", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/image/wms/WmsUtilities.java#L48-L108
159,349
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/image/wms/WmsUtilities.java
WmsUtilities.isDpiSet
private static boolean isDpiSet(final Multimap<String, String> extraParams) { String searchKey = "FORMAT_OPTIONS"; for (String key: extraParams.keys()) { if (key.equalsIgnoreCase(searchKey)) { for (String value: extraParams.get(key)) { if (value.toLowerCase().contains("dpi:")) { return true; } } } } return false; }
java
private static boolean isDpiSet(final Multimap<String, String> extraParams) { String searchKey = "FORMAT_OPTIONS"; for (String key: extraParams.keys()) { if (key.equalsIgnoreCase(searchKey)) { for (String value: extraParams.get(key)) { if (value.toLowerCase().contains("dpi:")) { return true; } } } } return false; }
[ "private", "static", "boolean", "isDpiSet", "(", "final", "Multimap", "<", "String", ",", "String", ">", "extraParams", ")", "{", "String", "searchKey", "=", "\"FORMAT_OPTIONS\"", ";", "for", "(", "String", "key", ":", "extraParams", ".", "keys", "(", ")", ")", "{", "if", "(", "key", ".", "equalsIgnoreCase", "(", "searchKey", ")", ")", "{", "for", "(", "String", "value", ":", "extraParams", ".", "get", "(", "key", ")", ")", "{", "if", "(", "value", ".", "toLowerCase", "(", ")", ".", "contains", "(", "\"dpi:\"", ")", ")", "{", "return", "true", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
Checks if the DPI value is already set for GeoServer.
[ "Checks", "if", "the", "DPI", "value", "is", "already", "set", "for", "GeoServer", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/image/wms/WmsUtilities.java#L171-L183
159,350
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/image/wms/WmsUtilities.java
WmsUtilities.setDpiValue
private static void setDpiValue(final Multimap<String, String> extraParams, final int dpi) { String searchKey = "FORMAT_OPTIONS"; for (String key: extraParams.keys()) { if (key.equalsIgnoreCase(searchKey)) { Collection<String> values = extraParams.removeAll(key); List<String> newValues = new ArrayList<>(); for (String value: values) { if (!StringUtils.isEmpty(value)) { value += ";dpi:" + Integer.toString(dpi); newValues.add(value); } } extraParams.putAll(key, newValues); return; } } }
java
private static void setDpiValue(final Multimap<String, String> extraParams, final int dpi) { String searchKey = "FORMAT_OPTIONS"; for (String key: extraParams.keys()) { if (key.equalsIgnoreCase(searchKey)) { Collection<String> values = extraParams.removeAll(key); List<String> newValues = new ArrayList<>(); for (String value: values) { if (!StringUtils.isEmpty(value)) { value += ";dpi:" + Integer.toString(dpi); newValues.add(value); } } extraParams.putAll(key, newValues); return; } } }
[ "private", "static", "void", "setDpiValue", "(", "final", "Multimap", "<", "String", ",", "String", ">", "extraParams", ",", "final", "int", "dpi", ")", "{", "String", "searchKey", "=", "\"FORMAT_OPTIONS\"", ";", "for", "(", "String", "key", ":", "extraParams", ".", "keys", "(", ")", ")", "{", "if", "(", "key", ".", "equalsIgnoreCase", "(", "searchKey", ")", ")", "{", "Collection", "<", "String", ">", "values", "=", "extraParams", ".", "removeAll", "(", "key", ")", ";", "List", "<", "String", ">", "newValues", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "value", ":", "values", ")", "{", "if", "(", "!", "StringUtils", ".", "isEmpty", "(", "value", ")", ")", "{", "value", "+=", "\";dpi:\"", "+", "Integer", ".", "toString", "(", "dpi", ")", ";", "newValues", ".", "add", "(", "value", ")", ";", "}", "}", "extraParams", ".", "putAll", "(", "key", ",", "newValues", ")", ";", "return", ";", "}", "}", "}" ]
Set the DPI value for GeoServer if there are already FORMAT_OPTIONS.
[ "Set", "the", "DPI", "value", "for", "GeoServer", "if", "there", "are", "already", "FORMAT_OPTIONS", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/image/wms/WmsUtilities.java#L188-L204
159,351
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java
GridUtils.calculateBounds
public static Polygon calculateBounds(final MapfishMapContext context) { double rotation = context.getRootContext().getRotation(); ReferencedEnvelope env = context.getRootContext().toReferencedEnvelope(); Coordinate centre = env.centre(); AffineTransform rotateInstance = AffineTransform.getRotateInstance(rotation, centre.x, centre.y); double[] dstPts = new double[8]; double[] srcPts = { env.getMinX(), env.getMinY(), env.getMinX(), env.getMaxY(), env.getMaxX(), env.getMaxY(), env.getMaxX(), env.getMinY() }; rotateInstance.transform(srcPts, 0, dstPts, 0, 4); return new GeometryFactory().createPolygon(new Coordinate[]{ new Coordinate(dstPts[0], dstPts[1]), new Coordinate(dstPts[2], dstPts[3]), new Coordinate(dstPts[4], dstPts[5]), new Coordinate(dstPts[6], dstPts[7]), new Coordinate(dstPts[0], dstPts[1]) }); }
java
public static Polygon calculateBounds(final MapfishMapContext context) { double rotation = context.getRootContext().getRotation(); ReferencedEnvelope env = context.getRootContext().toReferencedEnvelope(); Coordinate centre = env.centre(); AffineTransform rotateInstance = AffineTransform.getRotateInstance(rotation, centre.x, centre.y); double[] dstPts = new double[8]; double[] srcPts = { env.getMinX(), env.getMinY(), env.getMinX(), env.getMaxY(), env.getMaxX(), env.getMaxY(), env.getMaxX(), env.getMinY() }; rotateInstance.transform(srcPts, 0, dstPts, 0, 4); return new GeometryFactory().createPolygon(new Coordinate[]{ new Coordinate(dstPts[0], dstPts[1]), new Coordinate(dstPts[2], dstPts[3]), new Coordinate(dstPts[4], dstPts[5]), new Coordinate(dstPts[6], dstPts[7]), new Coordinate(dstPts[0], dstPts[1]) }); }
[ "public", "static", "Polygon", "calculateBounds", "(", "final", "MapfishMapContext", "context", ")", "{", "double", "rotation", "=", "context", ".", "getRootContext", "(", ")", ".", "getRotation", "(", ")", ";", "ReferencedEnvelope", "env", "=", "context", ".", "getRootContext", "(", ")", ".", "toReferencedEnvelope", "(", ")", ";", "Coordinate", "centre", "=", "env", ".", "centre", "(", ")", ";", "AffineTransform", "rotateInstance", "=", "AffineTransform", ".", "getRotateInstance", "(", "rotation", ",", "centre", ".", "x", ",", "centre", ".", "y", ")", ";", "double", "[", "]", "dstPts", "=", "new", "double", "[", "8", "]", ";", "double", "[", "]", "srcPts", "=", "{", "env", ".", "getMinX", "(", ")", ",", "env", ".", "getMinY", "(", ")", ",", "env", ".", "getMinX", "(", ")", ",", "env", ".", "getMaxY", "(", ")", ",", "env", ".", "getMaxX", "(", ")", ",", "env", ".", "getMaxY", "(", ")", ",", "env", ".", "getMaxX", "(", ")", ",", "env", ".", "getMinY", "(", ")", "}", ";", "rotateInstance", ".", "transform", "(", "srcPts", ",", "0", ",", "dstPts", ",", "0", ",", "4", ")", ";", "return", "new", "GeometryFactory", "(", ")", ".", "createPolygon", "(", "new", "Coordinate", "[", "]", "{", "new", "Coordinate", "(", "dstPts", "[", "0", "]", ",", "dstPts", "[", "1", "]", ")", ",", "new", "Coordinate", "(", "dstPts", "[", "2", "]", ",", "dstPts", "[", "3", "]", ")", ",", "new", "Coordinate", "(", "dstPts", "[", "4", "]", ",", "dstPts", "[", "5", "]", ")", ",", "new", "Coordinate", "(", "dstPts", "[", "6", "]", ",", "dstPts", "[", "7", "]", ")", ",", "new", "Coordinate", "(", "dstPts", "[", "0", "]", ",", "dstPts", "[", "1", "]", ")", "}", ")", ";", "}" ]
Create a polygon that represents in world space the exact area that will be visible on the printed map. @param context map context
[ "Create", "a", "polygon", "that", "represents", "in", "world", "space", "the", "exact", "area", "that", "will", "be", "visible", "on", "the", "printed", "map", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java#L42-L62
159,352
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java
GridUtils.createGridFeatureType
public static SimpleFeatureType createGridFeatureType( @Nonnull final MapfishMapContext mapContext, @Nonnull final Class<? extends Geometry> geomClass) { final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); CoordinateReferenceSystem projection = mapContext.getBounds().getProjection(); typeBuilder.add(Constants.Style.Grid.ATT_GEOM, geomClass, projection); typeBuilder.setName(Constants.Style.Grid.NAME_LINES); return typeBuilder.buildFeatureType(); }
java
public static SimpleFeatureType createGridFeatureType( @Nonnull final MapfishMapContext mapContext, @Nonnull final Class<? extends Geometry> geomClass) { final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); CoordinateReferenceSystem projection = mapContext.getBounds().getProjection(); typeBuilder.add(Constants.Style.Grid.ATT_GEOM, geomClass, projection); typeBuilder.setName(Constants.Style.Grid.NAME_LINES); return typeBuilder.buildFeatureType(); }
[ "public", "static", "SimpleFeatureType", "createGridFeatureType", "(", "@", "Nonnull", "final", "MapfishMapContext", "mapContext", ",", "@", "Nonnull", "final", "Class", "<", "?", "extends", "Geometry", ">", "geomClass", ")", "{", "final", "SimpleFeatureTypeBuilder", "typeBuilder", "=", "new", "SimpleFeatureTypeBuilder", "(", ")", ";", "CoordinateReferenceSystem", "projection", "=", "mapContext", ".", "getBounds", "(", ")", ".", "getProjection", "(", ")", ";", "typeBuilder", ".", "add", "(", "Constants", ".", "Style", ".", "Grid", ".", "ATT_GEOM", ",", "geomClass", ",", "projection", ")", ";", "typeBuilder", ".", "setName", "(", "Constants", ".", "Style", ".", "Grid", ".", "NAME_LINES", ")", ";", "return", "typeBuilder", ".", "buildFeatureType", "(", ")", ";", "}" ]
Create the grid feature type. @param mapContext the map context containing the information about the map the grid will be added to. @param geomClass the geometry type
[ "Create", "the", "grid", "feature", "type", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java#L89-L98
159,353
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java
GridUtils.createLabel
public static String createLabel(final double value, final String unit, final GridLabelFormat format) { final double zero = 0.000000001; if (format != null) { return format.format(value, unit); } else { if (Math.abs(value - Math.round(value)) < zero) { return String.format("%d %s", Math.round(value), unit); } else if ("m".equals(unit)) { // meter: no decimals return String.format("%1.0f %s", value, unit); } else if (NonSI.DEGREE_ANGLE.toString().equals(unit)) { // degree: by default 6 decimals return String.format("%1.6f %s", value, unit); } else { return String.format("%f %s", value, unit); } } }
java
public static String createLabel(final double value, final String unit, final GridLabelFormat format) { final double zero = 0.000000001; if (format != null) { return format.format(value, unit); } else { if (Math.abs(value - Math.round(value)) < zero) { return String.format("%d %s", Math.round(value), unit); } else if ("m".equals(unit)) { // meter: no decimals return String.format("%1.0f %s", value, unit); } else if (NonSI.DEGREE_ANGLE.toString().equals(unit)) { // degree: by default 6 decimals return String.format("%1.6f %s", value, unit); } else { return String.format("%f %s", value, unit); } } }
[ "public", "static", "String", "createLabel", "(", "final", "double", "value", ",", "final", "String", "unit", ",", "final", "GridLabelFormat", "format", ")", "{", "final", "double", "zero", "=", "0.000000001", ";", "if", "(", "format", "!=", "null", ")", "{", "return", "format", ".", "format", "(", "value", ",", "unit", ")", ";", "}", "else", "{", "if", "(", "Math", ".", "abs", "(", "value", "-", "Math", ".", "round", "(", "value", ")", ")", "<", "zero", ")", "{", "return", "String", ".", "format", "(", "\"%d %s\"", ",", "Math", ".", "round", "(", "value", ")", ",", "unit", ")", ";", "}", "else", "if", "(", "\"m\"", ".", "equals", "(", "unit", ")", ")", "{", "// meter: no decimals", "return", "String", ".", "format", "(", "\"%1.0f %s\"", ",", "value", ",", "unit", ")", ";", "}", "else", "if", "(", "NonSI", ".", "DEGREE_ANGLE", ".", "toString", "(", ")", ".", "equals", "(", "unit", ")", ")", "{", "// degree: by default 6 decimals", "return", "String", ".", "format", "(", "\"%1.6f %s\"", ",", "value", ",", "unit", ")", ";", "}", "else", "{", "return", "String", ".", "format", "(", "\"%f %s\"", ",", "value", ",", "unit", ")", ";", "}", "}", "}" ]
Create the label for a grid line. @param value the value of the line @param unit the unit that the value is in
[ "Create", "the", "label", "for", "a", "grid", "line", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java#L106-L123
159,354
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/parser/MapfishParser.java
MapfishParser.parsePrimitive
public static Object parsePrimitive( final String fieldName, final PrimitiveAttribute<?> pAtt, final PObject requestData) { Class<?> valueClass = pAtt.getValueClass(); Object value; try { value = parseValue(false, new String[0], valueClass, fieldName, requestData); } catch (UnsupportedTypeException e) { String type = e.type.getName(); if (e.type.isArray()) { type = e.type.getComponentType().getName() + "[]"; } throw new RuntimeException( "The type '" + type + "' is not a supported type when parsing json. " + "See documentation for supported types.\n\nUnsupported type found in attribute " + fieldName + "\n\nTo support more types add the type to " + "parseValue and parseArrayValue in this class and add a test to the test class", e); } pAtt.validateValue(value); return value; }
java
public static Object parsePrimitive( final String fieldName, final PrimitiveAttribute<?> pAtt, final PObject requestData) { Class<?> valueClass = pAtt.getValueClass(); Object value; try { value = parseValue(false, new String[0], valueClass, fieldName, requestData); } catch (UnsupportedTypeException e) { String type = e.type.getName(); if (e.type.isArray()) { type = e.type.getComponentType().getName() + "[]"; } throw new RuntimeException( "The type '" + type + "' is not a supported type when parsing json. " + "See documentation for supported types.\n\nUnsupported type found in attribute " + fieldName + "\n\nTo support more types add the type to " + "parseValue and parseArrayValue in this class and add a test to the test class", e); } pAtt.validateValue(value); return value; }
[ "public", "static", "Object", "parsePrimitive", "(", "final", "String", "fieldName", ",", "final", "PrimitiveAttribute", "<", "?", ">", "pAtt", ",", "final", "PObject", "requestData", ")", "{", "Class", "<", "?", ">", "valueClass", "=", "pAtt", ".", "getValueClass", "(", ")", ";", "Object", "value", ";", "try", "{", "value", "=", "parseValue", "(", "false", ",", "new", "String", "[", "0", "]", ",", "valueClass", ",", "fieldName", ",", "requestData", ")", ";", "}", "catch", "(", "UnsupportedTypeException", "e", ")", "{", "String", "type", "=", "e", ".", "type", ".", "getName", "(", ")", ";", "if", "(", "e", ".", "type", ".", "isArray", "(", ")", ")", "{", "type", "=", "e", ".", "type", ".", "getComponentType", "(", ")", ".", "getName", "(", ")", "+", "\"[]\"", ";", "}", "throw", "new", "RuntimeException", "(", "\"The type '\"", "+", "type", "+", "\"' is not a supported type when parsing json. \"", "+", "\"See documentation for supported types.\\n\\nUnsupported type found in attribute \"", "+", "fieldName", "+", "\"\\n\\nTo support more types add the type to \"", "+", "\"parseValue and parseArrayValue in this class and add a test to the test class\"", ",", "e", ")", ";", "}", "pAtt", ".", "validateValue", "(", "value", ")", ";", "return", "value", ";", "}" ]
Get the value of a primitive type from the request data. @param fieldName the name of the attribute to get from the request data. @param pAtt the primitive attribute. @param requestData the data to retrieve the value from.
[ "Get", "the", "value", "of", "a", "primitive", "type", "from", "the", "request", "data", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/parser/MapfishParser.java#L333-L355
159,355
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/CustomEPSGCodes.java
CustomEPSGCodes.getDefinitionsURL
@Override protected URL getDefinitionsURL() { try { URL url = CustomEPSGCodes.class.getResource(CUSTOM_EPSG_CODES_FILE); // quickly test url try (InputStream stream = url.openStream()) { //noinspection ResultOfMethodCallIgnored stream.read(); } return url; } catch (Throwable e) { throw new AssertionError("Unable to load /epsg.properties file from root of classpath."); } }
java
@Override protected URL getDefinitionsURL() { try { URL url = CustomEPSGCodes.class.getResource(CUSTOM_EPSG_CODES_FILE); // quickly test url try (InputStream stream = url.openStream()) { //noinspection ResultOfMethodCallIgnored stream.read(); } return url; } catch (Throwable e) { throw new AssertionError("Unable to load /epsg.properties file from root of classpath."); } }
[ "@", "Override", "protected", "URL", "getDefinitionsURL", "(", ")", "{", "try", "{", "URL", "url", "=", "CustomEPSGCodes", ".", "class", ".", "getResource", "(", "CUSTOM_EPSG_CODES_FILE", ")", ";", "// quickly test url", "try", "(", "InputStream", "stream", "=", "url", ".", "openStream", "(", ")", ")", "{", "//noinspection ResultOfMethodCallIgnored", "stream", ".", "read", "(", ")", ";", "}", "return", "url", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "AssertionError", "(", "\"Unable to load /epsg.properties file from root of classpath.\"", ")", ";", "}", "}" ]
Returns the URL to the property file that contains CRS definitions. @return The URL to the epsg file containing custom EPSG codes
[ "Returns", "the", "URL", "to", "the", "property", "file", "that", "contains", "CRS", "definitions", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/CustomEPSGCodes.java#L40-L53
159,356
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ExecutionStats.java
ExecutionStats.addMapStats
public synchronized void addMapStats( final MapfishMapContext mapContext, final MapAttribute.MapAttributeValues mapValues) { this.mapStats.add(new MapStats(mapContext, mapValues)); }
java
public synchronized void addMapStats( final MapfishMapContext mapContext, final MapAttribute.MapAttributeValues mapValues) { this.mapStats.add(new MapStats(mapContext, mapValues)); }
[ "public", "synchronized", "void", "addMapStats", "(", "final", "MapfishMapContext", "mapContext", ",", "final", "MapAttribute", ".", "MapAttributeValues", "mapValues", ")", "{", "this", ".", "mapStats", ".", "add", "(", "new", "MapStats", "(", "mapContext", ",", "mapValues", ")", ")", ";", "}" ]
Add statistics about a created map. @param mapContext the @param mapValues the
[ "Add", "statistics", "about", "a", "created", "map", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ExecutionStats.java#L30-L33
159,357
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ExecutionStats.java
ExecutionStats.addEmailStats
public void addEmailStats(final InternetAddress[] recipients, final boolean storageUsed) { this.storageUsed = storageUsed; for (InternetAddress recipient: recipients) { emailDests.add(recipient.getAddress()); } }
java
public void addEmailStats(final InternetAddress[] recipients, final boolean storageUsed) { this.storageUsed = storageUsed; for (InternetAddress recipient: recipients) { emailDests.add(recipient.getAddress()); } }
[ "public", "void", "addEmailStats", "(", "final", "InternetAddress", "[", "]", "recipients", ",", "final", "boolean", "storageUsed", ")", "{", "this", ".", "storageUsed", "=", "storageUsed", ";", "for", "(", "InternetAddress", "recipient", ":", "recipients", ")", "{", "emailDests", ".", "add", "(", "recipient", ".", "getAddress", "(", ")", ")", ";", "}", "}" ]
Add statistics about sent emails. @param recipients The list of recipients. @param storageUsed If a remote storage was used.
[ "Add", "statistics", "about", "sent", "emails", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ExecutionStats.java#L50-L55
159,358
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridParam.java
GridParam.calculateLabelUnit
public String calculateLabelUnit(final CoordinateReferenceSystem mapCrs) { String unit; if (this.labelProjection != null) { unit = this.labelCRS.getCoordinateSystem().getAxis(0).getUnit().toString(); } else { unit = mapCrs.getCoordinateSystem().getAxis(0).getUnit().toString(); } return unit; }
java
public String calculateLabelUnit(final CoordinateReferenceSystem mapCrs) { String unit; if (this.labelProjection != null) { unit = this.labelCRS.getCoordinateSystem().getAxis(0).getUnit().toString(); } else { unit = mapCrs.getCoordinateSystem().getAxis(0).getUnit().toString(); } return unit; }
[ "public", "String", "calculateLabelUnit", "(", "final", "CoordinateReferenceSystem", "mapCrs", ")", "{", "String", "unit", ";", "if", "(", "this", ".", "labelProjection", "!=", "null", ")", "{", "unit", "=", "this", ".", "labelCRS", ".", "getCoordinateSystem", "(", ")", ".", "getAxis", "(", "0", ")", ".", "getUnit", "(", ")", ".", "toString", "(", ")", ";", "}", "else", "{", "unit", "=", "mapCrs", ".", "getCoordinateSystem", "(", ")", ".", "getAxis", "(", "0", ")", ".", "getUnit", "(", ")", ".", "toString", "(", ")", ";", "}", "return", "unit", ";", "}" ]
Determine which unit to use when creating grid labels. @param mapCrs the crs of the map, used if the {@link #labelProjection} is not defined.
[ "Determine", "which", "unit", "to", "use", "when", "creating", "grid", "labels", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridParam.java#L244-L253
159,359
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridParam.java
GridParam.calculateLabelTransform
public MathTransform calculateLabelTransform(final CoordinateReferenceSystem mapCrs) { MathTransform labelTransform; if (this.labelProjection != null) { try { labelTransform = CRS.findMathTransform(mapCrs, this.labelCRS, true); } catch (FactoryException e) { throw new RuntimeException(e); } } else { labelTransform = IdentityTransform.create(2); } return labelTransform; }
java
public MathTransform calculateLabelTransform(final CoordinateReferenceSystem mapCrs) { MathTransform labelTransform; if (this.labelProjection != null) { try { labelTransform = CRS.findMathTransform(mapCrs, this.labelCRS, true); } catch (FactoryException e) { throw new RuntimeException(e); } } else { labelTransform = IdentityTransform.create(2); } return labelTransform; }
[ "public", "MathTransform", "calculateLabelTransform", "(", "final", "CoordinateReferenceSystem", "mapCrs", ")", "{", "MathTransform", "labelTransform", ";", "if", "(", "this", ".", "labelProjection", "!=", "null", ")", "{", "try", "{", "labelTransform", "=", "CRS", ".", "findMathTransform", "(", "mapCrs", ",", "this", ".", "labelCRS", ",", "true", ")", ";", "}", "catch", "(", "FactoryException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "else", "{", "labelTransform", "=", "IdentityTransform", ".", "create", "(", "2", ")", ";", "}", "return", "labelTransform", ";", "}" ]
Determine which math transform to use when creating the coordinate of the label. @param mapCrs the crs of the map, used if the {@link #labelProjection} is not defined.
[ "Determine", "which", "math", "transform", "to", "use", "when", "creating", "the", "coordinate", "of", "the", "label", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridParam.java#L260-L273
159,360
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/GridLabelFormat.java
GridLabelFormat.fromConfig
public static GridLabelFormat fromConfig(final GridParam param) { if (param.labelFormat != null) { return new GridLabelFormat.Simple(param.labelFormat); } else if (param.valueFormat != null) { return new GridLabelFormat.Detailed( param.valueFormat, param.unitFormat, param.formatDecimalSeparator, param.formatGroupingSeparator); } return null; }
java
public static GridLabelFormat fromConfig(final GridParam param) { if (param.labelFormat != null) { return new GridLabelFormat.Simple(param.labelFormat); } else if (param.valueFormat != null) { return new GridLabelFormat.Detailed( param.valueFormat, param.unitFormat, param.formatDecimalSeparator, param.formatGroupingSeparator); } return null; }
[ "public", "static", "GridLabelFormat", "fromConfig", "(", "final", "GridParam", "param", ")", "{", "if", "(", "param", ".", "labelFormat", "!=", "null", ")", "{", "return", "new", "GridLabelFormat", ".", "Simple", "(", "param", ".", "labelFormat", ")", ";", "}", "else", "if", "(", "param", ".", "valueFormat", "!=", "null", ")", "{", "return", "new", "GridLabelFormat", ".", "Detailed", "(", "param", ".", "valueFormat", ",", "param", ".", "unitFormat", ",", "param", ".", "formatDecimalSeparator", ",", "param", ".", "formatGroupingSeparator", ")", ";", "}", "return", "null", ";", "}" ]
Create an instance from the given config. @param param Grid param from the request.
[ "Create", "an", "instance", "from", "the", "given", "config", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridLabelFormat.java#L16-L25
159,361
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/http/HttpCredential.java
HttpCredential.toCredentials
@Nullable public final Credentials toCredentials(final AuthScope authscope) { try { if (!matches(MatchInfo.fromAuthScope(authscope))) { return null; } } catch (UnknownHostException | MalformedURLException | SocketException e) { throw new RuntimeException(e); } if (this.username == null) { return null; } final String passwordString; if (this.password != null) { passwordString = new String(this.password); } else { passwordString = null; } return new UsernamePasswordCredentials(this.username, passwordString); }
java
@Nullable public final Credentials toCredentials(final AuthScope authscope) { try { if (!matches(MatchInfo.fromAuthScope(authscope))) { return null; } } catch (UnknownHostException | MalformedURLException | SocketException e) { throw new RuntimeException(e); } if (this.username == null) { return null; } final String passwordString; if (this.password != null) { passwordString = new String(this.password); } else { passwordString = null; } return new UsernamePasswordCredentials(this.username, passwordString); }
[ "@", "Nullable", "public", "final", "Credentials", "toCredentials", "(", "final", "AuthScope", "authscope", ")", "{", "try", "{", "if", "(", "!", "matches", "(", "MatchInfo", ".", "fromAuthScope", "(", "authscope", ")", ")", ")", "{", "return", "null", ";", "}", "}", "catch", "(", "UnknownHostException", "|", "MalformedURLException", "|", "SocketException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "if", "(", "this", ".", "username", "==", "null", ")", "{", "return", "null", ";", "}", "final", "String", "passwordString", ";", "if", "(", "this", ".", "password", "!=", "null", ")", "{", "passwordString", "=", "new", "String", "(", "this", ".", "password", ")", ";", "}", "else", "{", "passwordString", "=", "null", ";", "}", "return", "new", "UsernamePasswordCredentials", "(", "this", ".", "username", ",", "passwordString", ")", ";", "}" ]
Check if this applies to the provided authorization scope and return the credentials for that scope or null if it doesn't apply to the scope. @param authscope the scope to test against.
[ "Check", "if", "this", "applies", "to", "the", "provided", "authorization", "scope", "and", "return", "the", "credentials", "for", "that", "scope", "or", "null", "if", "it", "doesn", "t", "apply", "to", "the", "scope", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/http/HttpCredential.java#L104-L125
159,362
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getJSONObject
public final PJsonObject getJSONObject(final int i) { JSONObject val = this.array.optJSONObject(i); final String context = "[" + i + "]"; if (val == null) { throw new ObjectMissingException(this, context); } return new PJsonObject(this, val, context); }
java
public final PJsonObject getJSONObject(final int i) { JSONObject val = this.array.optJSONObject(i); final String context = "[" + i + "]"; if (val == null) { throw new ObjectMissingException(this, context); } return new PJsonObject(this, val, context); }
[ "public", "final", "PJsonObject", "getJSONObject", "(", "final", "int", "i", ")", "{", "JSONObject", "val", "=", "this", ".", "array", ".", "optJSONObject", "(", "i", ")", ";", "final", "String", "context", "=", "\"[\"", "+", "i", "+", "\"]\"", ";", "if", "(", "val", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "context", ")", ";", "}", "return", "new", "PJsonObject", "(", "this", ",", "val", ",", "context", ")", ";", "}" ]
Get the element at the index as a json object. @param i the index of the object to access
[ "Get", "the", "element", "at", "the", "index", "as", "a", "json", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L52-L59
159,363
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getJSONArray
public final PJsonArray getJSONArray(final int i) { JSONArray val = this.array.optJSONArray(i); final String context = "[" + i + "]"; if (val == null) { throw new ObjectMissingException(this, context); } return new PJsonArray(this, val, context); }
java
public final PJsonArray getJSONArray(final int i) { JSONArray val = this.array.optJSONArray(i); final String context = "[" + i + "]"; if (val == null) { throw new ObjectMissingException(this, context); } return new PJsonArray(this, val, context); }
[ "public", "final", "PJsonArray", "getJSONArray", "(", "final", "int", "i", ")", "{", "JSONArray", "val", "=", "this", ".", "array", ".", "optJSONArray", "(", "i", ")", ";", "final", "String", "context", "=", "\"[\"", "+", "i", "+", "\"]\"", ";", "if", "(", "val", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "context", ")", ";", "}", "return", "new", "PJsonArray", "(", "this", ",", "val", ",", "context", ")", ";", "}" ]
Get the element at the index as a json array. @param i the index of the element to access
[ "Get", "the", "element", "at", "the", "index", "as", "a", "json", "array", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L76-L83
159,364
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getInt
@Override public final int getInt(final int i) { int val = this.array.optInt(i, Integer.MIN_VALUE); if (val == Integer.MIN_VALUE) { throw new ObjectMissingException(this, "[" + i + "]"); } return val; }
java
@Override public final int getInt(final int i) { int val = this.array.optInt(i, Integer.MIN_VALUE); if (val == Integer.MIN_VALUE) { throw new ObjectMissingException(this, "[" + i + "]"); } return val; }
[ "@", "Override", "public", "final", "int", "getInt", "(", "final", "int", "i", ")", "{", "int", "val", "=", "this", ".", "array", ".", "optInt", "(", "i", ",", "Integer", ".", "MIN_VALUE", ")", ";", "if", "(", "val", "==", "Integer", ".", "MIN_VALUE", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "\"[\"", "+", "i", "+", "\"]\"", ")", ";", "}", "return", "val", ";", "}" ]
Get the element at the index as an integer. @param i the index of the element to access
[ "Get", "the", "element", "at", "the", "index", "as", "an", "integer", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L90-L97
159,365
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getFloat
@Override public final float getFloat(final int i) { double val = this.array.optDouble(i, Double.MAX_VALUE); if (val == Double.MAX_VALUE) { throw new ObjectMissingException(this, "[" + i + "]"); } return (float) val; }
java
@Override public final float getFloat(final int i) { double val = this.array.optDouble(i, Double.MAX_VALUE); if (val == Double.MAX_VALUE) { throw new ObjectMissingException(this, "[" + i + "]"); } return (float) val; }
[ "@", "Override", "public", "final", "float", "getFloat", "(", "final", "int", "i", ")", "{", "double", "val", "=", "this", ".", "array", ".", "optDouble", "(", "i", ",", "Double", ".", "MAX_VALUE", ")", ";", "if", "(", "val", "==", "Double", ".", "MAX_VALUE", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "\"[\"", "+", "i", "+", "\"]\"", ")", ";", "}", "return", "(", "float", ")", "val", ";", "}" ]
Get the element at the index as a float. @param i the index of the element to access
[ "Get", "the", "element", "at", "the", "index", "as", "a", "float", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L113-L120
159,366
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getString
@Override public final String getString(final int i) { String val = this.array.optString(i, null); if (val == null) { throw new ObjectMissingException(this, "[" + i + "]"); } return val; }
java
@Override public final String getString(final int i) { String val = this.array.optString(i, null); if (val == null) { throw new ObjectMissingException(this, "[" + i + "]"); } return val; }
[ "@", "Override", "public", "final", "String", "getString", "(", "final", "int", "i", ")", "{", "String", "val", "=", "this", ".", "array", ".", "optString", "(", "i", ",", "null", ")", ";", "if", "(", "val", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "\"[\"", "+", "i", "+", "\"]\"", ")", ";", "}", "return", "val", ";", "}" ]
Get the element at the index as a string. @param i the index of the element to access
[ "Get", "the", "element", "at", "the", "index", "as", "a", "string", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L141-L148
159,367
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java
PJsonArray.getBool
@Override public final boolean getBool(final int i) { try { return this.array.getBoolean(i); } catch (JSONException e) { throw new ObjectMissingException(this, "[" + i + "]"); } }
java
@Override public final boolean getBool(final int i) { try { return this.array.getBoolean(i); } catch (JSONException e) { throw new ObjectMissingException(this, "[" + i + "]"); } }
[ "@", "Override", "public", "final", "boolean", "getBool", "(", "final", "int", "i", ")", "{", "try", "{", "return", "this", ".", "array", ".", "getBoolean", "(", "i", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "\"[\"", "+", "i", "+", "\"]\"", ")", ";", "}", "}" ]
Get the element as a boolean. @param i the index of the element to access
[ "Get", "the", "element", "as", "a", "boolean", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonArray.java#L162-L169
159,368
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getString
@Override public final String getString(final String key) { String result = optString(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final String getString(final String key) { String result = optString(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "String", "getString", "(", "final", "String", "key", ")", "{", "String", "result", "=", "optString", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "key", ")", ";", "}", "return", "result", ";", "}" ]
Get a property as a string or throw an exception. @param key the property name
[ "Get", "a", "property", "as", "a", "string", "or", "throw", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L24-L31
159,369
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optString
@Override public final String optString(final String key, final String defaultValue) { String result = optString(key); return result == null ? defaultValue : result; }
java
@Override public final String optString(final String key, final String defaultValue) { String result = optString(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "String", "optString", "(", "final", "String", "key", ",", "final", "String", "defaultValue", ")", "{", "String", "result", "=", "optString", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", ":", "result", ";", "}" ]
Get a property as a string or defaultValue. @param key the property name @param defaultValue the default value
[ "Get", "a", "property", "as", "a", "string", "or", "defaultValue", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L39-L43
159,370
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getInt
@Override public final int getInt(final String key) { Integer result = optInt(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final int getInt(final String key) { Integer result = optInt(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "int", "getInt", "(", "final", "String", "key", ")", "{", "Integer", "result", "=", "optInt", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "key", ")", ";", "}", "return", "result", ";", "}" ]
Get a property as an int or throw an exception. @param key the property name
[ "Get", "a", "property", "as", "an", "int", "or", "throw", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L50-L57
159,371
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optInt
@Override public final Integer optInt(final String key, final Integer defaultValue) { Integer result = optInt(key); return result == null ? defaultValue : result; }
java
@Override public final Integer optInt(final String key, final Integer defaultValue) { Integer result = optInt(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "Integer", "optInt", "(", "final", "String", "key", ",", "final", "Integer", "defaultValue", ")", "{", "Integer", "result", "=", "optInt", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", ":", "result", ";", "}" ]
Get a property as an int or default value. @param key the property name @param defaultValue the default value
[ "Get", "a", "property", "as", "an", "int", "or", "default", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L65-L69
159,372
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getLong
@Override public final long getLong(final String key) { Long result = optLong(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final long getLong(final String key) { Long result = optLong(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "long", "getLong", "(", "final", "String", "key", ")", "{", "Long", "result", "=", "optLong", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "key", ")", ";", "}", "return", "result", ";", "}" ]
Get a property as an long or throw an exception. @param key the property name
[ "Get", "a", "property", "as", "an", "long", "or", "throw", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L76-L83
159,373
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optLong
@Override public final long optLong(final String key, final long defaultValue) { Long result = optLong(key); return result == null ? defaultValue : result; }
java
@Override public final long optLong(final String key, final long defaultValue) { Long result = optLong(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "long", "optLong", "(", "final", "String", "key", ",", "final", "long", "defaultValue", ")", "{", "Long", "result", "=", "optLong", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", ":", "result", ";", "}" ]
Get a property as an long or default value. @param key the property name @param defaultValue the default value
[ "Get", "a", "property", "as", "an", "long", "or", "default", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L91-L95
159,374
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getDouble
@Override public final double getDouble(final String key) { Double result = optDouble(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final double getDouble(final String key) { Double result = optDouble(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "double", "getDouble", "(", "final", "String", "key", ")", "{", "Double", "result", "=", "optDouble", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "key", ")", ";", "}", "return", "result", ";", "}" ]
Get a property as a double or throw an exception. @param key the property name
[ "Get", "a", "property", "as", "a", "double", "or", "throw", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L102-L109
159,375
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optDouble
@Override public final Double optDouble(final String key, final Double defaultValue) { Double result = optDouble(key); return result == null ? defaultValue : result; }
java
@Override public final Double optDouble(final String key, final Double defaultValue) { Double result = optDouble(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "Double", "optDouble", "(", "final", "String", "key", ",", "final", "Double", "defaultValue", ")", "{", "Double", "result", "=", "optDouble", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", ":", "result", ";", "}" ]
Get a property as a double or defaultValue. @param key the property name @param defaultValue the default value
[ "Get", "a", "property", "as", "a", "double", "or", "defaultValue", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L117-L121
159,376
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getFloat
@Override public final float getFloat(final String key) { Float result = optFloat(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final float getFloat(final String key) { Float result = optFloat(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "float", "getFloat", "(", "final", "String", "key", ")", "{", "Float", "result", "=", "optFloat", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "key", ")", ";", "}", "return", "result", ";", "}" ]
Get a property as a float or throw an exception. @param key the property name
[ "Get", "a", "property", "as", "a", "float", "or", "throw", "an", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L128-L135
159,377
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optFloat
@Override public final Float optFloat(final String key, final Float defaultValue) { Float result = optFloat(key); return result == null ? defaultValue : result; }
java
@Override public final Float optFloat(final String key, final Float defaultValue) { Float result = optFloat(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "Float", "optFloat", "(", "final", "String", "key", ",", "final", "Float", "defaultValue", ")", "{", "Float", "result", "=", "optFloat", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", ":", "result", ";", "}" ]
Get a property as a float or Default value. @param key the property name @param defaultValue default value
[ "Get", "a", "property", "as", "a", "float", "or", "Default", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L143-L147
159,378
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getBool
@Override public final boolean getBool(final String key) { Boolean result = optBool(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final boolean getBool(final String key) { Boolean result = optBool(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "boolean", "getBool", "(", "final", "String", "key", ")", "{", "Boolean", "result", "=", "optBool", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "key", ")", ";", "}", "return", "result", ";", "}" ]
Get a property as a boolean or throw exception. @param key the property name
[ "Get", "a", "property", "as", "a", "boolean", "or", "throw", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L154-L161
159,379
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.optBool
@Override public final Boolean optBool(final String key, final Boolean defaultValue) { Boolean result = optBool(key); return result == null ? defaultValue : result; }
java
@Override public final Boolean optBool(final String key, final Boolean defaultValue) { Boolean result = optBool(key); return result == null ? defaultValue : result; }
[ "@", "Override", "public", "final", "Boolean", "optBool", "(", "final", "String", "key", ",", "final", "Boolean", "defaultValue", ")", "{", "Boolean", "result", "=", "optBool", "(", "key", ")", ";", "return", "result", "==", "null", "?", "defaultValue", ":", "result", ";", "}" ]
Get a property as a boolean or default value. @param key the property name @param defaultValue the default
[ "Get", "a", "property", "as", "a", "boolean", "or", "default", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L169-L173
159,380
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getObject
@Override public final PObject getObject(final String key) { PObject result = optObject(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final PObject getObject(final String key) { PObject result = optObject(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "PObject", "getObject", "(", "final", "String", "key", ")", "{", "PObject", "result", "=", "optObject", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "key", ")", ";", "}", "return", "result", ";", "}" ]
Get a property as a object or throw exception. @param key the property name
[ "Get", "a", "property", "as", "a", "object", "or", "throw", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L180-L187
159,381
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java
PAbstractObject.getArray
@Override public final PArray getArray(final String key) { PArray result = optArray(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
java
@Override public final PArray getArray(final String key) { PArray result = optArray(key); if (result == null) { throw new ObjectMissingException(this, key); } return result; }
[ "@", "Override", "public", "final", "PArray", "getArray", "(", "final", "String", "key", ")", "{", "PArray", "result", "=", "optArray", "(", "key", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "ObjectMissingException", "(", "this", ",", "key", ")", ";", "}", "return", "result", ";", "}" ]
Get a property as a array or throw exception. @param key the property name
[ "Get", "a", "property", "as", "a", "array", "or", "throw", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PAbstractObject.java#L206-L213
159,382
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/access/AccessAssertionPersister.java
AccessAssertionPersister.unmarshal
public AccessAssertion unmarshal(final JSONObject encodedAssertion) { final String className; try { className = encodedAssertion.getString(JSON_CLASS_NAME); final Class<?> assertionClass = Thread.currentThread().getContextClassLoader().loadClass(className); final AccessAssertion assertion = (AccessAssertion) this.applicationContext.getBean(assertionClass); assertion.unmarshal(encodedAssertion); return assertion; } catch (JSONException | ClassNotFoundException e) { throw new RuntimeException(e); } }
java
public AccessAssertion unmarshal(final JSONObject encodedAssertion) { final String className; try { className = encodedAssertion.getString(JSON_CLASS_NAME); final Class<?> assertionClass = Thread.currentThread().getContextClassLoader().loadClass(className); final AccessAssertion assertion = (AccessAssertion) this.applicationContext.getBean(assertionClass); assertion.unmarshal(encodedAssertion); return assertion; } catch (JSONException | ClassNotFoundException e) { throw new RuntimeException(e); } }
[ "public", "AccessAssertion", "unmarshal", "(", "final", "JSONObject", "encodedAssertion", ")", "{", "final", "String", "className", ";", "try", "{", "className", "=", "encodedAssertion", ".", "getString", "(", "JSON_CLASS_NAME", ")", ";", "final", "Class", "<", "?", ">", "assertionClass", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "loadClass", "(", "className", ")", ";", "final", "AccessAssertion", "assertion", "=", "(", "AccessAssertion", ")", "this", ".", "applicationContext", ".", "getBean", "(", "assertionClass", ")", ";", "assertion", ".", "unmarshal", "(", "encodedAssertion", ")", ";", "return", "assertion", ";", "}", "catch", "(", "JSONException", "|", "ClassNotFoundException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Load assertion from the provided json or throw exception if not possible. @param encodedAssertion the assertion as it was encoded in JSON.
[ "Load", "assertion", "from", "the", "provided", "json", "or", "throw", "exception", "if", "not", "possible", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/access/AccessAssertionPersister.java#L21-L35
159,383
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/access/AccessAssertionPersister.java
AccessAssertionPersister.marshal
public JSONObject marshal(final AccessAssertion assertion) { final JSONObject jsonObject = assertion.marshal(); if (jsonObject.has(JSON_CLASS_NAME)) { throw new AssertionError("The toJson method in AccessAssertion: '" + assertion.getClass() + "' defined a JSON field " + JSON_CLASS_NAME + " which is a reserved keyword and is not permitted to be used " + "in toJSON method"); } try { jsonObject.put(JSON_CLASS_NAME, assertion.getClass().getName()); } catch (JSONException e) { throw new RuntimeException(e); } return jsonObject; }
java
public JSONObject marshal(final AccessAssertion assertion) { final JSONObject jsonObject = assertion.marshal(); if (jsonObject.has(JSON_CLASS_NAME)) { throw new AssertionError("The toJson method in AccessAssertion: '" + assertion.getClass() + "' defined a JSON field " + JSON_CLASS_NAME + " which is a reserved keyword and is not permitted to be used " + "in toJSON method"); } try { jsonObject.put(JSON_CLASS_NAME, assertion.getClass().getName()); } catch (JSONException e) { throw new RuntimeException(e); } return jsonObject; }
[ "public", "JSONObject", "marshal", "(", "final", "AccessAssertion", "assertion", ")", "{", "final", "JSONObject", "jsonObject", "=", "assertion", ".", "marshal", "(", ")", ";", "if", "(", "jsonObject", ".", "has", "(", "JSON_CLASS_NAME", ")", ")", "{", "throw", "new", "AssertionError", "(", "\"The toJson method in AccessAssertion: '\"", "+", "assertion", ".", "getClass", "(", ")", "+", "\"' defined a JSON field \"", "+", "JSON_CLASS_NAME", "+", "\" which is a reserved keyword and is not permitted to be used \"", "+", "\"in toJSON method\"", ")", ";", "}", "try", "{", "jsonObject", ".", "put", "(", "JSON_CLASS_NAME", ",", "assertion", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "jsonObject", ";", "}" ]
Marshal the assertion as a JSON object. @param assertion the assertion to marshal
[ "Marshal", "the", "assertion", "as", "a", "JSON", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/access/AccessAssertionPersister.java#L42-L57
159,384
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/http/AddHeadersProcessor.java
AddHeadersProcessor.createFactoryWrapper
public static MfClientHttpRequestFactory createFactoryWrapper( final MfClientHttpRequestFactory requestFactory, final UriMatchers matchers, final Map<String, List<String>> headers) { return new AbstractMfClientHttpRequestFactoryWrapper(requestFactory, matchers, false) { @Override protected ClientHttpRequest createRequest( final URI uri, final HttpMethod httpMethod, final MfClientHttpRequestFactory requestFactory) throws IOException { final ClientHttpRequest request = requestFactory.createRequest(uri, httpMethod); request.getHeaders().putAll(headers); return request; } }; }
java
public static MfClientHttpRequestFactory createFactoryWrapper( final MfClientHttpRequestFactory requestFactory, final UriMatchers matchers, final Map<String, List<String>> headers) { return new AbstractMfClientHttpRequestFactoryWrapper(requestFactory, matchers, false) { @Override protected ClientHttpRequest createRequest( final URI uri, final HttpMethod httpMethod, final MfClientHttpRequestFactory requestFactory) throws IOException { final ClientHttpRequest request = requestFactory.createRequest(uri, httpMethod); request.getHeaders().putAll(headers); return request; } }; }
[ "public", "static", "MfClientHttpRequestFactory", "createFactoryWrapper", "(", "final", "MfClientHttpRequestFactory", "requestFactory", ",", "final", "UriMatchers", "matchers", ",", "final", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "headers", ")", "{", "return", "new", "AbstractMfClientHttpRequestFactoryWrapper", "(", "requestFactory", ",", "matchers", ",", "false", ")", "{", "@", "Override", "protected", "ClientHttpRequest", "createRequest", "(", "final", "URI", "uri", ",", "final", "HttpMethod", "httpMethod", ",", "final", "MfClientHttpRequestFactory", "requestFactory", ")", "throws", "IOException", "{", "final", "ClientHttpRequest", "request", "=", "requestFactory", ".", "createRequest", "(", "uri", ",", "httpMethod", ")", ";", "request", ".", "getHeaders", "(", ")", ".", "putAll", "(", "headers", ")", ";", "return", "request", ";", "}", "}", ";", "}" ]
Create a MfClientHttpRequestFactory for adding the specified headers. @param requestFactory the basic request factory. It should be unmodified and just wrapped with a proxy class. @param matchers The matchers. @param headers The headers. @return
[ "Create", "a", "MfClientHttpRequestFactory", "for", "adding", "the", "specified", "headers", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/AddHeadersProcessor.java#L44-L58
159,385
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/http/AddHeadersProcessor.java
AddHeadersProcessor.setHeaders
@SuppressWarnings("unchecked") public void setHeaders(final Map<String, Object> headers) { this.headers.clear(); for (Map.Entry<String, Object> entry: headers.entrySet()) { if (entry.getValue() instanceof List) { List value = (List) entry.getValue(); // verify they are all strings for (Object o: value) { Assert.isTrue(o instanceof String, o + " is not a string it is a: '" + o.getClass() + "'"); } this.headers.put(entry.getKey(), (List<String>) entry.getValue()); } else if (entry.getValue() instanceof String) { final List<String> value = Collections.singletonList((String) entry.getValue()); this.headers.put(entry.getKey(), value); } else { throw new IllegalArgumentException("Only strings and list of strings may be headers"); } } }
java
@SuppressWarnings("unchecked") public void setHeaders(final Map<String, Object> headers) { this.headers.clear(); for (Map.Entry<String, Object> entry: headers.entrySet()) { if (entry.getValue() instanceof List) { List value = (List) entry.getValue(); // verify they are all strings for (Object o: value) { Assert.isTrue(o instanceof String, o + " is not a string it is a: '" + o.getClass() + "'"); } this.headers.put(entry.getKey(), (List<String>) entry.getValue()); } else if (entry.getValue() instanceof String) { final List<String> value = Collections.singletonList((String) entry.getValue()); this.headers.put(entry.getKey(), value); } else { throw new IllegalArgumentException("Only strings and list of strings may be headers"); } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "setHeaders", "(", "final", "Map", "<", "String", ",", "Object", ">", "headers", ")", "{", "this", ".", "headers", ".", "clear", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Object", ">", "entry", ":", "headers", ".", "entrySet", "(", ")", ")", "{", "if", "(", "entry", ".", "getValue", "(", ")", "instanceof", "List", ")", "{", "List", "value", "=", "(", "List", ")", "entry", ".", "getValue", "(", ")", ";", "// verify they are all strings", "for", "(", "Object", "o", ":", "value", ")", "{", "Assert", ".", "isTrue", "(", "o", "instanceof", "String", ",", "o", "+", "\" is not a string it is a: '\"", "+", "o", ".", "getClass", "(", ")", "+", "\"'\"", ")", ";", "}", "this", ".", "headers", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "(", "List", "<", "String", ">", ")", "entry", ".", "getValue", "(", ")", ")", ";", "}", "else", "if", "(", "entry", ".", "getValue", "(", ")", "instanceof", "String", ")", "{", "final", "List", "<", "String", ">", "value", "=", "Collections", ".", "singletonList", "(", "(", "String", ")", "entry", ".", "getValue", "(", ")", ")", ";", "this", ".", "headers", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "value", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Only strings and list of strings may be headers\"", ")", ";", "}", "}", "}" ]
A map of the header key value pairs. Keys are strings and values are either list of strings or a string. @param headers the header map
[ "A", "map", "of", "the", "header", "key", "value", "pairs", ".", "Keys", "are", "strings", "and", "values", "are", "either", "list", "of", "strings", "or", "a", "string", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/AddHeadersProcessor.java#L66-L85
159,386
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java
ProcessorUtils.writeProcessorOutputToValues
public static void writeProcessorOutputToValues( final Object output, final Processor<?, ?> processor, final Values values) { Map<String, String> mapper = processor.getOutputMapperBiMap(); if (mapper == null) { mapper = Collections.emptyMap(); } final Collection<Field> fields = getAllAttributes(output.getClass()); for (Field field: fields) { String name = getOutputValueName(processor.getOutputPrefix(), mapper, field); try { final Object value = field.get(output); if (value != null) { values.put(name, value); } else { values.remove(name); } } catch (IllegalAccessException e) { throw ExceptionUtils.getRuntimeException(e); } } }
java
public static void writeProcessorOutputToValues( final Object output, final Processor<?, ?> processor, final Values values) { Map<String, String> mapper = processor.getOutputMapperBiMap(); if (mapper == null) { mapper = Collections.emptyMap(); } final Collection<Field> fields = getAllAttributes(output.getClass()); for (Field field: fields) { String name = getOutputValueName(processor.getOutputPrefix(), mapper, field); try { final Object value = field.get(output); if (value != null) { values.put(name, value); } else { values.remove(name); } } catch (IllegalAccessException e) { throw ExceptionUtils.getRuntimeException(e); } } }
[ "public", "static", "void", "writeProcessorOutputToValues", "(", "final", "Object", "output", ",", "final", "Processor", "<", "?", ",", "?", ">", "processor", ",", "final", "Values", "values", ")", "{", "Map", "<", "String", ",", "String", ">", "mapper", "=", "processor", ".", "getOutputMapperBiMap", "(", ")", ";", "if", "(", "mapper", "==", "null", ")", "{", "mapper", "=", "Collections", ".", "emptyMap", "(", ")", ";", "}", "final", "Collection", "<", "Field", ">", "fields", "=", "getAllAttributes", "(", "output", ".", "getClass", "(", ")", ")", ";", "for", "(", "Field", "field", ":", "fields", ")", "{", "String", "name", "=", "getOutputValueName", "(", "processor", ".", "getOutputPrefix", "(", ")", ",", "mapper", ",", "field", ")", ";", "try", "{", "final", "Object", "value", "=", "field", ".", "get", "(", "output", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "values", ".", "put", "(", "name", ",", "value", ")", ";", "}", "else", "{", "values", ".", "remove", "(", "name", ")", ";", "}", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "ExceptionUtils", ".", "getRuntimeException", "(", "e", ")", ";", "}", "}", "}" ]
Read the values from the output object and write them to the values object. @param output the output object from a processor @param processor the processor the output if from @param values the object for sharing values between processors
[ "Read", "the", "values", "from", "the", "output", "object", "and", "write", "them", "to", "the", "values", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java#L78-L101
159,387
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java
ProcessorUtils.getInputValueName
public static String getInputValueName( @Nullable final String inputPrefix, @Nonnull final BiMap<String, String> inputMapper, @Nonnull final String field) { String name = inputMapper == null ? null : inputMapper.inverse().get(field); if (name == null) { if (inputMapper != null && inputMapper.containsKey(field)) { throw new RuntimeException("field in keys"); } final String[] defaultValues = { Values.TASK_DIRECTORY_KEY, Values.CLIENT_HTTP_REQUEST_FACTORY_KEY, Values.TEMPLATE_KEY, Values.PDF_CONFIG_KEY, Values.SUBREPORT_DIR_KEY, Values.OUTPUT_FORMAT_KEY, Values.JOB_ID_KEY }; if (inputPrefix == null || Arrays.asList(defaultValues).contains(field)) { name = field; } else { name = inputPrefix.trim() + Character.toUpperCase(field.charAt(0)) + field.substring(1); } } return name; }
java
public static String getInputValueName( @Nullable final String inputPrefix, @Nonnull final BiMap<String, String> inputMapper, @Nonnull final String field) { String name = inputMapper == null ? null : inputMapper.inverse().get(field); if (name == null) { if (inputMapper != null && inputMapper.containsKey(field)) { throw new RuntimeException("field in keys"); } final String[] defaultValues = { Values.TASK_DIRECTORY_KEY, Values.CLIENT_HTTP_REQUEST_FACTORY_KEY, Values.TEMPLATE_KEY, Values.PDF_CONFIG_KEY, Values.SUBREPORT_DIR_KEY, Values.OUTPUT_FORMAT_KEY, Values.JOB_ID_KEY }; if (inputPrefix == null || Arrays.asList(defaultValues).contains(field)) { name = field; } else { name = inputPrefix.trim() + Character.toUpperCase(field.charAt(0)) + field.substring(1); } } return name; }
[ "public", "static", "String", "getInputValueName", "(", "@", "Nullable", "final", "String", "inputPrefix", ",", "@", "Nonnull", "final", "BiMap", "<", "String", ",", "String", ">", "inputMapper", ",", "@", "Nonnull", "final", "String", "field", ")", "{", "String", "name", "=", "inputMapper", "==", "null", "?", "null", ":", "inputMapper", ".", "inverse", "(", ")", ".", "get", "(", "field", ")", ";", "if", "(", "name", "==", "null", ")", "{", "if", "(", "inputMapper", "!=", "null", "&&", "inputMapper", ".", "containsKey", "(", "field", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"field in keys\"", ")", ";", "}", "final", "String", "[", "]", "defaultValues", "=", "{", "Values", ".", "TASK_DIRECTORY_KEY", ",", "Values", ".", "CLIENT_HTTP_REQUEST_FACTORY_KEY", ",", "Values", ".", "TEMPLATE_KEY", ",", "Values", ".", "PDF_CONFIG_KEY", ",", "Values", ".", "SUBREPORT_DIR_KEY", ",", "Values", ".", "OUTPUT_FORMAT_KEY", ",", "Values", ".", "JOB_ID_KEY", "}", ";", "if", "(", "inputPrefix", "==", "null", "||", "Arrays", ".", "asList", "(", "defaultValues", ")", ".", "contains", "(", "field", ")", ")", "{", "name", "=", "field", ";", "}", "else", "{", "name", "=", "inputPrefix", ".", "trim", "(", ")", "+", "Character", ".", "toUpperCase", "(", "field", ".", "charAt", "(", "0", ")", ")", "+", "field", ".", "substring", "(", "1", ")", ";", "}", "}", "return", "name", ";", "}" ]
Calculate the name of the input value. @param inputPrefix a nullable prefix to prepend to the name if non-null and non-empty @param inputMapper the name mapper @param field the field containing the value
[ "Calculate", "the", "name", "of", "the", "input", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java#L110-L133
159,388
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java
ProcessorUtils.getOutputValueName
public static String getOutputValueName( @Nullable final String outputPrefix, @Nonnull final Map<String, String> outputMapper, @Nonnull final Field field) { String name = outputMapper.get(field.getName()); if (name == null) { name = field.getName(); if (!StringUtils.isEmpty(outputPrefix) && !outputPrefix.trim().isEmpty()) { name = outputPrefix.trim() + Character.toUpperCase(name.charAt(0)) + name.substring(1); } } return name; }
java
public static String getOutputValueName( @Nullable final String outputPrefix, @Nonnull final Map<String, String> outputMapper, @Nonnull final Field field) { String name = outputMapper.get(field.getName()); if (name == null) { name = field.getName(); if (!StringUtils.isEmpty(outputPrefix) && !outputPrefix.trim().isEmpty()) { name = outputPrefix.trim() + Character.toUpperCase(name.charAt(0)) + name.substring(1); } } return name; }
[ "public", "static", "String", "getOutputValueName", "(", "@", "Nullable", "final", "String", "outputPrefix", ",", "@", "Nonnull", "final", "Map", "<", "String", ",", "String", ">", "outputMapper", ",", "@", "Nonnull", "final", "Field", "field", ")", "{", "String", "name", "=", "outputMapper", ".", "get", "(", "field", ".", "getName", "(", ")", ")", ";", "if", "(", "name", "==", "null", ")", "{", "name", "=", "field", ".", "getName", "(", ")", ";", "if", "(", "!", "StringUtils", ".", "isEmpty", "(", "outputPrefix", ")", "&&", "!", "outputPrefix", ".", "trim", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "name", "=", "outputPrefix", ".", "trim", "(", ")", "+", "Character", ".", "toUpperCase", "(", "name", ".", "charAt", "(", "0", ")", ")", "+", "name", ".", "substring", "(", "1", ")", ";", "}", "}", "return", "name", ";", "}" ]
Calculate the name of the output value. @param outputPrefix a nullable prefix to prepend to the name if non-null and non-empty @param outputMapper the name mapper @param field the field containing the value
[ "Calculate", "the", "name", "of", "the", "output", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorUtils.java#L142-L155
159,389
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java
MapfishMapContext.rectangleDoubleToDimension
public static Dimension rectangleDoubleToDimension(final Rectangle2D.Double rectangle) { return new Dimension( (int) Math.round(rectangle.width), (int) Math.round(rectangle.height)); }
java
public static Dimension rectangleDoubleToDimension(final Rectangle2D.Double rectangle) { return new Dimension( (int) Math.round(rectangle.width), (int) Math.round(rectangle.height)); }
[ "public", "static", "Dimension", "rectangleDoubleToDimension", "(", "final", "Rectangle2D", ".", "Double", "rectangle", ")", "{", "return", "new", "Dimension", "(", "(", "int", ")", "Math", ".", "round", "(", "rectangle", ".", "width", ")", ",", "(", "int", ")", "Math", ".", "round", "(", "rectangle", ".", "height", ")", ")", ";", "}" ]
Round the size of a rectangle with double values. @param rectangle The rectangle. @return
[ "Round", "the", "size", "of", "a", "rectangle", "with", "double", "values", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java#L109-L113
159,390
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java
MapfishMapContext.getRotatedBounds
public MapBounds getRotatedBounds(final Rectangle2D.Double paintAreaPrecise, final Rectangle paintArea) { final MapBounds rotatedBounds = this.getRotatedBounds(); if (rotatedBounds instanceof CenterScaleMapBounds) { return rotatedBounds; } final ReferencedEnvelope envelope = ((BBoxMapBounds) rotatedBounds).toReferencedEnvelope(null); // the paint area size and the map bounds are rotated independently. because // the paint area size is rounded to integers, the map bounds have to be adjusted // to these rounding changes. final double widthRatio = paintArea.getWidth() / paintAreaPrecise.getWidth(); final double heightRatio = paintArea.getHeight() / paintAreaPrecise.getHeight(); final double adaptedWidth = envelope.getWidth() * widthRatio; final double adaptedHeight = envelope.getHeight() * heightRatio; final double widthDiff = adaptedWidth - envelope.getWidth(); final double heigthDiff = adaptedHeight - envelope.getHeight(); envelope.expandBy(widthDiff / 2.0, heigthDiff / 2.0); return new BBoxMapBounds(envelope); }
java
public MapBounds getRotatedBounds(final Rectangle2D.Double paintAreaPrecise, final Rectangle paintArea) { final MapBounds rotatedBounds = this.getRotatedBounds(); if (rotatedBounds instanceof CenterScaleMapBounds) { return rotatedBounds; } final ReferencedEnvelope envelope = ((BBoxMapBounds) rotatedBounds).toReferencedEnvelope(null); // the paint area size and the map bounds are rotated independently. because // the paint area size is rounded to integers, the map bounds have to be adjusted // to these rounding changes. final double widthRatio = paintArea.getWidth() / paintAreaPrecise.getWidth(); final double heightRatio = paintArea.getHeight() / paintAreaPrecise.getHeight(); final double adaptedWidth = envelope.getWidth() * widthRatio; final double adaptedHeight = envelope.getHeight() * heightRatio; final double widthDiff = adaptedWidth - envelope.getWidth(); final double heigthDiff = adaptedHeight - envelope.getHeight(); envelope.expandBy(widthDiff / 2.0, heigthDiff / 2.0); return new BBoxMapBounds(envelope); }
[ "public", "MapBounds", "getRotatedBounds", "(", "final", "Rectangle2D", ".", "Double", "paintAreaPrecise", ",", "final", "Rectangle", "paintArea", ")", "{", "final", "MapBounds", "rotatedBounds", "=", "this", ".", "getRotatedBounds", "(", ")", ";", "if", "(", "rotatedBounds", "instanceof", "CenterScaleMapBounds", ")", "{", "return", "rotatedBounds", ";", "}", "final", "ReferencedEnvelope", "envelope", "=", "(", "(", "BBoxMapBounds", ")", "rotatedBounds", ")", ".", "toReferencedEnvelope", "(", "null", ")", ";", "// the paint area size and the map bounds are rotated independently. because", "// the paint area size is rounded to integers, the map bounds have to be adjusted", "// to these rounding changes.", "final", "double", "widthRatio", "=", "paintArea", ".", "getWidth", "(", ")", "/", "paintAreaPrecise", ".", "getWidth", "(", ")", ";", "final", "double", "heightRatio", "=", "paintArea", ".", "getHeight", "(", ")", "/", "paintAreaPrecise", ".", "getHeight", "(", ")", ";", "final", "double", "adaptedWidth", "=", "envelope", ".", "getWidth", "(", ")", "*", "widthRatio", ";", "final", "double", "adaptedHeight", "=", "envelope", ".", "getHeight", "(", ")", "*", "heightRatio", ";", "final", "double", "widthDiff", "=", "adaptedWidth", "-", "envelope", ".", "getWidth", "(", ")", ";", "final", "double", "heigthDiff", "=", "adaptedHeight", "-", "envelope", ".", "getHeight", "(", ")", ";", "envelope", ".", "expandBy", "(", "widthDiff", "/", "2.0", ",", "heigthDiff", "/", "2.0", ")", ";", "return", "new", "BBoxMapBounds", "(", "envelope", ")", ";", "}" ]
Return the map bounds rotated with the set rotation. The bounds are adapted to rounding changes of the size of the paint area. @param paintAreaPrecise The exact size of the paint area. @param paintArea The rounded size of the paint area. @return Rotated bounds.
[ "Return", "the", "map", "bounds", "rotated", "with", "the", "set", "rotation", ".", "The", "bounds", "are", "adapted", "to", "rounding", "changes", "of", "the", "size", "of", "the", "paint", "area", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java#L150-L172
159,391
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java
MapfishMapContext.getRotatedBoundsAdjustedForPreciseRotatedMapSize
public MapBounds getRotatedBoundsAdjustedForPreciseRotatedMapSize() { Rectangle2D.Double paintAreaPrecise = getRotatedMapSizePrecise(); Rectangle paintArea = new Rectangle(MapfishMapContext.rectangleDoubleToDimension(paintAreaPrecise)); return getRotatedBounds(paintAreaPrecise, paintArea); }
java
public MapBounds getRotatedBoundsAdjustedForPreciseRotatedMapSize() { Rectangle2D.Double paintAreaPrecise = getRotatedMapSizePrecise(); Rectangle paintArea = new Rectangle(MapfishMapContext.rectangleDoubleToDimension(paintAreaPrecise)); return getRotatedBounds(paintAreaPrecise, paintArea); }
[ "public", "MapBounds", "getRotatedBoundsAdjustedForPreciseRotatedMapSize", "(", ")", "{", "Rectangle2D", ".", "Double", "paintAreaPrecise", "=", "getRotatedMapSizePrecise", "(", ")", ";", "Rectangle", "paintArea", "=", "new", "Rectangle", "(", "MapfishMapContext", ".", "rectangleDoubleToDimension", "(", "paintAreaPrecise", ")", ")", ";", "return", "getRotatedBounds", "(", "paintAreaPrecise", ",", "paintArea", ")", ";", "}" ]
Return the map bounds rotated with the set rotation. The bounds are adapted to rounding changes of the size of the set paint area. @return Rotated bounds.
[ "Return", "the", "map", "bounds", "rotated", "with", "the", "set", "rotation", ".", "The", "bounds", "are", "adapted", "to", "rounding", "changes", "of", "the", "size", "of", "the", "set", "paint", "area", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/MapfishMapContext.java#L180-L184
159,392
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/cli/Main.java
Main.runMain
@VisibleForTesting public static void runMain(final String[] args) throws Exception { final CliHelpDefinition helpCli = new CliHelpDefinition(); try { Args.parse(helpCli, args); if (helpCli.help) { printUsage(0); return; } } catch (IllegalArgumentException invalidOption) { // Ignore because it is probably one of the non-help options. } final CliDefinition cli = new CliDefinition(); try { List<String> unusedArguments = Args.parse(cli, args); if (!unusedArguments.isEmpty()) { System.out.println("\n\nThe following arguments are not recognized: " + unusedArguments); printUsage(1); return; } } catch (IllegalArgumentException invalidOption) { System.out.println("\n\n" + invalidOption.getMessage()); printUsage(1); return; } configureLogs(cli.verbose); AbstractXmlApplicationContext context = new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT); if (cli.springConfig != null) { context = new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT, cli.springConfig); } try { context.getBean(Main.class).run(cli); } finally { context.close(); } }
java
@VisibleForTesting public static void runMain(final String[] args) throws Exception { final CliHelpDefinition helpCli = new CliHelpDefinition(); try { Args.parse(helpCli, args); if (helpCli.help) { printUsage(0); return; } } catch (IllegalArgumentException invalidOption) { // Ignore because it is probably one of the non-help options. } final CliDefinition cli = new CliDefinition(); try { List<String> unusedArguments = Args.parse(cli, args); if (!unusedArguments.isEmpty()) { System.out.println("\n\nThe following arguments are not recognized: " + unusedArguments); printUsage(1); return; } } catch (IllegalArgumentException invalidOption) { System.out.println("\n\n" + invalidOption.getMessage()); printUsage(1); return; } configureLogs(cli.verbose); AbstractXmlApplicationContext context = new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT); if (cli.springConfig != null) { context = new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT, cli.springConfig); } try { context.getBean(Main.class).run(cli); } finally { context.close(); } }
[ "@", "VisibleForTesting", "public", "static", "void", "runMain", "(", "final", "String", "[", "]", "args", ")", "throws", "Exception", "{", "final", "CliHelpDefinition", "helpCli", "=", "new", "CliHelpDefinition", "(", ")", ";", "try", "{", "Args", ".", "parse", "(", "helpCli", ",", "args", ")", ";", "if", "(", "helpCli", ".", "help", ")", "{", "printUsage", "(", "0", ")", ";", "return", ";", "}", "}", "catch", "(", "IllegalArgumentException", "invalidOption", ")", "{", "// Ignore because it is probably one of the non-help options.", "}", "final", "CliDefinition", "cli", "=", "new", "CliDefinition", "(", ")", ";", "try", "{", "List", "<", "String", ">", "unusedArguments", "=", "Args", ".", "parse", "(", "cli", ",", "args", ")", ";", "if", "(", "!", "unusedArguments", ".", "isEmpty", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"\\n\\nThe following arguments are not recognized: \"", "+", "unusedArguments", ")", ";", "printUsage", "(", "1", ")", ";", "return", ";", "}", "}", "catch", "(", "IllegalArgumentException", "invalidOption", ")", "{", "System", ".", "out", ".", "println", "(", "\"\\n\\n\"", "+", "invalidOption", ".", "getMessage", "(", ")", ")", ";", "printUsage", "(", "1", ")", ";", "return", ";", "}", "configureLogs", "(", "cli", ".", "verbose", ")", ";", "AbstractXmlApplicationContext", "context", "=", "new", "ClassPathXmlApplicationContext", "(", "DEFAULT_SPRING_CONTEXT", ")", ";", "if", "(", "cli", ".", "springConfig", "!=", "null", ")", "{", "context", "=", "new", "ClassPathXmlApplicationContext", "(", "DEFAULT_SPRING_CONTEXT", ",", "cli", ".", "springConfig", ")", ";", "}", "try", "{", "context", ".", "getBean", "(", "Main", ".", "class", ")", ".", "run", "(", "cli", ")", ";", "}", "finally", "{", "context", ".", "close", "(", ")", ";", "}", "}" ]
Runs the print. @param args the cli arguments @throws Exception
[ "Runs", "the", "print", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/cli/Main.java#L75-L115
159,393
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/tiled/CoverageTask.java
CoverageTask.call
public GridCoverage2D call() { try { BufferedImage coverageImage = this.tiledLayer.createBufferedImage( this.tilePreparationInfo.getImageWidth(), this.tilePreparationInfo.getImageHeight()); Graphics2D graphics = coverageImage.createGraphics(); try { for (SingleTilePreparationInfo tileInfo: this.tilePreparationInfo.getSingleTiles()) { final TileTask task; if (tileInfo.getTileRequest() != null) { task = new SingleTileLoaderTask( tileInfo.getTileRequest(), this.errorImage, tileInfo.getTileIndexX(), tileInfo.getTileIndexY(), this.failOnError, this.registry, this.context); } else { task = new PlaceHolderImageTask(this.tiledLayer.getMissingTileImage(), tileInfo.getTileIndexX(), tileInfo.getTileIndexY()); } Tile tile = task.call(); if (tile.getImage() != null) { graphics.drawImage(tile.getImage(), tile.getxIndex() * this.tiledLayer.getTileSize().width, tile.getyIndex() * this.tiledLayer.getTileSize().height, null); } } } finally { graphics.dispose(); } GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); GeneralEnvelope gridEnvelope = new GeneralEnvelope(this.tilePreparationInfo.getMapProjection()); gridEnvelope.setEnvelope(this.tilePreparationInfo.getGridCoverageOrigin().x, this.tilePreparationInfo.getGridCoverageOrigin().y, this.tilePreparationInfo.getGridCoverageMaxX(), this.tilePreparationInfo.getGridCoverageMaxY()); return factory.create(this.tiledLayer.createCommonUrl(), coverageImage, gridEnvelope, null, null, null); } catch (Exception e) { throw ExceptionUtils.getRuntimeException(e); } }
java
public GridCoverage2D call() { try { BufferedImage coverageImage = this.tiledLayer.createBufferedImage( this.tilePreparationInfo.getImageWidth(), this.tilePreparationInfo.getImageHeight()); Graphics2D graphics = coverageImage.createGraphics(); try { for (SingleTilePreparationInfo tileInfo: this.tilePreparationInfo.getSingleTiles()) { final TileTask task; if (tileInfo.getTileRequest() != null) { task = new SingleTileLoaderTask( tileInfo.getTileRequest(), this.errorImage, tileInfo.getTileIndexX(), tileInfo.getTileIndexY(), this.failOnError, this.registry, this.context); } else { task = new PlaceHolderImageTask(this.tiledLayer.getMissingTileImage(), tileInfo.getTileIndexX(), tileInfo.getTileIndexY()); } Tile tile = task.call(); if (tile.getImage() != null) { graphics.drawImage(tile.getImage(), tile.getxIndex() * this.tiledLayer.getTileSize().width, tile.getyIndex() * this.tiledLayer.getTileSize().height, null); } } } finally { graphics.dispose(); } GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); GeneralEnvelope gridEnvelope = new GeneralEnvelope(this.tilePreparationInfo.getMapProjection()); gridEnvelope.setEnvelope(this.tilePreparationInfo.getGridCoverageOrigin().x, this.tilePreparationInfo.getGridCoverageOrigin().y, this.tilePreparationInfo.getGridCoverageMaxX(), this.tilePreparationInfo.getGridCoverageMaxY()); return factory.create(this.tiledLayer.createCommonUrl(), coverageImage, gridEnvelope, null, null, null); } catch (Exception e) { throw ExceptionUtils.getRuntimeException(e); } }
[ "public", "GridCoverage2D", "call", "(", ")", "{", "try", "{", "BufferedImage", "coverageImage", "=", "this", ".", "tiledLayer", ".", "createBufferedImage", "(", "this", ".", "tilePreparationInfo", ".", "getImageWidth", "(", ")", ",", "this", ".", "tilePreparationInfo", ".", "getImageHeight", "(", ")", ")", ";", "Graphics2D", "graphics", "=", "coverageImage", ".", "createGraphics", "(", ")", ";", "try", "{", "for", "(", "SingleTilePreparationInfo", "tileInfo", ":", "this", ".", "tilePreparationInfo", ".", "getSingleTiles", "(", ")", ")", "{", "final", "TileTask", "task", ";", "if", "(", "tileInfo", ".", "getTileRequest", "(", ")", "!=", "null", ")", "{", "task", "=", "new", "SingleTileLoaderTask", "(", "tileInfo", ".", "getTileRequest", "(", ")", ",", "this", ".", "errorImage", ",", "tileInfo", ".", "getTileIndexX", "(", ")", ",", "tileInfo", ".", "getTileIndexY", "(", ")", ",", "this", ".", "failOnError", ",", "this", ".", "registry", ",", "this", ".", "context", ")", ";", "}", "else", "{", "task", "=", "new", "PlaceHolderImageTask", "(", "this", ".", "tiledLayer", ".", "getMissingTileImage", "(", ")", ",", "tileInfo", ".", "getTileIndexX", "(", ")", ",", "tileInfo", ".", "getTileIndexY", "(", ")", ")", ";", "}", "Tile", "tile", "=", "task", ".", "call", "(", ")", ";", "if", "(", "tile", ".", "getImage", "(", ")", "!=", "null", ")", "{", "graphics", ".", "drawImage", "(", "tile", ".", "getImage", "(", ")", ",", "tile", ".", "getxIndex", "(", ")", "*", "this", ".", "tiledLayer", ".", "getTileSize", "(", ")", ".", "width", ",", "tile", ".", "getyIndex", "(", ")", "*", "this", ".", "tiledLayer", ".", "getTileSize", "(", ")", ".", "height", ",", "null", ")", ";", "}", "}", "}", "finally", "{", "graphics", ".", "dispose", "(", ")", ";", "}", "GridCoverageFactory", "factory", "=", "CoverageFactoryFinder", ".", "getGridCoverageFactory", "(", "null", ")", ";", "GeneralEnvelope", "gridEnvelope", "=", "new", "GeneralEnvelope", "(", "this", ".", "tilePreparationInfo", ".", "getMapProjection", "(", ")", ")", ";", "gridEnvelope", ".", "setEnvelope", "(", "this", ".", "tilePreparationInfo", ".", "getGridCoverageOrigin", "(", ")", ".", "x", ",", "this", ".", "tilePreparationInfo", ".", "getGridCoverageOrigin", "(", ")", ".", "y", ",", "this", ".", "tilePreparationInfo", ".", "getGridCoverageMaxX", "(", ")", ",", "this", ".", "tilePreparationInfo", ".", "getGridCoverageMaxY", "(", ")", ")", ";", "return", "factory", ".", "create", "(", "this", ".", "tiledLayer", ".", "createCommonUrl", "(", ")", ",", "coverageImage", ",", "gridEnvelope", ",", "null", ",", "null", ",", "null", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "ExceptionUtils", ".", "getRuntimeException", "(", "e", ")", ";", "}", "}" ]
Call the Coverage Task.
[ "Call", "the", "Coverage", "Task", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/CoverageTask.java#L84-L123
159,394
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java
ThreadPoolJobManager.shutdown
@PreDestroy public final void shutdown() { this.timer.shutdownNow(); this.executor.shutdownNow(); if (this.cleanUpTimer != null) { this.cleanUpTimer.shutdownNow(); } }
java
@PreDestroy public final void shutdown() { this.timer.shutdownNow(); this.executor.shutdownNow(); if (this.cleanUpTimer != null) { this.cleanUpTimer.shutdownNow(); } }
[ "@", "PreDestroy", "public", "final", "void", "shutdown", "(", ")", "{", "this", ".", "timer", ".", "shutdownNow", "(", ")", ";", "this", ".", "executor", ".", "shutdownNow", "(", ")", ";", "if", "(", "this", ".", "cleanUpTimer", "!=", "null", ")", "{", "this", ".", "cleanUpTimer", ".", "shutdownNow", "(", ")", ";", "}", "}" ]
Called by spring when application context is being destroyed.
[ "Called", "by", "spring", "when", "application", "context", "is", "being", "destroyed", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java#L273-L280
159,395
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java
ThreadPoolJobManager.isAbandoned
private boolean isAbandoned(final SubmittedPrintJob printJob) { final long duration = ThreadPoolJobManager.this.jobQueue.timeSinceLastStatusCheck( printJob.getEntry().getReferenceId()); final boolean abandoned = duration > TimeUnit.SECONDS.toMillis(ThreadPoolJobManager.this.abandonedTimeout); if (abandoned) { LOGGER.info("Job {} is abandoned (no status check within the last {} seconds)", printJob.getEntry().getReferenceId(), ThreadPoolJobManager.this.abandonedTimeout); } return abandoned; }
java
private boolean isAbandoned(final SubmittedPrintJob printJob) { final long duration = ThreadPoolJobManager.this.jobQueue.timeSinceLastStatusCheck( printJob.getEntry().getReferenceId()); final boolean abandoned = duration > TimeUnit.SECONDS.toMillis(ThreadPoolJobManager.this.abandonedTimeout); if (abandoned) { LOGGER.info("Job {} is abandoned (no status check within the last {} seconds)", printJob.getEntry().getReferenceId(), ThreadPoolJobManager.this.abandonedTimeout); } return abandoned; }
[ "private", "boolean", "isAbandoned", "(", "final", "SubmittedPrintJob", "printJob", ")", "{", "final", "long", "duration", "=", "ThreadPoolJobManager", ".", "this", ".", "jobQueue", ".", "timeSinceLastStatusCheck", "(", "printJob", ".", "getEntry", "(", ")", ".", "getReferenceId", "(", ")", ")", ";", "final", "boolean", "abandoned", "=", "duration", ">", "TimeUnit", ".", "SECONDS", ".", "toMillis", "(", "ThreadPoolJobManager", ".", "this", ".", "abandonedTimeout", ")", ";", "if", "(", "abandoned", ")", "{", "LOGGER", ".", "info", "(", "\"Job {} is abandoned (no status check within the last {} seconds)\"", ",", "printJob", ".", "getEntry", "(", ")", ".", "getReferenceId", "(", ")", ",", "ThreadPoolJobManager", ".", "this", ".", "abandonedTimeout", ")", ";", "}", "return", "abandoned", ";", "}" ]
If the status of a print job is not checked for a while, we assume that the user is no longer interested in the report, and we cancel the job. @param printJob @return is the abandoned timeout exceeded?
[ "If", "the", "status", "of", "a", "print", "job", "is", "not", "checked", "for", "a", "while", "we", "assume", "that", "the", "user", "is", "no", "longer", "interested", "in", "the", "report", "and", "we", "cancel", "the", "job", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java#L479-L489
159,396
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java
ThreadPoolJobManager.isAcceptingNewJobs
private boolean isAcceptingNewJobs() { if (this.requestedToStop) { return false; } else if (new File(this.workingDirectories.getWorking(), "stop").exists()) { LOGGER.info("The print has been requested to stop"); this.requestedToStop = true; notifyIfStopped(); return false; } else { return true; } }
java
private boolean isAcceptingNewJobs() { if (this.requestedToStop) { return false; } else if (new File(this.workingDirectories.getWorking(), "stop").exists()) { LOGGER.info("The print has been requested to stop"); this.requestedToStop = true; notifyIfStopped(); return false; } else { return true; } }
[ "private", "boolean", "isAcceptingNewJobs", "(", ")", "{", "if", "(", "this", ".", "requestedToStop", ")", "{", "return", "false", ";", "}", "else", "if", "(", "new", "File", "(", "this", ".", "workingDirectories", ".", "getWorking", "(", ")", ",", "\"stop\"", ")", ".", "exists", "(", ")", ")", "{", "LOGGER", ".", "info", "(", "\"The print has been requested to stop\"", ")", ";", "this", ".", "requestedToStop", "=", "true", ";", "notifyIfStopped", "(", ")", ";", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Check if the print has not been asked to stop taking new jobs. @return true if it's OK to take new jobs.
[ "Check", "if", "the", "print", "has", "not", "been", "asked", "to", "stop", "taking", "new", "jobs", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java#L496-L507
159,397
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java
ThreadPoolJobManager.notifyIfStopped
private void notifyIfStopped() { if (isAcceptingNewJobs() || !this.runningTasksFutures.isEmpty()) { return; } final File stoppedFile = new File(this.workingDirectories.getWorking(), "stopped"); try { LOGGER.info("The print has finished processing jobs and can now stop"); stoppedFile.createNewFile(); } catch (IOException e) { LOGGER.warn("Cannot create the {} file", stoppedFile, e); } }
java
private void notifyIfStopped() { if (isAcceptingNewJobs() || !this.runningTasksFutures.isEmpty()) { return; } final File stoppedFile = new File(this.workingDirectories.getWorking(), "stopped"); try { LOGGER.info("The print has finished processing jobs and can now stop"); stoppedFile.createNewFile(); } catch (IOException e) { LOGGER.warn("Cannot create the {} file", stoppedFile, e); } }
[ "private", "void", "notifyIfStopped", "(", ")", "{", "if", "(", "isAcceptingNewJobs", "(", ")", "||", "!", "this", ".", "runningTasksFutures", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "final", "File", "stoppedFile", "=", "new", "File", "(", "this", ".", "workingDirectories", ".", "getWorking", "(", ")", ",", "\"stopped\"", ")", ";", "try", "{", "LOGGER", ".", "info", "(", "\"The print has finished processing jobs and can now stop\"", ")", ";", "stoppedFile", ".", "createNewFile", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "warn", "(", "\"Cannot create the {} file\"", ",", "stoppedFile", ",", "e", ")", ";", "}", "}" ]
Add a file to notify the script that asked to stop the print that it is now done processing the remain jobs.
[ "Add", "a", "file", "to", "notify", "the", "script", "that", "asked", "to", "stop", "the", "print", "that", "it", "is", "now", "done", "processing", "the", "remain", "jobs", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/ThreadPoolJobManager.java#L513-L524
159,398
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/AreaOfInterest.java
AreaOfInterest.postConstruct
public void postConstruct() { parseGeometry(); Assert.isTrue(this.polygon != null, "Polygon is null. 'area' string is: '" + this.area + "'"); Assert.isTrue(this.display != null, "'display' is null"); Assert.isTrue(this.style == null || this.display == AoiDisplay.RENDER, "'style' does not make sense unless 'display' == RENDER. In this case 'display' == " + this.display); }
java
public void postConstruct() { parseGeometry(); Assert.isTrue(this.polygon != null, "Polygon is null. 'area' string is: '" + this.area + "'"); Assert.isTrue(this.display != null, "'display' is null"); Assert.isTrue(this.style == null || this.display == AoiDisplay.RENDER, "'style' does not make sense unless 'display' == RENDER. In this case 'display' == " + this.display); }
[ "public", "void", "postConstruct", "(", ")", "{", "parseGeometry", "(", ")", ";", "Assert", ".", "isTrue", "(", "this", ".", "polygon", "!=", "null", ",", "\"Polygon is null. 'area' string is: '\"", "+", "this", ".", "area", "+", "\"'\"", ")", ";", "Assert", ".", "isTrue", "(", "this", ".", "display", "!=", "null", ",", "\"'display' is null\"", ")", ";", "Assert", ".", "isTrue", "(", "this", ".", "style", "==", "null", "||", "this", ".", "display", "==", "AoiDisplay", ".", "RENDER", ",", "\"'style' does not make sense unless 'display' == RENDER. In this case 'display' == \"", "+", "this", ".", "display", ")", ";", "}" ]
Tests that the area is valid geojson, the style ref is valid or null and the display is non-null.
[ "Tests", "that", "the", "area", "is", "valid", "geojson", "the", "style", "ref", "is", "valid", "or", "null", "and", "the", "display", "is", "non", "-", "null", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/AreaOfInterest.java#L57-L66
159,399
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/AreaOfInterest.java
AreaOfInterest.areaToFeatureCollection
public SimpleFeatureCollection areaToFeatureCollection( @Nonnull final MapAttribute.MapAttributeValues mapAttributes) { Assert.isTrue(mapAttributes.areaOfInterest == this, "map attributes passed in does not contain this area of interest object"); final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName("aoi"); CoordinateReferenceSystem crs = mapAttributes.getMapBounds().getProjection(); typeBuilder.add("geom", this.polygon.getClass(), crs); final SimpleFeature feature = SimpleFeatureBuilder.build(typeBuilder.buildFeatureType(), new Object[]{this.polygon}, "aoi"); final DefaultFeatureCollection features = new DefaultFeatureCollection(); features.add(feature); return features; }
java
public SimpleFeatureCollection areaToFeatureCollection( @Nonnull final MapAttribute.MapAttributeValues mapAttributes) { Assert.isTrue(mapAttributes.areaOfInterest == this, "map attributes passed in does not contain this area of interest object"); final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName("aoi"); CoordinateReferenceSystem crs = mapAttributes.getMapBounds().getProjection(); typeBuilder.add("geom", this.polygon.getClass(), crs); final SimpleFeature feature = SimpleFeatureBuilder.build(typeBuilder.buildFeatureType(), new Object[]{this.polygon}, "aoi"); final DefaultFeatureCollection features = new DefaultFeatureCollection(); features.add(feature); return features; }
[ "public", "SimpleFeatureCollection", "areaToFeatureCollection", "(", "@", "Nonnull", "final", "MapAttribute", ".", "MapAttributeValues", "mapAttributes", ")", "{", "Assert", ".", "isTrue", "(", "mapAttributes", ".", "areaOfInterest", "==", "this", ",", "\"map attributes passed in does not contain this area of interest object\"", ")", ";", "final", "SimpleFeatureTypeBuilder", "typeBuilder", "=", "new", "SimpleFeatureTypeBuilder", "(", ")", ";", "typeBuilder", ".", "setName", "(", "\"aoi\"", ")", ";", "CoordinateReferenceSystem", "crs", "=", "mapAttributes", ".", "getMapBounds", "(", ")", ".", "getProjection", "(", ")", ";", "typeBuilder", ".", "add", "(", "\"geom\"", ",", "this", ".", "polygon", ".", "getClass", "(", ")", ",", "crs", ")", ";", "final", "SimpleFeature", "feature", "=", "SimpleFeatureBuilder", ".", "build", "(", "typeBuilder", ".", "buildFeatureType", "(", ")", ",", "new", "Object", "[", "]", "{", "this", ".", "polygon", "}", ",", "\"aoi\"", ")", ";", "final", "DefaultFeatureCollection", "features", "=", "new", "DefaultFeatureCollection", "(", ")", ";", "features", ".", "add", "(", "feature", ")", ";", "return", "features", ";", "}" ]
Return the area polygon as the only feature in the feature collection. @param mapAttributes the attributes that this aoi is part of.
[ "Return", "the", "area", "polygon", "as", "the", "only", "feature", "in", "the", "feature", "collection", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/AreaOfInterest.java#L95-L109