idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
3,300
public String encrypt ( String data ) throws UnsupportedEncodingException , NoSuchAlgorithmException , NoSuchPaddingException , InvalidAlgorithmParameterException , InvalidKeyException , InvalidKeySpecException , BadPaddingException , IllegalBlockSizeException { if ( data == null ) return null ; SecretKey secretKey = g...
Encrypt a String
3,301
public void encryptAsync ( final String data , final Callback callback ) { if ( callback == null ) return ; new Thread ( new Runnable ( ) { public void run ( ) { try { String encrypt = encrypt ( data ) ; if ( encrypt == null ) { callback . onError ( new Exception ( "Encrypt return null, it normally occurs when you send...
This is a sugar method that calls encrypt method in background it is a good idea to use this one instead the default method because encryption can take several time and with this method the process occurs in a AsyncTask other advantage is the Callback with separated methods one for success and other for the exception
3,302
public String decrypt ( String data ) throws UnsupportedEncodingException , NoSuchAlgorithmException , InvalidKeySpecException , NoSuchPaddingException , InvalidAlgorithmParameterException , InvalidKeyException , BadPaddingException , IllegalBlockSizeException { if ( data == null ) return null ; byte [ ] dataBytes = Ba...
Decrypt a String
3,303
public void decryptAsync ( final String data , final Callback callback ) { if ( callback == null ) return ; new Thread ( new Runnable ( ) { public void run ( ) { try { String decrypt = decrypt ( data ) ; if ( decrypt == null ) { callback . onError ( new Exception ( "Decrypt return null, it normally occurs when you send...
This is a sugar method that calls decrypt method in background it is a good idea to use this one instead the default method because decryption can take several time and with this method the process occurs in a AsyncTask other advantage is the Callback with separated methods one for success and other for the exception
3,304
private SecretKey getSecretKey ( char [ ] key ) throws NoSuchAlgorithmException , UnsupportedEncodingException , InvalidKeySpecException { SecretKeyFactory factory = SecretKeyFactory . getInstance ( mBuilder . getSecretKeyType ( ) ) ; KeySpec spec = new PBEKeySpec ( key , mBuilder . getSalt ( ) . getBytes ( mBuilder . ...
creates a 128bit salted aes key
3,305
private char [ ] hashTheKey ( String key ) throws UnsupportedEncodingException , NoSuchAlgorithmException { MessageDigest messageDigest = MessageDigest . getInstance ( mBuilder . getDigestAlgorithm ( ) ) ; messageDigest . update ( key . getBytes ( mBuilder . getCharsetName ( ) ) ) ; return Base64 . encodeToString ( mes...
takes in a simple string and performs an sha1 hash that is 128 bits long ... we then base64 encode it and return the char array
3,306
private void renderTag ( Tag tag , StringBuilder buffer ) { buffer . append ( tag . name ( ) ) . append ( ' ' ) ; if ( ( tag instanceof ParamTag ) && ( ( ParamTag ) tag ) . isTypeParameter ( ) ) { ParamTag paramTag = ( ParamTag ) tag ; buffer . append ( "<" + paramTag . parameterName ( ) + ">" ) ; String text = paramTa...
Renders a document tag in the standard way .
3,307
private String render ( String input , boolean inline ) { if ( input . trim ( ) . isEmpty ( ) ) { return "" ; } options . setDocType ( inline ? INLINE_DOCTYPE : null ) ; return asciidoctor . render ( cleanJavadocInput ( input ) , options ) ; }
Renders the input using Asciidoctor .
3,308
@ SuppressWarnings ( "UnusedDeclaration" ) public static boolean validOptions ( String [ ] [ ] options , DocErrorReporter errorReporter ) { return validOptions ( options , errorReporter , new StandardAdapter ( ) ) ; }
Processes the input options by delegating to the standard handler .
3,309
public boolean render ( RootDoc rootDoc , DocletRenderer renderer ) { if ( ! processOverview ( rootDoc , renderer ) ) { return false ; } Set < PackageDoc > packages = new HashSet < PackageDoc > ( ) ; for ( ClassDoc doc : rootDoc . classes ( ) ) { packages . add ( doc . containingPackage ( ) ) ; renderClass ( doc , rend...
Renders a RootDoc s contents .
3,310
private void renderClass ( ClassDoc doc , DocletRenderer renderer ) { renderer . renderDoc ( doc ) ; for ( MemberDoc member : doc . fields ( ) ) { renderer . renderDoc ( member ) ; } for ( MemberDoc member : doc . constructors ( ) ) { renderer . renderDoc ( member ) ; } for ( MemberDoc member : doc . methods ( ) ) { re...
Renders an individual class .
3,311
public void close ( ) throws IOException , GeneralSecurityException { if ( mManifest != null ) { mOutputJar . putNextEntry ( new JarEntry ( JarFile . MANIFEST_NAME ) ) ; mManifest . write ( mOutputJar ) ; Signature signature = Signature . getInstance ( "SHA1with" + mKey . getAlgorithm ( ) ) ; signature . initSign ( mKe...
Closes the Jar archive by creating the manifest and signing the archive .
3,312
private void writeSignatureBlock ( Signature signature , X509Certificate publicKey , PrivateKey privateKey ) throws IOException , GeneralSecurityException { SignerInfo signerInfo = new SignerInfo ( new X500Name ( publicKey . getIssuerX500Principal ( ) . getName ( ) ) , publicKey . getSerialNumber ( ) , AlgorithmId . ge...
Write the certificate file with a digital signature .
3,313
public void validate ( ) { Revision revBuildToolsVersion = Revision . parseRevision ( buildToolsVersion ) ; if ( minimalBuildToolsVersion . compareTo ( revBuildToolsVersion ) > 0 ) { throw new GradleException ( "Android buildToolsVersion should be at least version " + minimalBuildToolsVersion + ": currently using " + b...
Checks whether the properties on the android extension are valid after everything was configured .
3,314
public static SigningInfo getDebugKey ( String storeOsPath , final PrintStream verboseStream ) throws ApkCreationException { try { if ( storeOsPath != null ) { File storeFile = new File ( storeOsPath ) ; try { checkInputFile ( storeFile ) ; } catch ( FileNotFoundException e ) { } if ( verboseStream != null ) { verboseS...
Returns the key and certificate from a given debug store .
3,315
private void init ( File apkFile , File resFile , File dexFile , PrivateKey key , X509Certificate certificate , PrintStream verboseStream ) throws ApkCreationException { try { checkOutputFile ( mApkFile = apkFile ) ; checkInputFile ( mResFile = resFile ) ; if ( dexFile != null ) { checkInputFile ( mDexFile = dexFile ) ...
Constructor init method .
3,316
public void addFile ( File file , String archivePath ) throws ApkCreationException , SealedApkException , DuplicateFileException { if ( mIsSealed ) { throw new SealedApkException ( "APK is already sealed" ) ; } try { doAddFile ( file , archivePath ) ; } catch ( DuplicateFileException e ) { mBuilder . cleanUp ( ) ; thro...
Adds a file to the APK at a given path
3,317
public void addZipFile ( File zipFile ) throws ApkCreationException , SealedApkException , DuplicateFileException { if ( mIsSealed ) { throw new SealedApkException ( "APK is already sealed" ) ; } try { verbosePrintln ( "%s:" , zipFile ) ; mNullFilter . reset ( zipFile ) ; FileInputStream fis = new FileInputStream ( zip...
Adds the content from a zip file . All file keep the same path inside the archive .
3,318
public JarStatus addResourcesFromJar ( File jarFile ) throws ApkCreationException , SealedApkException , DuplicateFileException { if ( mIsSealed ) { throw new SealedApkException ( "APK is already sealed" ) ; } try { verbosePrintln ( "%s:" , jarFile ) ; mFilter . reset ( jarFile ) ; FileInputStream fis = new FileInputSt...
Adds the resources from a jar file .
3,319
public void addSourceFolder ( File sourceFolder ) throws ApkCreationException , SealedApkException , DuplicateFileException { if ( mIsSealed ) { throw new SealedApkException ( "APK is already sealed" ) ; } addSourceFolder ( this , sourceFolder ) ; }
Adds the resources from a source folder .
3,320
public void addNativeLibraries ( File nativeFolder ) throws ApkCreationException , SealedApkException , DuplicateFileException { if ( mIsSealed ) { throw new SealedApkException ( "APK is already sealed" ) ; } if ( ! nativeFolder . isDirectory ( ) ) { if ( nativeFolder . exists ( ) ) { throw new ApkCreationException ( "...
Adds the native libraries from the top native folder . The content of this folder must be the various ABI folders .
3,321
public void sealApk ( ) throws ApkCreationException , SealedApkException { if ( mIsSealed ) { throw new SealedApkException ( "APK is already sealed" ) ; } try { mBuilder . close ( ) ; mIsSealed = true ; } catch ( Exception e ) { throw new ApkCreationException ( e , "Failed to seal APK" ) ; } finally { mBuilder . cleanU...
Seals the APK and signs it if necessary .
3,322
private void verbosePrintln ( String format , Object ... args ) { if ( mVerboseStream != null ) { mVerboseStream . println ( String . format ( format , args ) ) ; } }
Output a given message if the verbose mode is enabled .
3,323
public static boolean checkFolderForPackaging ( String folderName ) { return ! folderName . equalsIgnoreCase ( "CVS" ) && ! folderName . equalsIgnoreCase ( ".svn" ) && ! folderName . equalsIgnoreCase ( "SCCS" ) && ! folderName . startsWith ( "_" ) ; }
Checks whether a folder and its content is valid for packaging into the . apk as standard Java resource .
3,324
public void applyConfiguration ( Configuration configuration ) { if ( plugins != null ) { plugins . stream ( ) . filter ( pluginDefinition -> pluginDefinition . isConfigurationSupported ( configuration ) ) . forEach ( pluginDefinition -> project . getDependencies ( ) . add ( configuration . getName ( ) , generateDepend...
Add dependencies to the specified configuration . Only dependencies to plugins that support the provided configuration will be included .
3,325
List < ResourceSet > computeResourceSetList ( ) { List < ResourceSet > sourceFolderSets = resSetSupplier . get ( ) ; int size = sourceFolderSets . size ( ) + 4 ; if ( libraries != null ) { size += libraries . getArtifacts ( ) . size ( ) ; } List < ResourceSet > resourceSetList = Lists . newArrayListWithExpectedSize ( s...
Compute the list of resource set to be used during execution based all the inputs .
3,326
private static void examineAsBrowser ( final UserAgent . Builder builder , final Data data ) { Matcher matcher ; VersionNumber version = VersionNumber . UNKNOWN ; for ( final Entry < BrowserPattern , Browser > entry : data . getPatternToBrowserMap ( ) . entrySet ( ) ) { matcher = entry . getKey ( ) . getPattern ( ) . m...
Examines the user agent string whether it is a browser .
3,327
private static boolean examineAsRobot ( final UserAgent . Builder builder , final Data data ) { boolean isRobot = false ; VersionNumber version ; for ( final Robot robot : data . getRobots ( ) ) { if ( robot . getUserAgentString ( ) . equals ( builder . getUserAgentString ( ) ) ) { isRobot = true ; robot . copyTo ( bui...
Examines the user agent string whether it is a robot .
3,328
private static void examineDeviceCategory ( final UserAgent . Builder builder , final Data data ) { if ( UserAgentType . ROBOT == builder . getType ( ) ) { final DeviceCategory category = findDeviceCategoryByValue ( Category . OTHER , data ) ; builder . setDeviceCategory ( category ) ; return ; } for ( final Entry < De...
Examines the user agent string whether has a specific device category .
3,329
private static void examineOperatingSystem ( final UserAgent . Builder builder , final Data data ) { if ( net . sf . uadetector . OperatingSystem . EMPTY . equals ( builder . getOperatingSystem ( ) ) ) { for ( final Entry < OperatingSystemPattern , OperatingSystem > entry : data . getPatternToOperatingSystemMap ( ) . e...
Examines the operating system of the user agent string if not available .
3,330
public int compare ( final T o1 , final T o2 ) { int result = 0 ; if ( o1 == null ) { if ( o2 != null ) { result = - 1 ; } } else if ( o2 == null ) { result = 1 ; } else { result = compareType ( o1 , o2 ) ; } return result ; }
Compares two objects null safe to each other .
3,331
private static int compareInt ( final int a , final int b ) { int result = 0 ; if ( a > b ) { result = 1 ; } else if ( a < b ) { result = - 1 ; } return result ; }
Compares to integers .
3,332
static boolean hasUpdate ( final String newer , final String older ) { return VERSION_PATTERN . matcher ( newer ) . matches ( ) && VERSION_PATTERN . matcher ( older ) . matches ( ) ? newer . compareTo ( older ) > 0 : false ; }
Checks a given newer version against an older one .
3,333
protected boolean isUpdateAvailable ( ) { boolean result = false ; String version = EMPTY_VERSION ; try { version = retrieveRemoteVersion ( store . getVersionUrl ( ) , store . getCharset ( ) ) ; } catch ( final IOException e ) { LOG . info ( MSG_NO_UPDATE_CHECK_POSSIBLE ) ; LOG . debug ( String . format ( MSG_NO_UPDATE...
Fetches the current version information over HTTP and compares it with the last version of the most recently imported data .
3,334
public DataBuilder appendBrowserPattern ( final BrowserPattern pattern ) { Check . notNull ( pattern , "pattern" ) ; if ( ! browserPatterns . containsKey ( pattern . getId ( ) ) ) { browserPatterns . put ( pattern . getId ( ) , new TreeSet < BrowserPattern > ( BROWSER_PATTERN_COMPARATOR ) ) ; } browserPatterns . get ( ...
Appends a browser pattern to the map of pattern sorted by ID .
3,335
public DataBuilder appendDevicePattern ( final DevicePattern pattern ) { Check . notNull ( pattern , "pattern" ) ; if ( ! devicePatterns . containsKey ( pattern . getId ( ) ) ) { devicePatterns . put ( pattern . getId ( ) , new TreeSet < DevicePattern > ( DEVICE_PATTERN_COMPARATOR ) ) ; } devicePatterns . get ( pattern...
Appends a device pattern to the map of pattern sorted by ID .
3,336
public DataBuilder appendOperatingSystemPattern ( final OperatingSystemPattern pattern ) { Check . notNull ( pattern , "pattern" ) ; if ( ! operatingSystemPatterns . containsKey ( pattern . getId ( ) ) ) { operatingSystemPatterns . put ( pattern . getId ( ) , new TreeSet < OperatingSystemPattern > ( OS_PATTERN_COMPARAT...
Appends an operating system pattern to the map of pattern sorted by ID .
3,337
private void setUpUpdateService ( ) { if ( currentUpdateTask != null ) { currentUpdateTask . cancel ( false ) ; } currentUpdateTask = scheduler . scheduleWithFixedDelay ( getDataStore ( ) . getUpdateOperation ( ) , 0 , updateInterval , MILLISECONDS ) ; }
Set up a new update service to get newer UAS data
3,338
public void copyTo ( final UserAgent . Builder builder ) { final OperatingSystemFamily f = OperatingSystemFamily . evaluate ( family ) ; final VersionNumber version = VersionNumber . parseOperatingSystemVersion ( f , builder . getUserAgentString ( ) ) ; builder . setOperatingSystem ( new net . sf . uadetector . Operati...
Copies all information of the current operating system entry to the given user agent builder .
3,339
protected static File createTemporaryFile ( final File file ) { Check . notNull ( file , "file" ) ; final File tempFile = new File ( file . getParent ( ) , file . getName ( ) + ".temp" ) ; deleteFile ( tempFile ) ; return tempFile ; }
Creates a temporary file near the passed file . The name of the given one will be used and the suffix . temp will be added .
3,340
protected static void deleteFile ( final File file ) { Check . notNull ( file , "file" ) ; Check . stateIsTrue ( ! file . exists ( ) || file . delete ( ) , "Cannot delete file '%s'." , file . getPath ( ) ) ; }
Removes the given file .
3,341
private static String toVersionString ( final List < String > groups ) { final StringBuilder builder = new StringBuilder ( 6 ) ; int count = 0 ; for ( final String segment : groups ) { if ( EMPTY_GROUP . equals ( segment ) ) { break ; } else { if ( count > 0 ) { builder . append ( SEPARATOR ) ; } builder . append ( seg...
Converts the given list of numbers in a version string . The groups of the version number will be separated by a dot .
3,342
public int compareTo ( final ReadableVersionNumber other ) { int result = 0 ; if ( other == null ) { result = - 1 ; } else { Check . notNull ( other . getGroups ( ) , "other.getGroups()" ) ; final int length = groups . size ( ) < other . getGroups ( ) . size ( ) ? groups . size ( ) : other . getGroups ( ) . size ( ) ; ...
Compares this version number with the specified version number for order . Returns a negative integer zero or a positive integer as this version number is less than equal to or greater than the specified version number .
3,343
protected static void logParsingIssue ( final String prefix , final SAXParseException e ) { final StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( prefix ) ; buffer . append ( " while reading UAS data: " ) ; buffer . append ( e . getMessage ( ) ) ; buffer . append ( " (line: " ) ; buffer . append ( e . ...
Logs an issue while parsing XML .
3,344
private void transferToSpecificBuilderAndReset ( ) { if ( currentTag == Tag . VERSION ) { dataBuilder . setVersion ( buffer . toString ( ) ) ; } addToRobotBuilder ( ) ; addToBrowserBuilder ( ) ; addToOperatingSystemBuilder ( ) ; addToBrowserPatternBuilder ( ) ; addToBrowserTypeBuilder ( ) ; addToBrowserOsMappingBuilder...
Transfers all characters of a specific tag to the corresponding builder and resets the string buffer .
3,345
private static void deleteCacheFile ( final File cacheFile ) { try { if ( cacheFile . delete ( ) ) { LOG . warn ( String . format ( MSG_CACHE_FILE_IS_DAMAGED_AND_DELETED , cacheFile . getPath ( ) ) ) ; } else { LOG . warn ( String . format ( MSG_CACHE_FILE_IS_DAMAGED , cacheFile . getPath ( ) ) ) ; } } catch ( final Ex...
Removes the given cache file because it contains damaged content .
3,346
private static DataStore readCacheFileAsFallback ( final DataReader reader , final File cacheFile , final Charset charset , final DataStore fallback ) { DataStore fallbackDataStore ; if ( ! isEmpty ( cacheFile , charset ) ) { final URL cacheFileUrl = UrlUtil . toUrl ( cacheFile ) ; try { fallbackDataStore = new CacheFi...
Tries to read the content of specified cache file and returns them as fallback data store . If the cache file contains unexpected data the given fallback data store will be returned instead .
3,347
public void activate ( InetAddress host , int port , Collection < String > nonProxyHosts ) { for ( String scheme : new String [ ] { "http" , "https" } ) { String currentProxyHost = System . getProperty ( scheme + ".proxyHost" ) ; String currentProxyPort = System . getProperty ( scheme + ".proxyPort" ) ; if ( currentPro...
Activates a proxy override for the given URI scheme .
3,348
public void deactivateAll ( ) { for ( String scheme : new String [ ] { "http" , "https" } ) { InetSocketAddress originalProxy = originalProxies . remove ( scheme ) ; if ( originalProxy != null ) { System . setProperty ( scheme + ".proxyHost" , originalProxy . getHostName ( ) ) ; System . setProperty ( scheme + ".proxyP...
Deactivates all proxy overrides restoring the pre - existing proxy settings if any .
3,349
public ProxySelector getOriginalProxySelector ( ) { return new ProxySelector ( ) { public List < Proxy > select ( URI uri ) { InetSocketAddress address = originalProxies . get ( uri . getScheme ( ) ) ; if ( address != null && ! ( originalNonProxyHosts . contains ( uri . getHost ( ) ) ) ) { return Collections . singleto...
Used by the Betamax proxy so that it can use pre - existing proxy settings when forwarding requests that do not match anything on tape .
3,350
public void lookupChainedProxies ( HttpRequest request , Queue < ChainedProxy > chainedProxies ) { final InetSocketAddress originalProxy = originalProxies . get ( URI . create ( request . getUri ( ) ) . getScheme ( ) ) ; if ( originalProxy != null ) { ChainedProxy chainProxy = new ChainedProxyAdapter ( ) { public InetS...
Used by LittleProxy to connect to a downstream proxy if there is one .
3,351
public void start ( String tapeName , Optional < TapeMode > mode , Optional < MatchRule > matchRule ) { if ( tape != null ) { throw new IllegalStateException ( "start called when Recorder is already started" ) ; } tape = getTapeLoader ( ) . loadTape ( tapeName ) ; tape . setMode ( mode . or ( configuration . getDefault...
Starts the Recorder inserting a tape with the specified parameters .
3,352
public void stop ( ) { if ( tape == null ) { throw new IllegalStateException ( "stop called when Recorder is not started" ) ; } for ( RecorderListener listener : listeners ) { listener . onRecorderStop ( ) ; } getTapeLoader ( ) . writeTape ( tape ) ; tape = null ; }
Stops the Recorder and writes its current tape out to a file .
3,353
public Collection < String > getIgnoreHosts ( ) { if ( isIgnoreLocalhost ( ) ) { return new ImmutableSet . Builder < String > ( ) . addAll ( ignoreHosts ) . addAll ( Network . getLocalAddresses ( ) ) . build ( ) ; } else { return ignoreHosts ; } }
Hosts that are ignored by Betamax . Any connections made will be allowed to proceed normally and not be intercepted .
3,354
public static Map < String , Object > getAnnotationAttributes ( Annotation annotation , boolean classValuesAsString ) { Map < String , Object > attrs = new HashMap < > ( ) ; Method [ ] methods = annotation . annotationType ( ) . getDeclaredMethods ( ) ; for ( Method method : methods ) { if ( method . getParameterTypes ...
Retrieve the given annotation s attributes as a Map .
3,355
protected static void enableOrDisableExternalEntityParsing ( DocumentBuilderFactory factory , boolean enableExternalEntities ) { String [ ] externalGeneralEntitiesFeatures = { "http://xml.org/sax/features/external-general-entities" , "http://xerces.apache.org/xerces-j/features.html#external-general-entities" , "http://...
Explicitly enable or disable the external - general - entities and external - parameter - entities features of the underlying DocumentBuilderFactory .
3,356
protected static Document createDocumentImpl ( String name , String namespaceURI , boolean enableExternalEntities , boolean isNamespaceAware ) throws ParserConfigurationException , FactoryConfigurationError { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( isNam...
Construct an XML Document with a default namespace with the given root element .
3,357
protected static Document parseDocumentImpl ( InputSource inputSource , boolean enableExternalEntities , boolean isNamespaceAware ) throws ParserConfigurationException , SAXException , IOException { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( isNamespaceAwar...
Return an XML Document parsed from the given input source .
3,358
protected void stripWhitespaceOnlyTextNodesImpl ( ) throws XPathExpressionException { XPathFactory xpathFactory = XPathFactory . newInstance ( ) ; XPathExpression xpathExp = xpathFactory . newXPath ( ) . compile ( "//text()[normalize-space(.) = '']" ) ; NodeList emptyTextNodes = ( NodeList ) xpathExp . evaluate ( this ...
Find and delete from the underlying Document any text nodes that contain nothing but whitespace such as newlines and tab or space characters used to indent or pretty - print an XML document .
3,359
protected void importXMLBuilderImpl ( BaseXMLBuilder builder ) { assertElementContainsNoOrWhitespaceOnlyTextNodes ( this . xmlNode ) ; Node importedNode = getDocument ( ) . importNode ( builder . getDocument ( ) . getDocumentElement ( ) , true ) ; this . xmlNode . appendChild ( importedNode ) ; }
Imports another BaseXMLBuilder document into this document at the current position . The entire document provided is imported .
3,360
public Object xpathQuery ( String xpath , QName type , NamespaceContext nsContext ) throws XPathExpressionException { XPathFactory xpathFactory = XPathFactory . newInstance ( ) ; XPath xPath = xpathFactory . newXPath ( ) ; if ( nsContext != null ) { xPath . setNamespaceContext ( nsContext ) ; } XPathExpression xpathExp...
Return the result of evaluating an XPath query on the builder s DOM using the given namespace . Returns null if the query finds nothing or finds a node that does not match the type specified by returnType .
3,361
public Object xpathQuery ( String xpath , QName type ) throws XPathExpressionException { return xpathQuery ( xpath , type , null ) ; }
Return the result of evaluating an XPath query on the builder s DOM . Returns null if the query finds nothing or finds a node that does not match the type specified by returnType .
3,362
protected Element elementImpl ( String name , String namespaceURI ) { assertElementContainsNoOrWhitespaceOnlyTextNodes ( this . xmlNode ) ; if ( namespaceURI == null ) { return getDocument ( ) . createElement ( name ) ; } else { return getDocument ( ) . createElementNS ( namespaceURI , name ) ; } }
Add a named and namespaced XML element to the document as a child of this builder s node .
3,363
protected Element elementBeforeImpl ( String name ) { String prefix = getPrefixFromQualifiedName ( name ) ; String namespaceURI = this . xmlNode . lookupNamespaceURI ( prefix ) ; return elementBeforeImpl ( name , namespaceURI ) ; }
Add a named XML element to the document as a sibling element that precedes the position of this builder node .
3,364
protected Element elementBeforeImpl ( String name , String namespaceURI ) { Node parentNode = this . xmlNode . getParentNode ( ) ; assertElementContainsNoOrWhitespaceOnlyTextNodes ( parentNode ) ; Element newElement = ( namespaceURI == null ? getDocument ( ) . createElement ( name ) : getDocument ( ) . createElementNS ...
Add a named and namespaced XML element to the document as a sibling element that precedes the position of this builder node .
3,365
protected void attributeImpl ( String name , String value ) { if ( ! ( this . xmlNode instanceof Element ) ) { throw new RuntimeException ( "Cannot add an attribute to non-Element underlying node: " + this . xmlNode ) ; } ( ( Element ) xmlNode ) . setAttribute ( name , value ) ; }
Add a named attribute value to the element for this builder node .
3,366
protected void textImpl ( String value , boolean replaceText ) { if ( value == null ) { throw new IllegalArgumentException ( "Illegal null text value" ) ; } if ( replaceText ) { xmlNode . setTextContent ( value ) ; } else { xmlNode . appendChild ( getDocument ( ) . createTextNode ( value ) ) ; } }
Add or replace the text value of an element for this builder node .
3,367
protected void instructionImpl ( String target , String data ) { xmlNode . appendChild ( getDocument ( ) . createProcessingInstruction ( target , data ) ) ; }
Add an instruction to the element represented by this builder node .
3,368
protected void insertInstructionImpl ( String target , String data ) { getDocument ( ) . insertBefore ( getDocument ( ) . createProcessingInstruction ( target , data ) , xmlNode ) ; }
Insert an instruction before the element represented by this builder node .
3,369
protected void namespaceImpl ( String prefix , String namespaceURI ) { if ( ! ( this . xmlNode instanceof Element ) ) { throw new RuntimeException ( "Cannot add an attribute to non-Element underlying node: " + this . xmlNode ) ; } if ( prefix != null && prefix . length ( ) > 0 ) { ( ( Element ) xmlNode ) . setAttribute...
Add an XML namespace attribute to this builder s element node .
3,370
public String asString ( ) throws TransformerException { Properties outputProperties = new Properties ( ) ; outputProperties . put ( javax . xml . transform . OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; return asString ( outputProperties ) ; }
Serialize the XML document to a string excluding the XML declaration .
3,371
public static XMLBuilder2 parse ( InputSource inputSource , boolean enableExternalEntities , boolean isNamespaceAware ) { try { return new XMLBuilder2 ( parseDocumentImpl ( inputSource , enableExternalEntities , isNamespaceAware ) ) ; } catch ( ParserConfigurationException e ) { throw wrapExceptionAsRuntimeException ( ...
Construct a builder from an existing XML document . The provided XML document will be parsed and an XMLBuilder2 object referencing the document s root element will be returned .
3,372
public static XMLBuilder2 parse ( String xmlString , boolean enableExternalEntities , boolean isNamespaceAware ) { return XMLBuilder2 . parse ( new InputSource ( new StringReader ( xmlString ) ) , enableExternalEntities , isNamespaceAware ) ; }
Construct a builder from an existing XML document string . The provided XML document will be parsed and an XMLBuilder2 object referencing the document s root element will be returned .
3,373
public static XMLBuilder2 parse ( File xmlFile , boolean enableExternalEntities , boolean isNamespaceAware ) { try { return XMLBuilder2 . parse ( new InputSource ( new FileReader ( xmlFile ) ) , enableExternalEntities , isNamespaceAware ) ; } catch ( FileNotFoundException e ) { throw wrapExceptionAsRuntimeException ( e...
Construct a builder from an existing XML document file . The provided XML document will be parsed and an XMLBuilder2 object referencing the document s root element will be returned .
3,374
private void initProperties ( ) { center = new SimpleObjectProperty < > ( ) ; center . addListener ( ( observable , oldValue , newValue ) -> { if ( newValue != lastCoordinateFromMap . get ( ) ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "center changed from {} to {}" , oldValue , newValue ) ; } setCenterIn...
initializes the JavaFX properties .
3,375
private void setCenterInMap ( ) { final Coordinate actCenter = getCenter ( ) ; if ( getInitialized ( ) && null != actCenter ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "setting center in OpenLayers map: {}, animation: {}" , actCenter , animationDuration . get ( ) ) ; } jsMapView . call ( "setCenter" , act...
sets the value of the center property in the OL map .
3,376
private void setZoomInMap ( ) { if ( getInitialized ( ) ) { final int zoomInt = ( int ) getZoom ( ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "setting zoom in OpenLayers map: {}, animation: {}" , zoomInt , animationDuration . get ( ) ) ; } jsMapView . call ( "setZoom" , zoomInt , animationDuration . get (...
sets the value of the actual zoom property in the OL map .
3,377
private boolean checkApiKey ( final MapType mapTypeToCheck ) { switch ( requireNonNull ( mapTypeToCheck ) ) { case BINGMAPS_ROAD : case BINGMAPS_AERIAL : return bingMapsApiKey . isPresent ( ) ; default : return true ; } }
checks if the given map type needs an api key and if so if it is set .
3,378
private void setMapTypeInMap ( ) { if ( getInitialized ( ) ) { final String mapTypeName = getMapType ( ) . toString ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "setting map type in OpenLayers map: {}" , mapTypeName ) ; } bingMapsApiKey . ifPresent ( apiKey -> jsMapView . call ( "setBingMapsApiKey" , api...
sets the value of the mapType property in the OL map .
3,379
public MapView addCoordinateLine ( final CoordinateLine coordinateLine ) { if ( ! getInitialized ( ) ) { if ( logger . isWarnEnabled ( ) ) { logger . warn ( MAP_VIEW_NOT_YET_INITIALIZED ) ; } } else { synchronized ( coordinateLines ) { final String id = requireNonNull ( coordinateLine ) . getId ( ) ; if ( ! coordinateL...
add a CoordinateLine to the map . If it was already added nothing happens . The MapView only stores a weak reference to the object so the caller must keep a reference in order to prevent the line to be removed from the map . This method must only be called after the map is initialized otherwise a warning is logged and ...
3,380
private void setCoordinateLineVisibleInMap ( final String coordinateLineId ) { if ( null != coordinateLineId ) { final WeakReference < CoordinateLine > coordinateLineWeakReference = coordinateLines . get ( coordinateLineId ) ; if ( null != coordinateLineWeakReference ) { final CoordinateLine coordinateLine = coordinate...
shows or hides the coordinateline in the map according to it s visible property .
3,381
public MapView addLabel ( final MapLabel mapLabel ) { if ( ! getInitialized ( ) ) { if ( logger . isWarnEnabled ( ) ) { logger . warn ( MAP_VIEW_NOT_YET_INITIALIZED ) ; } } else { if ( null == requireNonNull ( mapLabel ) . getPosition ( ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "label with no position...
adds a label to the map . If it was already added nothing is changed . If the MapView is not yet initialized a warning is logged and nothing changes . If the label has no coordinate set it is not added and a logging entry is written .
3,382
private void addMapCoordinateElement ( final MapCoordinateElement mapCoordinateElement ) { final String id = mapCoordinateElement . getId ( ) ; final ChangeListener < Coordinate > coordinateChangeListener = ( observable , oldValue , newValue ) -> moveMapCoordinateElementInMap ( id ) ; final ChangeListener < Boolean > v...
sets up the internal information about a MapCoordinate Element .
3,383
private void setMarkerVisibleInMap ( final String id ) { if ( null != id ) { final WeakReference < MapCoordinateElement > weakReference = mapCoordinateElements . get ( id ) ; if ( null != weakReference ) { final MapCoordinateElement mapCoordinateElement = weakReference . get ( ) ; if ( null != mapCoordinateElement ) { ...
sets the visibility of a MapCoordinateElement in the map .
3,384
private void moveMapCoordinateElementInMap ( final String id ) { if ( getInitialized ( ) && null != id ) { final WeakReference < MapCoordinateElement > weakReference = mapCoordinateElements . get ( id ) ; if ( null != weakReference ) { final MapCoordinateElement mapCoordinateElement = weakReference . get ( ) ; if ( nul...
adjusts the mapCoordinateElement s position in the map .
3,385
public MapView addMarker ( final Marker marker ) { if ( ! getInitialized ( ) ) { if ( logger . isWarnEnabled ( ) ) { logger . warn ( MAP_VIEW_NOT_YET_INITIALIZED ) ; } } else { if ( null == requireNonNull ( marker ) . getPosition ( ) ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "marker with no position was...
adds a marker to the map . If it was already added nothing is changed . If the MapView is not yet initialized a warning is logged and nothing changes . If the marker has no coordinate set it is not added and a logging entry is written .
3,386
@ SuppressWarnings ( "UnusedDeclaration" ) private String createDataURI ( final URL imageURL ) { return imgCache . computeIfAbsent ( imageURL , url -> { String dataUrl = null ; try ( final InputStream isGuess = url . openStream ( ) ; final InputStream isConvert = url . openStream ( ) ; final ByteArrayOutputStream os = ...
loads an image and converts it s data to a base64 encoded data url .
3,387
public void showLink ( final String href ) { if ( null != href && ! href . isEmpty ( ) ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "JS asks to browse to {}" , href ) ; } if ( ! Desktop . isDesktopSupported ( ) ) { if ( logger . isWarnEnabled ( ) ) { logger . warn ( "no desktop support for displaying {}" ,...
called when an a href in the map is clicked and shows the URL in the default browser .
3,388
private void processMarkerClicked ( final String name , final ClickType clickType ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "JS reports marker {} clicked {}" , name , clickType ) ; } synchronized ( mapCoordinateElements ) { if ( mapCoordinateElements . containsKey ( name ) ) { final MapCoordinateElement...
processes a marker click
3,389
private void processLabelClicked ( final String name , final ClickType clickType ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "JS reports label {} clicked {}" , name , clickType ) ; } synchronized ( mapCoordinateElements ) { if ( mapCoordinateElements . containsKey ( name ) ) { final MapCoordinateElement m...
called when a label was clicked .
3,390
public void zoomChanged ( double newZoom ) { final long roundedZoom = Math . round ( newZoom ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "JS reports zoom value {}" , roundedZoom ) ; } lastZoomFromMap . set ( roundedZoom ) ; setZoom ( roundedZoom ) ; }
called when the user changed the zoom with the controls in the map .
3,391
public void extentSelected ( double latMin , double lonMin , double latMax , double lonMax ) { final Extent extent = Extent . forCoordinates ( new Coordinate ( latMin , lonMin ) , new Coordinate ( latMax , lonMax ) ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "JS reports extend selected: {}" , extent ) ; }...
called when the user selected an extent by dragging the mouse with modifier pressed .
3,392
public void extentChanged ( double latMin , double lonMin , double latMax , double lonMax ) { final Extent extent = Extent . forCoordinates ( new Coordinate ( latMin , lonMin ) , new Coordinate ( latMax , lonMax ) ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "JS reports extend change: {}" , extent ) ; } fi...
called when the map extent changed by changing the center or zoom of the map .
3,393
public static Extent forCoordinates ( Collection < ? extends Coordinate > coordinates ) { requireNonNull ( coordinates ) ; if ( coordinates . size ( ) < 2 ) { throw new IllegalArgumentException ( ) ; } double minLatitude = Double . MAX_VALUE ; double maxLatitude = - Double . MAX_VALUE ; double minLongitude = Double . M...
creates the extent of the given coordinates .
3,394
private URLStreamHandler getURLStreamHandler ( final String protocol ) { try { final Method method = URL . class . getDeclaredMethod ( "getURLStreamHandler" , String . class ) ; method . setAccessible ( true ) ; return ( URLStreamHandler ) method . invoke ( null , protocol ) ; } catch ( final Exception e ) { if ( logge...
returns the URL class s stream handler for a protocol . this uses inspection .
3,395
public URLStreamHandler createURLStreamHandler ( final String protocol ) { if ( null == protocol ) { throw new IllegalArgumentException ( "null protocol not allowed" ) ; } if ( logger . isTraceEnabled ( ) ) { logger . trace ( "need to create URLStreamHandler for protocol {}" , protocol ) ; } final String proto = protoc...
default Handler for http and https .
3,396
public static Marker createProvided ( Provided provided ) { requireNonNull ( provided ) ; return new Marker ( Marker . class . getResource ( "/markers/" + provided . getFilename ( ) ) , provided . getOffsetX ( ) , provided . getOffsetY ( ) ) ; }
return a provided Marker with the given color .
3,397
public Marker attachLabel ( MapLabel mapLabel ) { optMapLabel = Optional . of ( requireNonNull ( mapLabel ) ) ; mapLabel . setMarker ( this ) ; mapLabel . visibleProperty ( ) . bind ( visibleProperty ( ) ) ; mapLabel . positionProperty ( ) . bind ( positionProperty ( ) ) ; return this ; }
attaches the MapLabel to this Marker
3,398
public Marker detachLabel ( ) { optMapLabel . ifPresent ( mapLabel -> { mapLabel . setMarker ( null ) ; mapLabel . visibleProperty ( ) . unbind ( ) ; mapLabel . positionProperty ( ) . unbind ( ) ; } ) ; optMapLabel = Optional . empty ( ) ; return this ; }
detaches an attached Label .
3,399
public Object parse ( SerializerHandler serializerHandler , InputStream response , boolean debugMode ) throws XMLRPCException { try { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; DocumentBuilder builder = factory . newDocumentBuilder ( ) ; Document d...
The given InputStream must contain the xml response from an xmlrpc server . This method extract the content of it as an object .