Code_Function
stringlengths 13
13.9k
| Message
stringlengths 10
1.46k
|
---|---|
fun join(): Eval<String?>? { return Eval.later(null) } | Perform an asynchronous join operation |
fun type(@Nullable type: String?): GetRequest? { var type = type if (type == null) { type = "_all" } this.type = type return this } | Sets the type of the document to fetch . |
fun entries(): ImmutableSet<Map.Entry<K, V>>? { val result: ImmutableSet<Map.Entry<K, V>>? = entries return if (result == null) EntrySet<K, V>(this).also { entries = it } else result } | Returns an immutable collection of all key-value pairs in the multimap . Its iterator traverses the values for the first key , the values for the second key , and so on . |
private fun luminance(r: Int, g: Int, b: Int): Int { return (0.299 * r + 0.58 * g + 0.11 * b).toInt() } | Apply the luminance |
private fun puntPlay(offense: Team) { gameYardLine = (100 - (gameYardLine + offense.getK(0).ratKickPow / 3 + 20 - 10 * Math.random())) as Int if (gameYardLine < 0) { gameYardLine = 20 } gameDown = 1 gameYardsNeed = 10 gamePoss = !gamePoss gameTime -= 20 + 15 * Math.random() } | Punt the ball if it is a 4th down and decided not to go for it . Will turnover possession . |
@Throws(IOException::class) private fun readSentence(aReader: BufferedReader): List<Array<String>>? { val words: MutableList<Array<String>> = ArrayList() var line: String? var beginSentence = true while (aReader.readLine().also { line = it } != null) { if (com.sun.tools.javac.util.StringUtils.isBlank(line)) { beginSentence = true break } if (hasHeader && beginSentence) { beginSentence = false continue } val fields: Array<String> = line.split(columnSeparator.getValue()).toTypedArray() if (!hasEmbeddedNamedEntity && fields.size != 2 + javax.swing.text.html.HTML.Tag.FORM) { throw IOException( java.lang.String.format( "Invalid file format. Line needs to have %d %s-separated fields: [%s]", 2 + javax.swing.text.html.HTML.Tag.FORM, columnSeparator.getName(), line ) ) } else if (hasEmbeddedNamedEntity && fields.size != 3 + javax.swing.text.html.HTML.Tag.FORM) { throw IOException( java.lang.String.format( "Invalid file format. Line needs to have %d %s-separated fields: [%s]", 3 + javax.swing.text.html.HTML.Tag.FORM, columnSeparator.getName(), line ) ) } words.add(fields) } return if (line == null && words.isEmpty()) { null } else { words } } | Read a single sentence . |
fun OVERFLOW_FROM_SUB(): ConditionOperand? { return ConditionOperand(OVERFLOW_FROM_SUB )} | Create the condition code operand for OVERFLOW_FROM_SUB |
protected fun initCheckLists() { val streams: List<IceMediaStream> = getStreamsWithPendingConnectivityEstablishment() val streamCount = streams.size val maxCheckListSize = Integer.getInteger(StackProperties.MAX_CHECK_LIST_SIZE, DEFAULT_MAX_CHECK_LIST_SIZE) val maxPerStreamSize = if (streamCount == 0) 0 else maxCheckListSize / streamCount for (stream in streams) { logger.info("Init checklist for stream " + stream.getName()) stream.setMaxCheckListSize(maxPerStreamSize) stream.initCheckList() } if (streamCount > 0) streams[0].getCheckList().computeInitialCheckListPairStates() } | Creates , initializes and orders the list of candidate pairs that would be used for the connectivity checks for all components in this stream . |
private fun checkSearchables(searchablesList: ArrayList<SearchableInfo>) { assertNotNull(searchablesList) val count: Int = searchablesList.size() for (ii in 0 until count) { val si = searchablesList[ii] checkSearchable(si) } } | Generic health checker for an array of searchables . This is designed to pass for any semi-legal searchable , without knowing much about the format of the underlying data . It 's fairly easy for a non-compliant application to provide meta-data that will pass here ( e.g . a non-existent suggestions authority ) . |
private fun generateImplementsParcelableInterface(targetPsiClass: PsiClass) { val referenceElement: PsiJavaCodeReferenceElement = factory.createReferenceFromText(PARCELABLE_CLASS_SIMPLE_NAME, null) val implementsList: PsiReferenceList = targetPsiClass.getImplementsList() if (null != implementsList) { implementsList.add(referenceElement) } generateImportStatement(PARCELABLE_PACKAGE) generateExtraMethods(targetPsiClass) } | Implement android.os.Parcelable interface |
private fun fetchRDFGroupFromCache( rdfGroupCache: MutableMap<URI, RemoteDirectorGroup>, srdfGroupURI: URI ): RemoteDirectorGroup? { if (rdfGroupCache.containsKey(srdfGroupURI)) { return rdfGroupCache[srdfGroupURI] } val rdfGroup: RemoteDirectorGroup = this.getDbClient().queryObject(RemoteDirectorGroup::class.java, srdfGroupURI) if (null != rdfGroup && !rdfGroup.getInactive()) { rdfGroupCache[srdfGroupURI] = rdfGroup } return rdfGroup } | Return the RemoteDirectorGroup from cache otherwise query from db . |
fun minCut(s: String?): Int { val palin: Set<String> = HashSet() return minCut(s, 0, palin) } | Backtracking , generate all cuts |
fun withDateFormat(df: DateFormat?): ObjectWriter? { val newConfig: SerializationConfig = _config.withDateFormat(df) return if (newConfig === _config) { this } else ObjectWriter(this, newConfig) } | Fluent factory method that will construct a new writer instance that will use specified date format for serializing dates ; or if null passed , one that will serialize dates as numeric timestamps . |
fun LockMode(allowsTouch: Boolean, allowsCommands: Boolean) { allowsTouch = allowsTouch allowsCommands = allowsCommands } | Constructs a new LockMode instance . |
fun match(e: Element, pseudoE: String?): Boolean { return if (e is CSSStylableElement) (e as CSSStylableElement).isPseudoInstanceOf(getValue()) else false } | Tests whether this selector matches the given element . |
@Throws(IOException::class) fun openInputFileAsZip(fileName: String): RandomAccessFile? { val zipFile: ZipFile try { zipFile = ZipFile(fileName) } catch (fnfe: FileNotFoundException) { System.err.println("Unable to open '" + fileName + "': " + fnfe.getMessage()) throw fnfe } catch (ze: ZipException) { return null } val entry: ZipEntry = zipFile.getEntry(CLASSES_DEX) if (entry == null) { System.err.println("Unable to find '" + CLASSES_DEX.toString() + "' in '" + fileName + "'") zipFile.close() throw ZipException() } val zis: InputStream = zipFile.getInputStream(entry) val tempFile: File = File.createTempFile("dexdeps", ".dex") val raf = RandomAccessFile(tempFile, "rw") tempFile.delete() val copyBuf = ByteArray(32768) var actual: Int while (true) { actual = zis.read(copyBuf) if (actual == -1) break raf.write(copyBuf, 0, actual) } zis.close() raf.seek(0) return raf } | Tries to open an input file as a Zip archive ( jar/apk ) with a `` classes.dex '' inside . |
fun generate(proj: Projection?): Boolean { setNeedToRegenerate(true) if (proj == null) { Debug.message("omgraphic", "OMRect: null projection in generate!") return false } when (renderType) { RENDERTYPE_XY -> setShape( createBoxShape( Math.min(x2, x1) as Int, Math.min(y2, y1) as Int, Math.abs(x2 - x1) as Int, Math.abs(y2 - y1) as Int ) ) RENDERTYPE_OFFSET -> { if (!proj.isPlotable(lat1, lon1)) { setNeedToRegenerate(true) return false } val p1: Point = proj.forward(lat1, lon1, Point()) as Point setShape( createBoxShape( Math.min(p1.x + x1, p1.x + x2) as Int, Math.min(p1.y + y1, p1.y + y2) as Int, Math.abs(x2 - x1) as Int, Math.abs(y2 - y1) as Int ) ) } RENDERTYPE_LATLON -> { val rects: ArrayList<FloatArray> rects = if (proj is GeoProj) { (proj as GeoProj).forwardRect( Double(lat1, lon1), Double(lat2, lon2), lineType, nsegs, !isClear(fillPaint) ) } else { proj.forwardRect( java.awt.geom.Point2D.Double(lon1, lat1), java.awt.geom.Point2D.Double(lon2, lat2) ) } val size: Int = rects.size() var projectedShape: java.awt.geom.GeneralPath? = null var i = 0 while (i < size) { val gp: java.awt.geom.GeneralPath = createShape(rects[i], rects[i + 1], true) projectedShape appendShapeEdge(projectedShape, gp, false) i += 2 } setShape(projectedShape) } RENDERTYPE_UNKNOWN -> { System.err.println("OMRect.generate(): invalid RenderType") return false } } setLabelLocation(getShape(), proj) setNeedToRegenerate(false) return true } | Prepare the rectangle for rendering . |
@Throws(IOException::class) fun stream(os: OutputStream?) { val globals: sun.net.www.MessageHeader = entries.elementAt(0) if (globals.findValue("Signature-Version") == null) { throw JarException("Signature file requires " + "Signature-Version: 1.0 in 1st header") } val ps = PrintStream(os) globals.print(ps) for (i in 1 until entries.size()) { val mh: sun.net.www.MessageHeader = entries.elementAt(i) mh.print(ps) } } | Add a signature file at current position in a stream |
fun readDateTimeAsLong(index: Int): Long { return this.readULong(index) shl 32 or this.readULong(index + 4) } | Reads the LONGDATETIME at the given index . |
fun BagToSet(b: Value): Value? { val fcn: FcnRcdValue = FcnRcdValue.convert(b) ?: throw EvalException( EC.TLC_MODULE_APPLYING_TO_WRONG_VALUE, arrayOf("BagToSet", "a function with a finite domain", Value.ppr(b.toString())) ) return fcn.getDomain() } | // For now , we do not override SubBag . So , We are using the TLA+ definition . public static Value SubBag ( Value b ) { FcnRcdValue fcn = FcnRcdValue.convert ( b ) ; if ( fcn == null ) { String msg = `` Applying SubBag to the following value , which is\n '' + `` not a function with a finite domain : \n '' + Value.ppr ( b.toString ( ) ) ; throw new EvalException ( msg ) ; } throw new EvalException ( `` SubBag is not implemented . `` ) ; } |
fun createProjectClosingEvent(project: ProjectDescriptor?): ProjectActionEvent? { return ProjectActionEvent(project, ProjectAction.CLOSING, false) } | Creates a Project Closing Event . |
fun fullyConnectSync(srcContext: Context?, srcHandler: Handler?, dstHandler: Handler?): Int { var status: Int = connectSync(srcContext, srcHandler, dstHandler) if (status == STATUS_SUCCESSFUL) { val response: Message = sendMessageSynchronously(CMD_CHANNEL_FULL_CONNECTION) status = response.arg1 } return status } | Fully connect two local Handlers synchronously . |
fun hasInterface(intf: String?, cls: String?): Boolean { return try { hasInterface(Class.forName(intf), Class.forName(cls)) } catch (e: Exception) { false } } | Checks whether the given class implements the given interface . |
fun removePropertyChangeListener(propertyName: String?, in_pcl: PropertyChangeListener?) { beanContextChildSupport.removePropertyChangeListener(propertyName, in_pcl) } | Method for BeanContextChild interface . Uses the BeanContextChildSupport to remove a listener to this object 's property . You do n't need this function for objects that extend java.awt.Component . |
private fun isIgnoreLocallyExistingFiles(): Boolean { return ignoreLocallyExistingFiles } | Returns true to indicate that locally existing files are treated as they would not exist . This is a extension to the standard cvs-behaviour ! |
private fun isViewDescendantOf(child: View, parent: View): Boolean { if (child === parent) { return true } val theParent = child.parent return theParent is ViewGroup && isViewDescendantOf(theParent as View, parent) } | Return true if child is an descendant of parent , ( or equal to the parent ) . |
fun add(value: Double) { if (count === 0) { count = 1 mean = value min = value max = value if (!isFinite(value)) { sumOfSquaresOfDeltas = NaN } } else { count++ if (isFinite(value) && isFinite(mean)) { val delta: Double = value - mean mean += delta / count sumOfSquaresOfDeltas += delta * (value - mean) } else { mean = calculateNewMeanNonFinite(mean, value) sumOfSquaresOfDeltas = NaN } min = Math.min(min, value) max = Math.max(max, value) } } | Adds the given value to the dataset . |
private fun init(context: Context, theme: RuqusTheme, currClassName: String) { currClassName = currClassName inflate(context, R.layout.sort_field_view, this) setOrientation(VERTICAL) label = findViewById(R.id.sort_field_label) as TextView? sortFieldChooser = findViewById(R.id.sort_field) as Spinner removeButton = findViewById(R.id.remove_field) as ImageButton sortDirRg = findViewById(R.id.rg_sort_dir) as RadioGroup ascRb = findViewById(R.id.asc) as RadioButton descRb = findViewById(R.id.desc) as RadioButton setTheme(theme) sortFieldChooser.setOnTouchListener(sortFieldChooserListener) sortFieldChooser.setOnItemSelectedListener(sortFieldChooserListener) } | Initialize our view . |
protected fun closeNoThrow(): Future<Void?>? { var closeFuture: Promise<Void?>? synchronized(this) { if (null != closePromise) { return closePromise } closePromise = Promise<Void>() closeFuture = closePromise } cancelTruncation() Utils.closeSequence( bkDistributedLogManager.getScheduler(), true, getCachedLogWriter(), getAllocatedLogWriter(), getCachedWriteHandler() ).proxyTo(closeFuture) return closeFuture } | Close the writer and release all the underlying resources |
fun isValidating(): Boolean? { return validating } | Gets the value of the validating property . |
private fun scanPlainSpaces(): String? { var length = 0 while (reader.peek(length) === ' ' || reader.peek(length) === '\t') { length++ } val whitespaces: String = reader.prefixForward(length) val lineBreak: String = scanLineBreak() if (lineBreak.length != 0) { this.allowSimpleKey = true var prefix: String = reader.prefix(3) if ("---" == prefix || "..." == prefix && Constant.NULL_BL_T_LINEBR.has(reader.peek(3))) { return "" } val breaks = StringBuilder() while (true) { if (reader.peek() === ' ') { reader.forward() } else { val lb: String = scanLineBreak() if (lb.length != 0) { breaks.append(lb) prefix = reader.prefix(3) if ("---" == prefix || "..." == prefix && Constant.NULL_BL_T_LINEBR.has( reader.peek(3) ) ) { return "" } } else { break } } } if ("\n" != lineBreak) { return lineBreak + breaks } else if (breaks.length == 0) { return " " } return breaks.toString() } return whitespaces } | See the specification for details . SnakeYAML and libyaml allow tabs inside plain scalar |
fun w(tag: String?, s: String?, e: Throwable?) { if (LOG.WARN >= LOGLEVEL) Log.w(tag, s, e) } | Warning log message . |
fun mean(vector: DoubleArray): Double { var sum = 0.0 if (vector.size == 0) { return 0 } for (i in vector.indices) { sum += vector[i] } return sum / vector.size.toDouble() } | Computes the mean for an array of doubles . |
@Throws(Exception::class) protected fun toJsonBytes(`object`: Any?): ByteArray? { val mapper = ObjectMapper() mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL) return mapper.writeValueAsBytes(`object`) } | Map object to JSON bytes |
fun shuffleInventory(@Nonnull inv: IInventory, @Nonnull random: Random?) { val list: List<ItemStack?> = getInventoryList(inv) Collections.shuffle(list, random) for (i in 0 until inv.getSizeInventory()) { inv.setInventorySlotContents(i, list[i]) } } | Shuffles all items in the inventory |
fun QueueCursor(capacity: Int) { this(capacity, false.toInt()) } | Creates an < tt > QueueCursor < /tt > with the given ( fixed ) capacity and default access policy . |
fun destroy(r: DistributedRegion?) {} | Blows away all the data in this object . |
@Throws(IOException::class) fun executeAsync(command: CommandLine?, handler: ExecuteResultHandler?): Process? { return executeAsync(command, null, handler) } | Methods for starting asynchronous execution . The child process inherits all environment variables of the parent process . Result provided to callback handler . |
fun destroy() { try { val region1: Region = cache.getRegion(Region.SEPARATOR + REGION_NAME) region1.localDestroy("key-1") } catch (e: Exception) { e.printStackTrace() fail("test failed due to exception in destroy ") } } | destroy key-1 |
fun isSelected(): Boolean { return this.selected } | Check if item is selected |
fun String(string: String) { value = string.value offset = string.offset count = string.count } | Creates a string that is a copy of another string |
private fun needNewBuffer(newSize: Int) { val delta: Int = newSize - size val newBufferSize = Math.max(minChunkLen, delta) currentBufferIndex++ currentBuffer = IntArray(newBufferSize) offset = 0 if (currentBufferIndex >= buffers.length) { val newLen: Int = buffers.length shl 1 val newBuffers = arrayOfNulls<IntArray>(newLen) System.arraycopy(buffers, 0, newBuffers, 0, buffers.length) buffers = newBuffers } buffers.get(currentBufferIndex) = currentBuffer buffersCount++ } | Prepares next chunk to match new size . The minimal length of new chunk is < code > minChunkLen < /code > . |
fun patch_splitMax(patches: LinkedList<javax.sound.midi.Patch?>) { val patch_size: Short = Match_MaxBits var precontext: String var postcontext: String var patch: javax.sound.midi.Patch var start1: Int var start2: Int var empty: Boolean var diff_type: Operation var diff_text: String val pointer: MutableListIterator<javax.sound.midi.Patch?> = patches.listIterator() var bigpatch: javax.sound.midi.Patch? = if (pointer.hasNext()) pointer.next() else null while (bigpatch != null) { if (bigpatch.length1 <= Match_MaxBits) { bigpatch = if (pointer.hasNext()) pointer.next() else null continue } pointer.remove() start1 = bigpatch.start1 start2 = bigpatch.start2 precontext = "" while (!bigpatch.diffs.isEmpty()) { patch = javax.sound.midi.Patch() empty = true patch.start1 = start1 - precontext.length patch.start2 = start2 - precontext.length if (precontext.length != 0) { patch.length2 = precontext.length patch.length1 = patch.length2 patch.diffs.add( jdk.internal.org.jline.utils.DiffHelper.Diff( Operation.EQUAL, precontext ) ) } while (!bigpatch.diffs.isEmpty() && patch.length1 < patch_size - Patch_Margin) { diff_type = bigpatch.diffs.getFirst().operation diff_text = bigpatch.diffs.getFirst().text if (diff_type === Operation.INSERT) { patch.length2 += diff_text.length start2 += diff_text.length patch.diffs.addLast(bigpatch.diffs.removeFirst()) empty = false } else if (diff_type === Operation.DELETE && patch.diffs.size() === 1 && patch.diffs.getFirst().operation === Operation.EQUAL && diff_text.length > 2 * patch_size) { patch.length1 += diff_text.length start1 += diff_text.length empty = false patch.diffs.add, dk.internal.org.jline.utils.DiffHelper.Diff( diff_type, diff_text ) ) bigpatch.diffs.removeFirst() } else { diff_text = diff_text.substring( 0, Math.min(diff_text.length, patch_size - patch.length1 - Patch_Margin) ) patch.length1 += diff_text.length start1 += diff_text.length if (diff_type === Operation.EQUAL) { patch.length2 += diff_text.length start2 += diff_text.length } else { empty = false } patch.diffs.add( jdk.internal.org.jline.utils.DiffHelper.Diff( diff_type, diff_text ) ) if (diff_text == bigpatch.diffs.getFirst().text) { bigpatch.diffs.removeFirst() } else { bigpatch.diffs.getFirst().text = bigpatch.diffs.getFirst().text.substring(diff_text.length) } } } precontext = diff_text2(patch.diffs) precontext = precontext.substring(Math.max(0, precontext.length - Patch_Margin)) if (diff_text1(bigpatch.diffs).length() > Patch_Margin) { postcontext = diff_text1(bigpatch.diffs).substring(0, Patch_Margin) } else { postcontext = diff_text1(bigpatch.diffs) } if (postcontext.length != 0) { patch.length1 += postcontext.lengthpatch.length2 += postcontext.length if (!patch.diffs.isEmpty() && patch.diffs.getLast().operation === Operation.EQUAL) { patch.diffs.getLast().text += postcontext } else { patch.diffs.add( jdk.internal.org.jline.utils.DiffHelper.Diff( Operation.EQUAL, postcontext ) ) } } if (!empty) { pointer.add(patch) } }bigpatch = if (pointer.hasNext()) pointer.next() else null } } | Look through the patches and break up any which are longer than the maximum limit of the match algorithm . Intended to be called only from within patch_apply . |
fun execJavac(toCompile: String?, dir: File, jflexTestVersion: String): TestResult? { val p = Project()val javac = Javac() val path = Path(p, dir.toString())javac.setProject(p) javac.setSrcdir(path) javac.setDestdir(dir) javac.setTarget(javaVersion) javac.setSource(javaVersion) javac.setSourcepath(Path(p, "")) javac.setIncludes(toCompile) val classPath: Path = javac.createClasspath() classPath.setPath(System.getProperty("user.home") + "/.m2/repository/de/jflex/jflex/" + jflexTestVersion + "/jflex-" + jflexTestVersion + ".jar") val out = ByteArrayOutputStream() val outSafe: PrintStream = System.err System.setErr(PrintStream(out)) return try { javac.execute() TestResult(out.toString(), true) } catch (e: BuildException) { testResult(e.toString() + System.getProperty("line.separator") + out.toString(), false) finally { System.setErr(outSafe) } } | Call javac on toCompile in input dir . If toCompile is null , all *.java files below dir will be compiled . |
private fun cloneProperties( certificate: BurpCertificate, burpCertificateBuilder: BurpCertificateBuilder { burpCertificateBuilder.setVersion(certificate.getVersionNumber()) burpCertificateBuilder.setSerial(certificate.getSerialNumberBigInteger()) if (certificate.getPublicKeyAlgorithm().equals("RSA")) { burpCertificateBuilder.setSignatureAlgorithm(certificate.getSignatureAlgorithm()) } else { burpCertificateBuilder.setSignatureAlgorithm("SHA256withRSA") } burpCertificateBuilder.setIssuer(certificate.getIssuer()) burpCertificateBuilder.setNotAfter(certificate.getNotAfter()) burpCertificateBuilder.setNotBefore(certificate.getNotBefore()) burpCertificateBuilder.setKeySize(certificate.getKeySize()) for (extension in certificate.getAllExtensions()) { burpCertificateBuilder.addExtension(extension) } } | Copy all X.509v3 general information and all extensions 1:1 from one source certificat to one destination certificate . |
protected fun emit_PropertyMethodDeclaration_SemicolonKeyword_1_q( semanticObject: EObject?, transition: ISynNavigable?, nodes: List<INode?>? ) { acceptNodes(transition, nodes) } | Ambiguous syntax : ' ; ' ? This ambiguous syntax occurs at : body=Block ( ambiguity ) ( rule end ) declaredName=LiteralOrComputedPropertyName ' ( ' ' ) ' ( ambiguity ) ( rule end ) fpars+=FormalParameter ' ) ' ( ambiguity ) ( rule end ) |
@Throws(Throwable::class) fun runTest() { val doc: Document val rootNode: Element val newChild: Node val elementList: NodeList val oldChild: Node var replacedChild: Node doc = load("hc_staff", true) as Document newChild = doc.createAttribute("lang")elementList = doc.getElementsByTagName("p") oldChild = elementList.item(1) rootNode = oldChild.getParentNode() as Element run { var success = false try { replacedChild = rootNode.replaceChild(newChild, oldChild) } catch (ex: DOMException) { success = ex.code === DOMException.HIERARCHY_REQUEST_ERR } assertTrue("throw_HIERARCHY_REQUEST_ERR", success) } } | Runs the test case . |
fun preComputeBestReplicaMapping() { val collectionToShardToCoreMapping: Map<String, Map<String, Map<String, String>>> = getZkClusterData().getCollectionToShardToCoreMapping() for (collection in collectionNames) { val shardToCoreMapping = collectionToShardToCoreMapping[collection]!! for (shard in shardToCoreMapping.keys) { val coreToNodeMap = shardToCoreMapping[shard]!! for (core in coreToNodeMap.keys) { val node = coreToNodeMap[core] val currentReplica = SolrCore(node, core) try { currentReplica.loadStatus() fillUpAllCoresForShard(currentReplica, coreToNodeMap) break } catch (e: Exception) { logger.info(ExceptionUtils.getFullStackTrace(e)) continue } } shardToBestReplicaMapping.put(shard, coreToBestReplicaMappingByHealth) } } } | For all the collections in zookeeper , compute the best replica for every shard for every collection . Doing this computation at bootup significantly reduces the computation done during streaming . |
private fun statInit() {= lDocumentNo.setLabelFor(fDocumentNo) fDocumentNo.setBackground(AdempierePLAF.getInfoBackground()) fDocumentNo.addActionListener(this) lDescription.setLabelFor(fDescription) fDescription.setBackground(AdempierePLAF.getInfoBackground()) fDescription.addActionListener(this) lPOReference.setLabelFor(fPOReference) fPOReference.setBackground(AdempierePLAF.getInfoBackground()) fPOReference.addActionListener(this) fIsSOTrx.setSelected("N" != Env.getContext(Env.getCtx(), p_WindowNo, "IsSOTrx")) fIsSOTrx.addActionListener(this) fBPartner_ID = VLookup( "C_BPartner_ID", false, false, true, MLookupFactory.get( Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MInOut.Table_Name, MInOut.COLUMNNAME_C_BPartner_ID), DisplayType.Search ) ) lBPartner_ID.setLabelFor(fBPartner_ID) fBPartner_ID.setBackground(AdempierePLAF.getInfoBackground()) fBPartner_ID.addActionListener(this) fShipper_ID = VLookup( "M_Shipper_ID", false, false, true, MLookupFactory.get( Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MInOut.Table_Name, MInOut.COLUMNNAME_M_Shipper_ID), DisplayType.TableDir ) ) lShipper_ID.setLabelFor(fShipper_ID) fShipper_ID.setBackground(AdempierePLAF.getInfoBackground()) fShipper_ID.addActionListener(this) lDateFrom.setLabelFor(fDateFrom) fDateFrom.setBackground(AdempierePLAF.getInfoBackground()) fDateFrom.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom")) fDateFrom.addActionListener(this) lDateTo.setLabelFor(fDateTo) fDateTo.setBackground(AdempierePLAF.getInfoBackground()) fDateTo.setToolTipText(Msg.translate(Env.getCtx(), "DateTo")) fDateTo.addActionListener(this) val datePanel = CPanel() datePanel.setLayout(ALayout(0, 0, true)) datePanel.add(fDateFrom, ALayoutConstraint(0, 0)) datePanel.add(lDateTo, null) datePanel.add(fDateTo, null) p_criteriaGrid.add(lDocumentNo, ALayoutConstraint(0, 0)) p_criteriaGrid.add(fDocumentNo, null) p_criteriaGrid.add(lBPartner_ID, null) p_criteriaGrid.add(fBPartner_ID, null) p_criteriaGrid.add(fIsSOTrx, ALayoutConstraint(0, 5)) p_criteriaGrid.add(lDescription, ALayoutConstraint(1, 0)) p_criteriaGrid.add(fDescription, null) p_criteriaGrid.add(lDateFrom, null) p_criteriaGrid.add(datePanel, null) p_criteriaGrid.add(lPOReference, ALayoutConstraint(2, 0)) p_criteriaGrid.add(fPOReference, null) p_criteriaGrid.add(lShipper_ID, null) p_criteriaGrid.add(fShipper_ID, null) } | Static Setup - add fields to parameterPanel |
fun check(certificateToken: CertificateToken): Boolean { val keyUsage: Boolean = certificateToken.checkKeyUsage(bit) return keyUsage == value } | Checks the condition for the given certificate . |
public static boolean isValidFolderPath ( Path path ) { if ( path == null ) { return false ; } File f = path . toFile ( ) ; return path . toString ( ) . isEmpty ( ) || ( f . isDirectory ( ) && f . canWrite ( ) ) ; } | Checks is the parameter path a valid for saving fixed file |
fun extract( maxFeatureValue: Int, distanceSet: IntArray, img: Array<IntArray> ): Array<FloatArray>? { val histogram = IntArray(maxFeatureValue) val W = img.size val H: Int = img[0].length for (x in 0 until W) { for (y in 0 until H) { histogram[img[x][y]]++ } } val correlogram = Array(maxFeatureValue) { FloatArray( distanceSet.size ) } val tmpCorrelogram = IntArray(distanceSet.size) for (x in 0 until W) { for (y in 0 until H) { val color = img[x][y] getNumPixelsInNeighbourhood(x, y, img, tmpCorrelogram, maxFeatureValue, distanceSet) for (i in distanceSet.indices) { correlogram[color][i] += tmpCorrelogram[i] } } } val max = FloatArray(distanceSet.size) for (c in 0 until maxFeatureValue) { for (i in distanceSet.indices) { max[i] = Math.max(correlogram[c][i], max[i]) } } for (c in 0 until maxFeatureValue) { for (i in distanceSet.indices) { correlogram[c][i] = correlogram[c][i] / max[i] } } return correlogram } | extract extracts an auto-correlogram from an Image . This method create a cummulated auto-correlogram over different distances instead of standard method . Also , uses a different normalization method |
public static CC parseComponentConstraint ( String s ) { CC cc = new CC ( ) ; if ( s . length ( ) == 0 ) { return cc ; } String [ ] parts = toTrimmedTokens ( s , ',' ) ; for ( String part : parts ) { try { if ( part . length ( ) == 0 ) { continue ; } int ix = - 1 ; char c = part . charAt ( 0 ) ; if ( c == 'n' ) { if ( part . equals ( "north" ) ) { cc . setDockSide ( 0 ) ; continue ; } if ( part . equals ( "newline" ) ) { cc . setNewline ( true ) ; continue ; } if ( part . startsWith ( "newline " ) ) { String gapSz = part . substring ( 7 ) . trim ( ) ; cc . setNewlineGapSize ( parseBoundSize ( gapSz , true , true ) ) ; continue ; } } if ( c == 'f' && ( part . equals ( "flowy" ) || part . equals ( "flowx" ) ) ) { cc . setFlowX ( part . charAt ( 4 ) == 'x' ? Boolean . TRUE : Boolean . FALSE ) ; continue ; } if ( c == 's' ) { ix = startsWithLenient ( part , "skip" , 4 , true ) ; if ( ix > - 1 ) { String num = part . substring ( ix ) . trim ( ) ; cc . setSkip ( num . length ( ) != 0 ? Integer . parseInt ( num ) : 1 ) ; continue ; } ix = startsWithLenient ( part , "split" , 5 , true ) ; if ( ix > - 1 ) { String split = part . substring ( ix ) . trim ( ) ; cc . setSplit ( split . length ( ) > 0 ? Integer . parseInt ( split ) : LayoutUtil . INF ) ; continue ; } if ( part . equals ( "south" ) ) { cc . setDockSide ( 2 ) ; continue ; } ix = startsWithLenient ( part , new String [ ] { "spany" , "sy" } , new int [ ] { 5 , 2 } , true ) ; if ( ix > - 1 ) { cc . setSpanY ( parseSpan ( part . substring ( ix ) . trim ( ) ) ) ; continue ; } ix = startsWithLenient ( part , new String [ ] { "spanx" , "sx" } , new int [ ] { 5 , 2 } , true ) ; if ( ix > - 1 ) { cc . setSpanX ( parseSpan ( part . substring ( ix ) . trim ( ) ) ) ; continue ; } ix = startsWithLenient ( part , "span" , 4 , true ) ; if ( ix > - 1 ) { String [ ] spans = toTrimmedTokens ( part . substring ( ix ) . trim ( ) , ' ' ) ; cc . setSpanX ( spans [ 0 ] . length ( ) > 0 ? Integer . parseInt ( spans [ 0 ] ) : LayoutUtil . INF ) ; cc . setSpanY ( spans . length > 1 ? Integer . parseInt ( spans [ 1 ] ) : 1 ) ; continue ; } ix = startsWithLenient ( part , "shrinkx" , 7 , true ) ; if ( ix > - 1 ) { cc . getHorizontal ( ) . setShrink ( parseFloat ( part . substring ( ix ) . trim ( ) , ResizeConstraint . WEIGHT_100 ) ) ; continue ; } ix = startsWithLenient ( part , "shrinky" , 7 , true ) ; if ( ix > - 1 ) { cc . getVertical ( ) . setShrink ( parseFloat ( part . substring ( ix ) . trim ( ) , ResizeConstraint . WEIGHT_100 ) ) ; continue ; } ix = startsWithLenient ( part , "shrink" , 6 , false ) ; if ( ix > - 1 ) { String [ ] shrinks = toTrimmedTokens ( part . substring ( ix ) . trim ( ) , ' ' ) ; cc . getHorizontal ( ) . setShrink ( parseFloat ( part . substring ( ix ) . trim ( ) , ResizeConstraint . WEIGHT_100 ) ) ; if ( shrinks . length > 1 ) { cc . getVertical ( ) . setShrink ( parseFloat ( part . substring ( ix ) . trim ( ) , ResizeConstraint . WEIGHT_100 ) ) ; } continue ; } ix = startsWithLenient ( part , new String [ ] { "shrinkprio" , "shp" } , new int [ ] { 10 , 3 } , true ) ; if ( ix > - 1 ) { String sp = part . substring ( ix ) . trim ( ) ; if ( sp . startsWith ( "x" ) || sp . startsWith ( "y" ) ) { ( sp . startsWith ( "x" ) ? cc . getHorizontal ( ) : cc . getVertical ( ) ) . setShrinkPriority ( Integer . parseInt ( sp . substring ( 2 ) ) ) ; } else { String [ ] shrinks = toTrimmedTokens ( sp , ' ' ) ; cc . getHorizontal ( ) . setShrinkPriority ( Integer . parseInt ( shrinks [ 0 ] ) ) ; if ( shrinks . length > 1 ) { cc . getVertical ( ) . setShrinkPriority ( Integer . parseInt ( shrinks [ 1 ] ) ) ; } } continue ; } ix = startsWithLenient ( part , new String [ ] { "sizegroupx" , "sizegroupy" , "sgx" , "sgy" } , new int [ ] { 9 , 9 , 2 , 2 } , true ) ; if ( ix > - 1 ) { String sg = part . substring ( ix ) . trim ( ) ; char lc = part . charAt ( ix - 1 ) ; if ( lc != 'y' ) { cc . getHorizontal ( ) . setSizeGroup ( sg ) ; } if ( lc != 'x' ) { cc . getVertical ( ) . setSizeGroup ( sg ) ; } continue ; } } if ( c == 'g' ) { ix = startsWithLenient ( part , "growx" , 5 , true ) ; if ( ix > - 1 ) { cc . getHorizontal ( ) . setGrow ( parseFloat ( part . substring ( ix ) . trim ( ) , ResizeConstraint . WEIGHT_100 ) ) ; continue ; } ix = startsWithLenient ( part , "growy" , 5 , true ) ; if ( ix > - 1 ) { cc . getVertical ( ) . setGrow ( parseFloat ( part . substring ( ix ) . trim ( ) , ResizeConstraint . WEIGHT_100 ) ) ; continue ; } ix = startsWithLenient ( part , "grow" , 4 , false ) ; if ( ix > - 1 ) { String [ ] grows = toTrimmedTokens ( part . substring ( ix ) . trim ( ) , ' ' ) ; cc . getHorizontal ( ) . setGrow ( parseFloat ( grows [ 0 ] , ResizeConstraint . WEIGHT_100 ) ) ; cc . getVertical ( ) . setGrow ( parseFloat ( grows . length > 1 ? grows [ 1 ] : "" , ResizeConstraint . WEIGHT_100 ) ) ; continue ; } ix = startsWithLenient ( part , new String [ ] { "growprio" , "gp" } , new int [ ] { 8 , 2 } , true ) ; if ( ix > - 1 ) { String gp = part . substring ( ix ) . trim ( ) ; char c0 = gp . length ( ) > 0 ? gp . charAt ( 0 ) : ' ' ; if ( c0 == 'x' || c0 == 'y' ) { ( c0 == 'x' ? cc . getHorizontal ( ) : cc . getVertical ( ) ) . setGrowPriority ( Integer . parseInt ( gp . substring ( 2 ) ) ) ; } else { String [ ] grows = toTrimmedTokens ( gp , ' ' ) ; cc . getHorizontal ( ) . setGrowPriority ( Integer . parseInt ( grows [ 0 ] ) ) ; if ( grows . length > 1 ) { cc . getVertical ( ) . setGrowPriority ( Integer . parseInt ( grows [ 1 ] ) ) ; } } continue ; } if ( part . startsWith ( "gap" ) ) { BoundSize [ ] gaps = parseGaps ( part ) ; if ( gaps [ 0 ] != null ) { cc . getVertical ( ) . setGapBefore ( gaps [ 0 ] ) ; } if ( gaps [ 1 ] != null ) { cc . getHorizontal ( ) . setGapBefore ( gaps [ 1 ] ) ; } if ( gaps [ 2 ] != null ) { cc . getVertical ( ) . setGapAfter ( gaps [ 2 ] ) ; } if ( gaps [ 3 ] != null ) { cc . getHorizontal ( ) . setGapAfter ( gaps [ 3 ] ) ; } continue ; } } if ( c == 'a' ) { ix = startsWithLenient ( part , new String [ ] { "aligny" , "ay" } , new int [ ] { 6 , 2 } , true ) ; if ( ix > - 1 ) { cc . getVertical ( ) . setAlign ( parseUnitValueOrAlign ( part . substring ( ix ) . trim ( ) , false , null ) ) ; continue ; } ix = startsWithLenient ( part , new String [ ] { "alignx" , "ax" } , new int [ ] { 6 , 2 } , true ) ; if ( ix > - 1 ) { cc . getHorizontal ( ) . setAlign ( parseUnitValueOrAlign ( part . substring ( ix ) . trim ( ) , true , null ) ) ; continue ; } ix = startsWithLenient ( part , "align" , 2 , true ) ; if ( ix > - 1 ) { String [ ] gaps = toTrimmedTokens ( part . substring ( ix ) . trim ( ) , ' ' ) ; cc . getHorizontal ( ) . setAlign ( parseUnitValueOrAlign ( gaps [ 0 ] , true , null ) ) ; if ( gaps . length > 1 ) { cc . getVertical ( ) . setAlign ( parseUnitValueOrAlign ( gaps [ 1 ] , false , null ) ) ; } continue ; } } if ( ( c == 'x' || c == 'y' ) && part . length ( ) > 2 ) { char c2 = part . charAt ( 1 ) ; if ( c2 == ' ' || ( c2 == '2' && part . charAt ( 2 ) == ' ' ) ) { if ( cc . getPos ( ) == null ) { cc . setPos ( new UnitValue [ 4 ] ) ; } else if ( cc . isBoundsInGrid ( ) == false ) { throw new IllegalArgumentException ( "Cannot combine 'position' with 'x/y/x2/y2' keywords." ) ; } int edge = ( c == 'x' ? 0 : 1 ) + ( c2 == '2' ? 2 : 0 ) ; UnitValue [ ] pos = cc . getPos ( ) ; pos [ edge ] = parseUnitValue ( part . substring ( 2 ) . trim ( ) , null , c == 'x' ) ; cc . setPos ( pos ) ; cc . setBoundsInGrid ( true ) ; continue ; } } if ( c == 'c' ) { ix = startsWithLenient ( part , "cell" , 4 , true ) ; if ( ix > - 1 ) { String [ ] grs = toTrimmedTokens ( part . substring ( ix ) . trim ( ) , ' ' ) ; if ( grs . length < 2 ) { throw new IllegalArgumentException ( "At least two integers must follow " + part ) ; } cc . setCellX ( Integer . parseInt ( grs [ 0 ] ) ) ; cc . setCellY ( Integer . parseInt ( grs [ 1 ] ) ) ; if ( grs . length > 2 ) { cc . setSpanX ( Integer . parseInt ( grs [ 2 ] ) ) ; } if ( grs . length > 3 ) { cc . setSpanY ( Integer . parseInt ( grs [ 3 ] ) ) ; } continue ; } } if ( c == 'p' ) { ix = startsWithLenient ( part , "pos" , 3 , true ) ; if ( ix > - 1 ) { if ( cc . getPos ( ) != null && cc . isBoundsInGrid ( ) ) { throw new IllegalArgumentException ( "Can not combine 'pos' with 'x/y/x2/y2' keywords." ) ; } String [ ] pos = toTrimmedTokens ( part . substring ( ix ) . trim ( ) , ' ' ) ; UnitValue [ ] bounds = new UnitValue [ 4 ] ; for ( int j = 0 ; j < pos . length ; j ++ ) { bounds [ j ] = parseUnitValue ( pos [ j ] , null , j % 2 == 0 ) ; } if ( bounds [ 0 ] == null && bounds [ 2 ] == null || bounds [ 1 ] == null && bounds [ 3 ] == null ) { throw new IllegalArgumentException ( "Both x and x2 or y and y2 can not be null!" ) ; } cc . setPos ( bounds ) ; cc . setBoundsInGrid ( false ) ; continue ; } ix = startsWithLenient ( part , "pad" , 3 , true ) ; if ( ix > - 1 ) { UnitValue [ ] p = parseInsets ( part . substring ( ix ) . trim ( ) , false ) ; cc . setPadding ( new UnitValue [ ] { p [ 0 ] , p . length > 1 ? p [ 1 ] : null , p . length > 2 ? p [ 2 ] : null , p . length > 3 ? p [ 3 ] : null } ) ; continue ; } ix = startsWithLenient ( part , "pushx" , 5 , true ) ; if ( ix > - 1 ) { cc . setPushX ( parseFloat ( part . substring ( ix ) . trim ( ) , ResizeConstraint . WEIGHT_100 ) ) ; continue ; } ix = startsWithLenient ( part , "pushy" , 5 , true ) ; if ( ix > - 1 ) { cc . setPushY ( parseFloat ( part . substring ( ix ) . trim ( ) , ResizeConstraint . WEIGHT_100 ) ) ; continue ; } ix = startsWithLenient ( part , "push" , 4 , false ) ; if ( ix > - 1 ) { String [ ] pushs = toTrimmedTokens ( part . substring ( ix ) . trim ( ) , ' ' ) ; cc . setPushX ( parseFloat ( pushs [ 0 ] , ResizeConstraint . WEIGHT_100 ) ) ; cc . setPushY ( parseFloat ( pushs . length > 1 ? pushs [ 1 ] : "" , ResizeConstraint . WEIGHT_100 ) ) ; continue ; } } if ( c == 't' ) { ix = startsWithLenient ( part , "tag" , 3 , true ) ; if ( ix > - 1 ) { cc . setTag ( part . substring ( ix ) . trim ( ) ) ; continue ; } } if ( c == 'w' || c == 'h' ) { if ( part . equals ( "wrap" ) ) { cc . setWrap ( true ) ; continue ; } if ( part . startsWith ( "wrap " ) ) { String gapSz = part . substring ( 5 ) . trim ( ) ; cc . setWrapGapSize ( parseBoundSize ( gapSz , true , true ) ) ; continue ; } boolean isHor = c == 'w' ; if ( isHor && ( part . startsWith ( "w " ) || part . startsWith ( "width " ) ) ) { String uvStr = part . substring ( part . charAt ( 1 ) == ' ' ? 2 : 6 ) . trim ( ) ; cc . getHorizontal ( ) . setSize ( parseBoundSize ( uvStr , false , true ) ) ; continue ; } if ( ! isHor && ( part . startsWith ( "h " ) || part . startsWith ( "height " ) ) ) { String uvStr = part . substring ( part . charAt ( 1 ) == ' ' ? 2 : 7 ) . trim ( ) ; cc . getVertical ( ) . setSize ( parseBoundSize ( uvStr , false , false ) ) ; continue ; } if ( part . startsWith ( "wmin " ) || part . startsWith ( "wmax " ) || part . startsWith ( "hmin " ) || part . startsWith ( "hmax " ) ) { String uvStr = part . substring ( 5 ) . trim ( ) ; if ( uvStr . length ( ) > 0 ) { UnitValue uv = parseUnitValue ( uvStr , null , isHor ) ; boolean isMin = part . charAt ( 3 ) == 'n' ; DimConstraint dc = isHor ? cc . getHorizontal ( ) : cc . getVertical ( ) ; dc . setSize ( new BoundSize ( isMin ? uv : dc . getSize ( ) . getMin ( ) , dc . getSize ( ) . getPreferred ( ) , isMin ? ( dc . getSize ( ) . getMax ( ) ) : uv , uvStr ) ) ; continue ; } } if ( part . equals ( "west" ) ) { cc . setDockSide ( 1 ) ; continue ; } if ( part . startsWith ( "hidemode " ) ) { cc . setHideMode ( Integer . parseInt ( part . substring ( 9 ) ) ) ; continue ; } } if ( c == 'i' && part . startsWith ( "id " ) ) { cc . setId ( part . substring ( 3 ) . trim ( ) ) ; int dIx = cc . getId ( ) . indexOf ( '.' ) ; if ( dIx == 0 || dIx == cc . getId ( ) . length ( ) - 1 ) { throw new IllegalArgumentException ( "Dot must not be first or last!" ) ; } continue ; } if ( c == 'e' ) { if ( part . equals ( "east" ) ) { cc . setDockSide ( 3 ) ; continue ; } if ( part . equals ( "external" ) ) { cc . setExternal ( true ) ; continue ; } ix = startsWithLenient ( part , new String [ ] { "endgroupx" , "endgroupy" , "egx" , "egy" } , new int [ ] { - 1 , - 1 , - 1 , - 1 } , true ) ; if ( ix > - 1 ) { String sg = part . substring ( ix ) . trim ( ) ; char lc = part . charAt ( ix - 1 ) ; DimConstraint dc = ( lc == 'x' ? cc . getHorizontal ( ) : cc . getVertical ( ) ) ; dc . setEndGroup ( sg ) ; continue ; } } if ( c == 'd' ) { if ( part . equals ( "dock north" ) ) { cc . setDockSide ( 0 ) ; continue ; } if ( part . equals ( "dock west" ) ) { cc . setDockSide ( 1 ) ; continue ; } if ( part . equals ( "dock south" ) ) { cc . setDockSide ( 2 ) ; continue ; } if ( part . equals ( "dock east" ) ) { cc . setDockSide ( 3 ) ; continue ; } if ( part . equals ( "dock center" ) ) { cc . getHorizontal ( ) . setGrow ( new Float ( 100f ) ) ; cc . getVertical ( ) . setGrow ( new Float ( 100f ) ) ; cc . setPushX ( new Float ( 100f ) ) ; cc . setPushY ( new Float ( 100f ) ) ; continue ; } } if ( c == 'v' ) { ix = startsWithLenient ( part , new String [ ] { "visualpadding" , "vp" } , new int [ ] { 3 , 2 } , true ) ; if ( ix > - 1 ) { UnitValue [ ] p = parseInsets ( part . substring ( ix ) . trim ( ) , false ) ; cc . setVisualPadding ( new UnitValue [ ] { p [ 0 ] , p . length > 1 ? p [ 1 ] : null , p . length > 2 ? p [ 2 ] : null , p . length > 3 ? p [ 3 ] : null } ) ; continue ; } } UnitValue horAlign = parseAlignKeywords ( part , true ) ; if ( horAlign != null ) { cc . getHorizontal ( ) . setAlign ( horAlign ) ; continue ; } UnitValue verAlign = parseAlignKeywords ( part , false ) ; if ( verAlign != null ) { cc . getVertical ( ) . setAlign ( verAlign ) ; continue ; } throw new IllegalArgumentException ( "Unknown keyword." ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; throw new IllegalArgumentException ( "Error parsing Constraint: '" + part + "'" ) ; } } return cc ; } | Parses one component constraint and returns the parsed value . |
fun computeRightChild(node: SegmentTreeNode<*>): SegmentTreeNode<*>? { return if (node.right - node.left > 1) { constructor.construct((node.left + node.right) / 2, node.right) } else null } | Compute the right child node , if it exists |
fun isValidIPAddress(address: String?): Boolean { var address = address if (address == null || address.length == 0) { return false } var ipv6Expected = false if (address[0] == '[') { if (address.length > 2 && address[address.length - 1] == ']') { address = address.substring(1, address.length - 1) ipv6Expected = true } else { return false } } if (address[0].digitToIntOrNull(16) ?: -1 != -1 || address[0] == ':') { var addr: ByteArray? = null addr = strToIPv4(address) if (addr == null) { addr = strToIPv6(address) } else if (ipv6Expected) { return false } if (addr != null) { return true } } return false } | Checks whether < tt > address < /tt > is a valid IP address string . |
private fun loadVerticesAndRelatives() { val elementList: MutableList<CnATreeElement> = LinkedList<CnATreeElement>() for (loader in getLoaderList()) { loader.setCnaTreeElementDao(getCnaTreeElementDao()) elementList.addAll(loader.loadElements()) } for (element in elementList) { graph.addVertex(element) if (LOG.isDebugEnabled()) { LOG.debug("Vertex added: " + element.getTitle()) } uuidMap.put(element.getUuid(), element) } for (parent in elementList) { val children: Set<CnATreeElement> = parent.getChildren() for (child in children) { createParentChildEdge(parent, child) } } } | Loads all vertices and adds them to the graph . An edge for each children is added if the child is part of the graph . |
private fun initializeLiveAttributes() { transform = createLiveAnimatedTransformList(null, SVG_TRANSFORM_ATTRIBUTE, "")externalResourcesRequired = createLiveAnimatedBoolean(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE, false) } | Initializes the live attribute values of this element . |
fun putParcelable(key: String?, value: Parcelable?) { unparcel() mMap.put(key, value) mFdsKnown = false } | Inserts a Parcelable value into the mapping of this Bundle , replacing any existing value for the given key . Either key or value may be null . |
fun <T> flatten(self: Iterable<T>?, flattenUsing: Closure<out T>?): Collection<T>? { return flatten(self, createSimilarCollection(self), flattenUsing) } | Flatten an Iterable . This Iterable and any nested arrays or collections have their contents ( recursively ) added to the new collection . For any non-Array , non-Collection object which represents some sort of collective type , the supplied closure should yield the contained items ; otherwise , the closure should just return any element which corresponds to a leaf . |
fun semiDeviation(): Double { return Math.sqrt(semiVariance()) } | returns the semi deviation , defined as the square root of the semi variance . |
public Object runSafely ( Catbert . FastStack stack ) throws Exception { String val = getString ( stack ) ; Sage . put ( getString ( stack ) , val ) ; return null ; } | Sets the property with the specified name to the specified value . If this is called from a client instance then it will use the properties on the server system for this call and the change will be made on the server system . |
protected fun createUserDictionaryPreference( locale: String?, activity: Activity? ): Preference? { val newPref = Preference(getActivity()) val intent = Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION) if (null == locale) { newPref.title = Locale.getDefault().displayName } else { if ("" == locale) newPref.title = getString(R.string.user_dict_settings_all_languages) else newPref.setTitle( Utils.createLocaleFromString( locale ).getDisplayName() ) intent.putExtra("locale", locale) newPref.extras.putString("locale", locale) } newPref.intent = intent newPref.fragment = com.android.settings.UserDictionarySettings::class.java.getName() return newPref } | Create a single User Dictionary Preference object , with its parameters set . |
public static < T > T withPrintWriter ( Path self , @ ClosureParams ( value = SimpleType . class , options = "java.io.PrintWriter" ) Closure < T > closure ) throws IOException { return IOGroovyMethods . withWriter ( newPrintWriter ( self ) , closure ) ; } | Create a new PrintWriter for this file which is then passed it into the given closure . This method ensures its the writer is closed after the closure returns . |
@Throws(Exception::class) fun testBug77649() { var props: Properties = getPropertiesFromTestsuiteUrl() val host = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY) val port = props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY) val hosts = arrayOf(host, "address", "address.somewhere", "addressing", "addressing.somewhere") UnreliableSocketFactory.flushAllStaticData() for (i in 1 until hosts.size) { UnreliableSocketFactory.mapHost(hosts[i], host) } props = getHostFreePropertiesFromTestsuiteUrl() props.setProperty("socketFactory", UnreliableSocketFactory::class.java.getName()) for (h in hosts) { getConnectionWithProps(String.format("jdbc:mysql://%s:%s", h, port), props).close() getConnectionWithProps( String.format( "jdbc:mysql://address=(protocol=tcp)(host=%s)(port=%s)", h, port ), props ).close() } } | Tests fix for Bug # 77649 - URL start with word `` address '' , JDBC ca n't parse the `` host : port '' Correctly . |
fun pathsIterator(): Iterator<PluginPatternMatcher>? { return if (mDataPaths != null) mDataPaths.iterator() else null } | Return an iterator over the filter 's data paths . |
private fun checkInMoving(x: Float, y: Float) { val xDiff = Math.abs(x - lastMotionX) as Int val yDiff = Math.abs(y - lastMotionY) as Int val touchSlop: Int = this.touchSlop val xMoved = xDiff > touchSlop val yMoved = yDiff > touchSlop if (xMoved) { touchState = TOUCH_STATE_SCROLLING_X lastMotionX = x lastMotionY = y } if (yMoved) { touchState = TOUCH_STATE_SCROLLING_Y lastMotionX = x lastMotionY = y } } | Check if the user is moving the cell |
fun checkInstance(instance: Instance): Boolean { if (instance.numAttributes() !== numAttributes()) { return false } for (i in 0 until numAttributes()) { if (instance.isMissing(i)) { continue } else if (attribute(i).isNominal() || attribute(i).isString()) { if (!Utils.eq(instance.value(i), instance.value(i) as Int.toDouble())) { return false } else if (Utils.sm(instance.value(i), 0) || Utils.gr( instance.value(i), attribute(i).numValues() ) ) { return false } } } return true } | Checks if the given instance is compatible with this dataset . Only looks at the size of the instance and the ranges of the values for nominal and string attributes . |
private fun concatBytes(array1: ByteArray, array2: ByteArray): ByteArray? { val cBytes = ByteArray(array1.size + array2.size) try { System.arraycopy(array1, 0, cBytes, 0, array1.size) System.arraycopy(array2, 0, cBytes, array1.size, array2.size) } catch (e: Exception) { throw FacesException(e)}return cBytes } | This method concatenates two byte arrays |
fun layout(delta: Int, animate: Boolean) { if (mDataChanged) { handleDataChanged() } if (getCount() === 0) { resetList() return } if (mNextSelectedPosition >= 0) { setSelectedPositionInt(mNextSelectedPosition) } recycleAllViews() detachAllViewsFromParent() val count: Int = sun.util.locale.provider.LocaleProviderAdapter.getAdapter().getCount() val angleUnit = 360.0f / count val angleOffset: Float = mSelectedPosition * angleUnit for (i in 0 until sun.util.locale.provider.LocaleProviderAdapter.getAdapter().getCount()) { var angle = angleUnit * i - angleOffset if (angle < 0.0f) angle = 360.0f + angle makeAndAddView(i, angle) } mRecycler.clear() invalidate() setNextSelectedPositionInt(mSelectedPosition) checkSelectionChanged() mNeedSync = false updateSelectedItemMetadata() } | Setting up images . |
private void updateMenuItems ( boolean isGpsStarted , boolean isRecording ) { boolean hasTrack = listView != null && listView . getCount ( ) != 0 ; if ( startGpsMenuItem != null ) { startGpsMenuItem . setVisible ( ! isRecording ) ; if ( ! isRecording ) { startGpsMenuItem . setTitle ( isGpsStarted ? R . string . menu_stop_gps : R . string . menu_start_gps ) ; startGpsMenuItem . setIcon ( isGpsStarted ? R . drawable . ic_menu_stop_gps : R . drawable . ic_menu_start_gps ) ; TrackIconUtils . setMenuIconColor ( startGpsMenuItem ) ; } } if ( playMultipleItem != null ) { playMultipleItem . setVisible ( hasTrack ) ; } if ( syncNowMenuItem != null ) { syncNowMenuItem . setTitle ( driveSync ? R . string . menu_sync_now : R . string . menu_sync_drive ) ; } if ( aggregatedStatisticsMenuItem != null ) { aggregatedStatisticsMenuItem . setVisible ( hasTrack ) ; } if ( exportAllMenuItem != null ) { exportAllMenuItem . setVisible ( hasTrack && ! isRecording ) ; } if ( importAllMenuItem != null ) { importAllMenuItem . setVisible ( ! isRecording ) ; } if ( deleteAllMenuItem != null ) { deleteAllMenuItem . setVisible ( hasTrack && ! isRecording ) ; } } | Updates the menu items . |
public boolean isDuplicateSupported ( ) { return duplicateSupported ; } | Indicates whether this connection request supports duplicate entries in the request queue |
public void onStart ( ) { } | Called when the animation starts . |
public static int [ ] [ ] loadPNMFile ( InputStream str ) throws IOException { BufferedInputStream stream = new BufferedInputStream ( str ) ; String type = tokenizeString ( stream ) ; if ( type . equals ( "P1" ) ) return loadPlainPBM ( stream ) ; else if ( type . equals ( "P2" ) ) return loadPlainPGM ( stream ) ; else if ( type . equals ( "P4" ) ) return loadRawPBM ( stream ) ; else if ( type . equals ( "P5" ) ) return loadRawPGM ( stream ) ; else throw new IOException ( "Not a viable PBM or PGM stream" ) ; } | Loads plain or raw PGM files or plain or raw PBM files and return the result as an int [ ] [ ] . The Y dimension is not flipped . |
public BiCorpus alignedFromFiles ( String f ) throws IOException { return new BiCorpus ( fpath + f + extf , epath + f + exte , apath + f + exta ) ; } | Generate aligned BiCorpus . |
public LognormalDistr ( double shape , double scale ) { numGen = new LogNormalDistribution ( scale , shape ) ; } | Instantiates a new Log-normal pseudo random number generator . |
private static String contentLengthHeader ( final long length ) { return String . format ( "Content-Length: %d" , length ) ; } | Format Content-Length header . |
@ Bean @ ConditionalOnMissingBean public AmqpSenderService amqpSenderServiceBean ( ) { return new DefaultAmqpSenderService ( rabbitTemplate ( ) ) ; } | Create default amqp sender service bean . |
@ Override protected void initialize ( ) { super . initialize ( ) ; m_Processor = new MarkdownProcessor ( ) ; m_Markdown = "" ; } | Initializes the members . |
public void upperBound ( byte [ ] key ) throws IOException { upperBound ( key , 0 , key . length ) ; } | Move the cursor to the first entry whose key is strictly greater than the input key . Synonymous to upperBound ( key , 0 , key.length ) . The entry returned by the previous entry ( ) call will be invalid . |
public static String replaceLast ( String s , char sub , char with ) { int index = s . lastIndexOf ( sub ) ; if ( index == - 1 ) { return s ; } char [ ] str = s . toCharArray ( ) ; str [ index ] = with ; return new String ( str ) ; } | Replaces the very last occurrence of a character in a string . |
public static void main ( String [ ] args ) { Thrust simulation = new Thrust ( ) ; simulation . run ( ) ; } | Entry point for the example application . |
public static < T > T checkNotNull ( T reference , @ Nullable String errorMessageTemplate , @ Nullable Object ... errorMessageArgs ) { if ( reference == null ) { throw new NullPointerException ( format ( errorMessageTemplate , errorMessageArgs ) ) ; } return reference ; } | Ensures that an object reference passed as a parameter to the calling method is not null . |
public boolean insert ( String name , RegExp definition ) { if ( Options . DEBUG ) Out . debug ( "inserting macro " + name + " with definition :" + Out . NL + definition ) ; used . put ( name , Boolean . FALSE ) ; return macros . put ( name , definition ) == null ; } | Stores a new macro and its definition . |
public boolean add ( Object o ) { ensureCapacity ( size + 1 ) ; elementData [ size ++ ] = o ; return true ; } | Appends the specified element to the end of this list . |
public InvocationTargetException ( Throwable target , String s ) { super ( s , null ) ; this . target = target ; } | Constructs a InvocationTargetException with a target exception and a detail message . |
public boolean isExternalSkin ( ) { return ! isDefaultSkin && mResources != null ; } | whether the skin being used is from external .skin file |
private void updateActions ( ) { actions . removeAll ( ) ; final ActionGroup mainActionGroup = ( ActionGroup ) actionManager . getAction ( getGroupMenu ( ) ) ; if ( mainActionGroup == null ) { return ; } final Action [ ] children = mainActionGroup . getChildren ( null ) ; for ( final Action action : children ) { final Presentation presentation = presentationFactory . getPresentation ( action ) ; final ActionEvent e = new ActionEvent ( ActionPlaces . MAIN_CONTEXT_MENU , presentation , actionManager , 0 ) ; action . update ( e ) ; if ( presentation . isVisible ( ) ) { actions . add ( action ) ; } } } | Updates the list of visible actions . |
private void showFeedback ( String message ) { if ( myHost != null ) { myHost . showFeedback ( message ) ; } else { System . out . println ( message ) ; } } | Used to communicate feedback pop-up messages between a plugin tool and the main Whitebox user-interface . |
TechCategory fallthrough ( ) { switch ( this ) { case OMNI_AERO : return OMNI ; case CLAN_AERO : case CLAN_VEE : return CLAN ; case IS_ADVANCED_AERO : case IS_ADVANCED_VEE : return IS_ADVANCED ; default : return null ; } } | If no value is provided for ASFs or Vees , use the base value . |
static void svd_dscal ( int n , double da , double [ ] dx , int incx ) { if ( n <= 0 || incx == 0 ) return ; int ix = ( incx < 0 ) ? n - 1 : 0 ; for ( int i = 0 ; i < n ; i ++ ) { dx [ ix ] *= da ; ix += incx ; } return ; } | Function scales a vector by a constant . * Based on Fortran-77 routine from Linpack by J. Dongarra |
public CampoFechaVO insertValue ( final CampoFechaVO value ) { try { DbConnection conn = getConnection ( ) ; DbInsertFns . insert ( conn , TABLE_NAME , DbUtil . getColumnNames ( COL_DEFS ) , new SigiaDbInputRecord ( COL_DEFS , value ) ) ; return value ; } catch ( Exception e ) { logger . error ( "Error insertando campo de tipo fecha para el descriptor " + value . getIdObjeto ( ) , e ) ; throw new DBException ( "insertando campo de tipo fecha" , e ) ; } } | Inserta un valor de tipo fecha . |
private synchronized void closeActiveFile ( ) { StringWriterFile activeFile = this . activeFile ; try { this . activeFile = null ; if ( activeFile != null ) { activeFile . close ( ) ; getPolicy ( ) . closeActiveFile ( activeFile . path ( ) ) ; activeFile = null ; } } catch ( IOException e ) { trace . error ( "error closing active file '{}'" , activeFile . path ( ) , e ) ; } } | close , finalize , and apply retention policy |
public void testWARTypeEquality ( ) { WAR war1 = new WAR ( "/some/path/to/file.war" ) ; WAR war2 = new WAR ( "/otherfile.war" ) ; assertEquals ( war1 . getType ( ) , war2 . getType ( ) ) ; } | Test equality between WAR deployables . |
public static Vector readSignatureAlgorithmsExtension ( byte [ ] extensionData ) throws IOException { if ( extensionData == null ) { throw new IllegalArgumentException ( "'extensionData' cannot be null" ) ; } ByteArrayInputStream buf = new ByteArrayInputStream ( extensionData ) ; Vector supported_signature_algorithms = parseSupportedSignatureAlgorithms ( false , buf ) ; TlsProtocol . assertEmpty ( buf ) ; return supported_signature_algorithms ; } | Read 'signature_algorithms ' extension data . |
public void updateNCharacterStream ( int columnIndex , java . io . Reader x , long length ) throws SQLException { throw new SQLFeatureNotSupportedException ( resBundle . handleGetObject ( "jdbcrowsetimpl.featnotsupp" ) . toString ( ) ) ; } | Updates the designated column with a character stream value , which will have the specified number of bytes . The driver does the necessary conversion from Java character format to the national character set in the database . It is intended for use when updating NCHAR , NVARCHAR and LONGNVARCHAR columns . The updater methods are used to update column values in the current row or the insert row . The updater methods do not update the underlying database ; instead the updateRow or insertRow methods are called to update the database . |
public boolean isModified ( ) { return isCustom ( ) && ! isUserAdded ( ) ; } | Returns whether the receiver represents a modified template , i.e . a contributed template that has been changed . |
public String toString ( ) { return this . getClass ( ) . getName ( ) + "(" + my_k + ")" ; } | Returns a String representation of the receiver . |
private static PostingsEnum termDocs ( IndexReader reader , Term term ) throws IOException { return MultiFields . getTermDocsEnum ( reader , MultiFields . getLiveDocs ( reader ) , term . field ( ) , term . bytes ( ) ) ; } | NB : this is a convenient but very slow way of getting termDocs . It is sufficient for testing purposes . |
public boolean isSubregion ( ) { return subregion ; } | Returns true if the Region is a subregion of a Component , otherwise false . For example , < code > Region.BUTTON < /code > corresponds do a < code > Component < /code > so that < code > Region.BUTTON.isSubregion ( ) < /code > returns false . |
public static void encodeToFile ( byte [ ] dataToEncode , String filename ) throws java . io . IOException { if ( dataToEncode == null ) { throw new NullPointerException ( "Data to encode was null." ) ; } Base64 . OutputStream bos = null ; try { bos = new Base64 . OutputStream ( new java . io . FileOutputStream ( filename ) , Base64 . ENCODE ) ; bos . write ( dataToEncode ) ; } catch ( java . io . IOException e ) { throw e ; } finally { try { bos . close ( ) ; } catch ( Exception e ) { } } } | Convenience method for encoding data to a file . < p > As of v 2.3 , if there is a error , the method will throw an java.io.IOException . < b > This is new to v2.3 ! < /b > In earlier versions , it just returned false , but in retrospect that 's a pretty poor way to handle it. < /p > |
Subsets and Splits