idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
16,500
private static int applyMaskPenaltyRule1Internal ( ByteMatrix matrix , boolean isHorizontal ) { int penalty = 0 ; int iLimit = isHorizontal ? matrix . getHeight ( ) : matrix . getWidth ( ) ; int jLimit = isHorizontal ? matrix . getWidth ( ) : matrix . getHeight ( ) ; byte [ ] [ ] array = matrix . getArray ( ) ; for ( i...
Helper function for applyMaskPenaltyRule1 . We need this for doing this calculation in both vertical and horizontal orders respectively .
16,501
public AddressBookParsedResult parse ( Result result ) { String rawText = getMassagedText ( result ) ; if ( ! rawText . startsWith ( "BIZCARD:" ) ) { return null ; } String firstName = matchSingleDoCoMoPrefixedField ( "N:" , rawText , true ) ; String lastName = matchSingleDoCoMoPrefixedField ( "X:" , rawText , true ) ;...
DoCoMo s proposed formats
16,502
public void setRange ( int start , int end ) { if ( end < start || start < 0 || end > size ) { throw new IllegalArgumentException ( ) ; } if ( end == start ) { return ; } end -- ; int firstInt = start / 32 ; int lastInt = end / 32 ; for ( int i = firstInt ; i <= lastInt ; i ++ ) { int firstBit = i > firstInt ? 0 : star...
Sets a range of bits .
16,503
public boolean isRange ( int start , int end , boolean value ) { if ( end < start || start < 0 || end > size ) { throw new IllegalArgumentException ( ) ; } if ( end == start ) { return true ; } end -- ; int firstInt = start / 32 ; int lastInt = end / 32 ; for ( int i = firstInt ; i <= lastInt ; i ++ ) { int firstBit = ...
Efficient method to check if a range of bits is set or not set .
16,504
public void appendBits ( int value , int numBits ) { if ( numBits < 0 || numBits > 32 ) { throw new IllegalArgumentException ( "Num bits must be between 0 and 32" ) ; } ensureCapacity ( size + numBits ) ; for ( int numBitsLeft = numBits ; numBitsLeft > 0 ; numBitsLeft -- ) { appendBit ( ( ( value >> ( numBitsLeft - 1 )...
Appends the least - significant bits from value in order from most - significant to least - significant . For example appending 6 bits from 0x000001E will append the bits 0 1 1 1 1 0 in that order .
16,505
public void reverse ( ) { int [ ] newBits = new int [ bits . length ] ; int len = ( size - 1 ) / 32 ; int oldBitsLen = len + 1 ; for ( int i = 0 ; i < oldBitsLen ; i ++ ) { long x = bits [ i ] ; x = ( ( x >> 1 ) & 0x55555555L ) | ( ( x & 0x55555555L ) << 1 ) ; x = ( ( x >> 2 ) & 0x33333333L ) | ( ( x & 0x33333333L ) <<...
Reverses all bits in the array .
16,506
private static int determineConsecutiveTextCount ( CharSequence msg , int startpos ) { int len = msg . length ( ) ; int idx = startpos ; while ( idx < len ) { char ch = msg . charAt ( idx ) ; int numericCount = 0 ; while ( numericCount < 13 && isDigit ( ch ) && idx < len ) { numericCount ++ ; idx ++ ; if ( idx < len ) ...
Determines the number of consecutive characters that are encodable using text compaction .
16,507
private static int determineConsecutiveBinaryCount ( String msg , int startpos , Charset encoding ) throws WriterException { CharsetEncoder encoder = encoding . newEncoder ( ) ; int len = msg . length ( ) ; int idx = startpos ; while ( idx < len ) { char ch = msg . charAt ( idx ) ; int numericCount = 0 ; while ( numeri...
Determines the number of consecutive characters that are encodable using binary compaction .
16,508
public static int determineConsecutiveDigitCount ( CharSequence msg , int startpos ) { int count = 0 ; int len = msg . length ( ) ; int idx = startpos ; if ( idx < len ) { char ch = msg . charAt ( idx ) ; while ( isDigit ( ch ) && idx < len ) { count ++ ; idx ++ ; if ( idx < len ) { ch = msg . charAt ( idx ) ; } } } re...
Determines the number of consecutive characters that are encodable using numeric compaction .
16,509
final void searchMap ( String address ) { launchIntent ( new Intent ( Intent . ACTION_VIEW , Uri . parse ( "geo:0,0?q=" + Uri . encode ( address ) ) ) ) ; }
Do a geo search using the address as the query .
16,510
final void openProductSearch ( String upc ) { Uri uri = Uri . parse ( "http://www.google." + LocaleManager . getProductSearchCountryTLD ( activity ) + "/m/products?q=" + upc + "&source=zxing" ) ; launchIntent ( new Intent ( Intent . ACTION_VIEW , uri ) ) ; }
Uses the mobile - specific version of Product Search which is formatted for small screens .
16,511
private void decode ( byte [ ] data , int width , int height ) { long start = System . nanoTime ( ) ; Result rawResult = null ; PlanarYUVLuminanceSource source = activity . getCameraManager ( ) . buildLuminanceSource ( data , width , height ) ; if ( source != null ) { BinaryBitmap bitmap = new BinaryBitmap ( new Hybrid...
Decode the data within the viewfinder rectangle and time how long it took . For efficiency reuse the same reader objects from one decode to the next .
16,512
private ResultPoint [ ] detectSolid1 ( ResultPoint [ ] cornerPoints ) { ResultPoint pointA = cornerPoints [ 0 ] ; ResultPoint pointB = cornerPoints [ 1 ] ; ResultPoint pointC = cornerPoints [ 3 ] ; ResultPoint pointD = cornerPoints [ 2 ] ; int trAB = transitionsBetween ( pointA , pointB ) ; int trBC = transitionsBetwee...
Detect a solid side which has minimum transition .
16,513
private ResultPoint [ ] detectSolid2 ( ResultPoint [ ] points ) { ResultPoint pointA = points [ 0 ] ; ResultPoint pointB = points [ 1 ] ; ResultPoint pointC = points [ 2 ] ; ResultPoint pointD = points [ 3 ] ; int tr = transitionsBetween ( pointA , pointD ) ; ResultPoint pointBs = shiftPoint ( pointB , pointC , ( tr + ...
Detect a second solid side next to first solid side .
16,514
private ResultPoint correctTopRight ( ResultPoint [ ] points ) { ResultPoint pointA = points [ 0 ] ; ResultPoint pointB = points [ 1 ] ; ResultPoint pointC = points [ 2 ] ; ResultPoint pointD = points [ 3 ] ; int trTop = transitionsBetween ( pointA , pointD ) ; int trRight = transitionsBetween ( pointB , pointD ) ; Res...
Calculates the corner position of the white top right module .
16,515
private ResultPoint [ ] shiftToModuleCenter ( ResultPoint [ ] points ) { ResultPoint pointA = points [ 0 ] ; ResultPoint pointB = points [ 1 ] ; ResultPoint pointC = points [ 2 ] ; ResultPoint pointD = points [ 3 ] ; int dimH = transitionsBetween ( pointA , pointD ) + 1 ; int dimV = transitionsBetween ( pointC , pointD...
Shift the edge points to the module center .
16,516
protected void startActivityForResult ( Intent intent , int code ) { if ( fragment == null ) { activity . startActivityForResult ( intent , code ) ; } else { fragment . startActivityForResult ( intent , code ) ; } }
Start an activity . This method is defined to allow different methods of activity starting for newer versions of Android and for compatibility library .
16,517
public final AlertDialog shareText ( CharSequence text , CharSequence type ) { Intent intent = new Intent ( ) ; intent . addCategory ( Intent . CATEGORY_DEFAULT ) ; intent . setAction ( BS_PACKAGE + ".ENCODE" ) ; intent . putExtra ( "ENCODE_TYPE" , type ) ; intent . putExtra ( "ENCODE_DATA" , text ) ; String targetAppP...
Shares the given text by encoding it as a barcode such that another user can scan the text off the screen of the device .
16,518
public BitArray getBlackRow ( int y , BitArray row ) throws NotFoundException { LuminanceSource source = getLuminanceSource ( ) ; int width = source . getWidth ( ) ; if ( row == null || row . getSize ( ) < width ) { row = new BitArray ( width ) ; } else { row . clear ( ) ; } initArrays ( width ) ; byte [ ] localLuminan...
Applies simple sharpening to the row data to improve performance of the 1D Readers .
16,519
public BitMatrix getBlackMatrix ( ) throws NotFoundException { LuminanceSource source = getLuminanceSource ( ) ; int width = source . getWidth ( ) ; int height = source . getHeight ( ) ; BitMatrix matrix = new BitMatrix ( width , height ) ; initArrays ( width ) ; int [ ] localBuckets = buckets ; for ( int y = 1 ; y < 5...
Does not sharpen the data as this call is intended to only be used by 2D Readers .
16,520
State latchAndAppend ( int mode , int value ) { int bitCount = this . bitCount ; Token token = this . token ; if ( mode != this . mode ) { int latch = HighLevelEncoder . LATCH_TABLE [ this . mode ] [ mode ] ; token = token . add ( latch & 0xFFFF , latch >> 16 ) ; bitCount += latch >> 16 ; } int latchModeBitCount = mode...
necessary different ) mode and then a code .
16,521
State shiftAndAppend ( int mode , int value ) { Token token = this . token ; int thisModeBitCount = this . mode == HighLevelEncoder . MODE_DIGIT ? 4 : 5 ; token = token . add ( HighLevelEncoder . SHIFT_TABLE [ this . mode ] [ mode ] , thisModeBitCount ) ; token = token . add ( value , 5 ) ; return new State ( token , t...
to a different mode to output a single value .
16,522
State addBinaryShiftChar ( int index ) { Token token = this . token ; int mode = this . mode ; int bitCount = this . bitCount ; if ( this . mode == HighLevelEncoder . MODE_PUNCT || this . mode == HighLevelEncoder . MODE_DIGIT ) { int latch = HighLevelEncoder . LATCH_TABLE [ mode ] [ HighLevelEncoder . MODE_UPPER ] ; to...
output in Binary Shift mode .
16,523
State endBinaryShift ( int index ) { if ( binaryShiftByteCount == 0 ) { return this ; } Token token = this . token ; token = token . addBinaryShift ( index - binaryShiftByteCount , binaryShiftByteCount ) ; return new State ( token , mode , 0 , this . bitCount ) ; }
Binary Shift mode .
16,524
boolean isBetterThanOrEqualTo ( State other ) { int newModeBitCount = this . bitCount + ( HighLevelEncoder . LATCH_TABLE [ this . mode ] [ other . mode ] >> 16 ) ; if ( this . binaryShiftByteCount < other . binaryShiftByteCount ) { newModeBitCount += calculateBinaryShiftCost ( other ) - calculateBinaryShiftCost ( this ...
state under all possible circumstances .
16,525
private static BitMatrix encodeLowLevel ( DefaultPlacement placement , SymbolInfo symbolInfo , int width , int height ) { int symbolWidth = symbolInfo . getSymbolDataWidth ( ) ; int symbolHeight = symbolInfo . getSymbolDataHeight ( ) ; ByteMatrix matrix = new ByteMatrix ( symbolInfo . getSymbolWidth ( ) , symbolInfo . ...
Encode the given symbol info to a bit matrix .
16,526
private static BitMatrix convertByteMatrixToBitMatrix ( ByteMatrix matrix , int reqWidth , int reqHeight ) { int matrixWidth = matrix . getWidth ( ) ; int matrixHeight = matrix . getHeight ( ) ; int outputWidth = Math . max ( reqWidth , matrixWidth ) ; int outputHeight = Math . max ( reqHeight , matrixHeight ) ; int mu...
Convert the ByteMatrix to BitMatrix .
16,527
private static int skipWhiteSpace ( BitArray row ) throws NotFoundException { int width = row . getSize ( ) ; int endStart = row . getNextSet ( 0 ) ; if ( endStart == width ) { throw NotFoundException . getNotFoundInstance ( ) ; } return endStart ; }
Skip all whitespace until we get to the first black line .
16,528
public BitArray getRow ( int y , BitArray row ) { if ( row == null || row . getSize ( ) < width ) { row = new BitArray ( width ) ; } else { row . clear ( ) ; } int offset = y * rowSize ; for ( int x = 0 ; x < rowSize ; x ++ ) { row . setBulk ( x * 32 , bits [ offset + x ] ) ; } return row ; }
A fast method to retrieve one row of data from the matrix as a BitArray .
16,529
public int [ ] getEnclosingRectangle ( ) { int left = width ; int top = height ; int right = - 1 ; int bottom = - 1 ; for ( int y = 0 ; y < height ; y ++ ) { for ( int x32 = 0 ; x32 < rowSize ; x32 ++ ) { int theBits = bits [ y * rowSize + x32 ] ; if ( theBits != 0 ) { if ( y < top ) { top = y ; } if ( y > bottom ) { b...
This is useful in detecting the enclosing rectangle of a pure barcode .
16,530
public int [ ] getTopLeftOnBit ( ) { int bitsOffset = 0 ; while ( bitsOffset < bits . length && bits [ bitsOffset ] == 0 ) { bitsOffset ++ ; } if ( bitsOffset == bits . length ) { return null ; } int y = bitsOffset / rowSize ; int x = ( bitsOffset % rowSize ) * 32 ; int theBits = bits [ bitsOffset ] ; int bit = 0 ; whi...
This is useful in detecting a corner of a pure barcode .
16,531
static void buildMatrix ( BitArray dataBits , ErrorCorrectionLevel ecLevel , Version version , int maskPattern , ByteMatrix matrix ) throws WriterException { clearMatrix ( matrix ) ; embedBasicPatterns ( version , matrix ) ; embedTypeInfo ( ecLevel , maskPattern , matrix ) ; maybeEmbedVersionInfo ( version , matrix ) ;...
success store the result in matrix and return true .
16,532
static void embedBasicPatterns ( Version version , ByteMatrix matrix ) throws WriterException { embedPositionDetectionPatternsAndSeparators ( matrix ) ; embedDarkDotAtLeftBottomCorner ( matrix ) ; maybeEmbedPositionAdjustmentPatterns ( version , matrix ) ; embedTimingPatterns ( matrix ) ; }
- Position adjustment patterns if need be
16,533
static void embedTypeInfo ( ErrorCorrectionLevel ecLevel , int maskPattern , ByteMatrix matrix ) throws WriterException { BitArray typeInfoBits = new BitArray ( ) ; makeTypeInfoBits ( ecLevel , maskPattern , typeInfoBits ) ; for ( int i = 0 ; i < typeInfoBits . getSize ( ) ; ++ i ) { boolean bit = typeInfoBits . get ( ...
Embed type information . On success modify the matrix .
16,534
static int calculateBCHCode ( int value , int poly ) { if ( poly == 0 ) { throw new IllegalArgumentException ( "0 polynomial" ) ; } int msbSetInPoly = findMSBSet ( poly ) ; value <<= msbSetInPoly - 1 ; while ( findMSBSet ( value ) >= msbSetInPoly ) { value ^= poly << ( findMSBSet ( value ) - msbSetInPoly ) ; } return v...
operations . We don t care if coefficients are positive or negative .
16,535
private static void maybeEmbedPositionAdjustmentPatterns ( Version version , ByteMatrix matrix ) { if ( version . getVersionNumber ( ) < 2 ) { return ; } int index = version . getVersionNumber ( ) - 1 ; int [ ] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE [ index ] ; for ( int y : coordinates ) { if ( y >...
Embed position adjustment patterns if need be .
16,536
List < ExpandedPair > decodeRow2pairs ( int rowNumber , BitArray row ) throws NotFoundException { boolean done = false ; while ( ! done ) { try { this . pairs . add ( retrieveNextPair ( row , this . pairs , rowNumber ) ) ; } catch ( NotFoundException nfe ) { if ( this . pairs . isEmpty ( ) ) { throw nfe ; } done = true...
Not private for testing
16,537
private List < ExpandedPair > checkRows ( List < ExpandedRow > collectedRows , int currentRow ) throws NotFoundException { for ( int i = currentRow ; i < rows . size ( ) ; i ++ ) { ExpandedRow row = rows . get ( i ) ; this . pairs . clear ( ) ; for ( ExpandedRow collectedRow : collectedRows ) { this . pairs . addAll ( ...
Recursion is used to implement backtracking
16,538
private static boolean isValidSequence ( List < ExpandedPair > pairs ) { for ( int [ ] sequence : FINDER_PATTERN_SEQUENCES ) { if ( pairs . size ( ) > sequence . length ) { continue ; } boolean stop = true ; for ( int j = 0 ; j < pairs . size ( ) ; j ++ ) { if ( pairs . get ( j ) . getFinderPattern ( ) . getValue ( ) !...
either complete or a prefix
16,539
private static void removePartialRows ( List < ExpandedPair > pairs , List < ExpandedRow > rows ) { for ( Iterator < ExpandedRow > iterator = rows . iterator ( ) ; iterator . hasNext ( ) ; ) { ExpandedRow r = iterator . next ( ) ; if ( r . getPairs ( ) . size ( ) == pairs . size ( ) ) { continue ; } boolean allFound = ...
Remove all the rows that contains only specified pairs
16,540
private static boolean isPartialRow ( Iterable < ExpandedPair > pairs , Iterable < ExpandedRow > rows ) { for ( ExpandedRow r : rows ) { boolean allFound = true ; for ( ExpandedPair p : pairs ) { boolean found = false ; for ( ExpandedPair pp : r . getPairs ( ) ) { if ( p . equals ( pp ) ) { found = true ; break ; } } i...
Returns true when one of the rows already contains all the pairs
16,541
static Result constructResult ( List < ExpandedPair > pairs ) throws NotFoundException , FormatException { BitArray binary = BitArrayBuilder . buildBitArray ( pairs ) ; AbstractExpandedDecoder decoder = AbstractExpandedDecoder . createDecoder ( binary ) ; String resultingString = decoder . parseInformation ( ) ; Result...
Not private for unit testing
16,542
private static int calculateMaskPenalty ( ByteMatrix matrix ) { return MaskUtil . applyMaskPenaltyRule1 ( matrix ) + MaskUtil . applyMaskPenaltyRule2 ( matrix ) + MaskUtil . applyMaskPenaltyRule3 ( matrix ) + MaskUtil . applyMaskPenaltyRule4 ( matrix ) ; }
Basically it applies four rules and summate all penalties .
16,543
private static Version recommendVersion ( ErrorCorrectionLevel ecLevel , Mode mode , BitArray headerBits , BitArray dataBits ) throws WriterException { int provisionalBitsNeeded = calculateBitsNeeded ( mode , headerBits , dataBits , Version . getVersionForNumber ( 1 ) ) ; Version provisionalVersion = chooseVersion ( pr...
Decides the smallest version of QR code that will contain all of the provided data .
16,544
static void appendLengthInfo ( int numLetters , Version version , Mode mode , BitArray bits ) throws WriterException { int numBits = mode . getCharacterCountBits ( version ) ; if ( numLetters >= ( 1 << numBits ) ) { throw new WriterException ( numLetters + " is bigger than " + ( ( 1 << numBits ) - 1 ) ) ; } bits . appe...
Append length info . On success store the result in bits .
16,545
public ProductParsedResult parse ( Result result ) { BarcodeFormat format = result . getBarcodeFormat ( ) ; if ( ! ( format == BarcodeFormat . UPC_A || format == BarcodeFormat . UPC_E || format == BarcodeFormat . EAN_8 || format == BarcodeFormat . EAN_13 ) ) { return null ; } String rawText = getMassagedText ( result )...
Treat all UPC and EAN variants as UPCs in the sense that they are all product barcodes .
16,546
private int [ ] determineDimensions ( int sourceCodeWords , int errorCorrectionCodeWords ) throws WriterException { float ratio = 0.0f ; int [ ] dimension = null ; for ( int cols = minCols ; cols <= maxCols ; cols ++ ) { int rows = calculateNumberOfRows ( sourceCodeWords , errorCorrectionCodeWords , cols ) ; if ( rows ...
Determine optimal nr of columns and rows for the specified number of codewords .
16,547
public void applyMirroredCorrection ( ResultPoint [ ] points ) { if ( ! mirrored || points == null || points . length < 3 ) { return ; } ResultPoint bottomLeft = points [ 0 ] ; points [ 0 ] = points [ 2 ] ; points [ 2 ] = bottomLeft ; }
Apply the result points order correction due to mirroring .
16,548
void setValue ( int value ) { Integer confidence = values . get ( value ) ; if ( confidence == null ) { confidence = 0 ; } confidence ++ ; values . put ( value , confidence ) ; }
Add an occurrence of a value
16,549
int [ ] getValue ( ) { int maxConfidence = - 1 ; Collection < Integer > result = new ArrayList < > ( ) ; for ( Entry < Integer , Integer > entry : values . entrySet ( ) ) { if ( entry . getValue ( ) > maxConfidence ) { maxConfidence = entry . getValue ( ) ; result . clear ( ) ; result . add ( entry . getKey ( ) ) ; } e...
Determines the maximum occurrence of a set value and returns all values which were set with this occurrence .
16,550
private Collection < State > updateStateListForChar ( Iterable < State > states , int index ) { Collection < State > result = new LinkedList < > ( ) ; for ( State state : states ) { updateStateForChar ( state , index , result ) ; } return simplifyStates ( result ) ; }
non - optimal states .
16,551
private void updateStateForChar ( State state , int index , Collection < State > result ) { char ch = ( char ) ( text [ index ] & 0xFF ) ; boolean charInCurrentTable = CHAR_MAP [ state . getMode ( ) ] [ ch ] > 0 ; State stateNoBinary = null ; for ( int mode = 0 ; mode <= MODE_PUNCT ; mode ++ ) { int charInMode = CHAR_M...
the result list .
16,552
public CharSequence getDisplayContents ( ) { String contents = getResult ( ) . getDisplayResult ( ) ; contents = contents . replace ( "\r" , "" ) ; return formatPhone ( contents ) ; }
Overriden so we can take advantage of Android s phone number hyphenation routines .
16,553
private void drawResultPoints ( Bitmap barcode , float scaleFactor , Result rawResult ) { ResultPoint [ ] points = rawResult . getResultPoints ( ) ; if ( points != null && points . length > 0 ) { Canvas canvas = new Canvas ( barcode ) ; Paint paint = new Paint ( ) ; paint . setColor ( getResources ( ) . getColor ( R . ...
Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode .
16,554
private ResultPoint [ ] centerEdges ( ResultPoint y , ResultPoint z , ResultPoint x , ResultPoint t ) { float yi = y . getX ( ) ; float yj = y . getY ( ) ; float zi = z . getX ( ) ; float zj = z . getY ( ) ; float xi = x . getX ( ) ; float xj = x . getY ( ) ; float ti = t . getX ( ) ; float tj = t . getY ( ) ; if ( yi ...
recenters the points of a constant distance towards the center
16,555
private boolean containsBlackPoint ( int a , int b , int fixed , boolean horizontal ) { if ( horizontal ) { for ( int x = a ; x <= b ; x ++ ) { if ( image . get ( x , fixed ) ) { return true ; } } } else { for ( int y = a ; y <= b ; y ++ ) { if ( image . get ( fixed , y ) ) { return true ; } } } return false ; }
Determines whether a segment contains a black point
16,556
private void addCalendarEvent ( String summary , long start , boolean allDay , long end , String location , String description , String [ ] attendees ) { Intent intent = new Intent ( Intent . ACTION_INSERT ) ; intent . setType ( "vnd.android.cursor.item/event" ) ; intent . putExtra ( "beginTime" , start ) ; if ( allDay...
Sends an intent to create a new calendar event by prepopulating the Add Event UI . Older versions of the system have a bug where the event title will not be filled out .
16,557
private static String getEncodedData ( boolean [ ] correctedBits ) { int endIndex = correctedBits . length ; Table latchTable = Table . UPPER ; Table shiftTable = Table . UPPER ; StringBuilder result = new StringBuilder ( 20 ) ; int index = 0 ; while ( index < endIndex ) { if ( shiftTable == Table . BINARY ) { if ( end...
Gets the string encoded in the aztec code bits
16,558
private static Table getTable ( char t ) { switch ( t ) { case 'L' : return Table . LOWER ; case 'P' : return Table . PUNCT ; case 'M' : return Table . MIXED ; case 'D' : return Table . DIGIT ; case 'B' : return Table . BINARY ; case 'U' : default : return Table . UPPER ; } }
gets the table corresponding to the char passed
16,559
private boolean [ ] extractBits ( BitMatrix matrix ) { boolean compact = ddata . isCompact ( ) ; int layers = ddata . getNbLayers ( ) ; int baseMatrixSize = ( compact ? 11 : 14 ) + layers * 4 ; int [ ] alignmentMap = new int [ baseMatrixSize ] ; boolean [ ] rawbits = new boolean [ totalBitsInLayer ( layers , compact ) ...
Gets the array of bits from an Aztec Code matrix
16,560
private static int readCode ( boolean [ ] rawbits , int startIndex , int length ) { int res = 0 ; for ( int i = startIndex ; i < startIndex + length ; i ++ ) { res <<= 1 ; if ( rawbits [ i ] ) { res |= 0x01 ; } } return res ; }
Reads a code of given length and at given index in an array of bits
16,561
private static byte readByte ( boolean [ ] rawbits , int startIndex ) { int n = rawbits . length - startIndex ; if ( n >= 8 ) { return ( byte ) readCode ( rawbits , startIndex , 8 ) ; } return ( byte ) ( readCode ( rawbits , startIndex , n ) << ( 8 - n ) ) ; }
Reads a code of length 8 in an array of bits padding with zeros
16,562
static byte [ ] convertBoolArrayToByteArray ( boolean [ ] boolArr ) { byte [ ] byteArr = new byte [ ( boolArr . length + 7 ) / 8 ] ; for ( int i = 0 ; i < byteArr . length ; i ++ ) { byteArr [ i ] = readByte ( boolArr , 8 * i ) ; } return byteArr ; }
Packs a bit array into bytes most significant bit first
16,563
public static String convertUPCEtoUPCA ( String upce ) { char [ ] upceChars = new char [ 6 ] ; upce . getChars ( 1 , 7 , upceChars , 0 ) ; StringBuilder result = new StringBuilder ( 12 ) ; result . append ( upce . charAt ( 0 ) ) ; char lastChar = upceChars [ 5 ] ; switch ( lastChar ) { case '0' : case '1' : case '2' : ...
Expands a UPC - E value back into its full equivalent UPC - A code value .
16,564
public Result decode ( BinaryBitmap image , Map < DecodeHintType , ? > hints ) throws NotFoundException { setHints ( hints ) ; return decodeInternal ( image ) ; }
Decode an image using the hints provided . Does not honor existing state .
16,565
private void utah ( int row , int col , int pos ) { module ( row - 2 , col - 2 , pos , 1 ) ; module ( row - 2 , col - 1 , pos , 2 ) ; module ( row - 1 , col - 2 , pos , 3 ) ; module ( row - 1 , col - 1 , pos , 4 ) ; module ( row - 1 , col , pos , 5 ) ; module ( row , col - 2 , pos , 6 ) ; module ( row , col - 1 , pos ,...
Places the 8 bits of a utah - shaped symbol character in ECC200 .
16,566
private static String massageURI ( String uri ) { uri = uri . trim ( ) ; int protocolEnd = uri . indexOf ( ':' ) ; if ( protocolEnd < 0 || isColonFollowedByPortNumber ( uri , protocolEnd ) ) { uri = "http://" + uri ; } return uri ; }
Transforms a string that represents a URI into something more proper by adding or canonicalizing the protocol .
16,567
public static SimplePageDecorator first ( ) { List < SimplePageDecorator > decorators = all ( ) ; return decorators . isEmpty ( ) ? null : decorators . get ( 0 ) ; }
The first found LoginDecarator there can only be one .
16,568
protected Map < Computer , T > monitor ( ) throws InterruptedException { Map < Computer , T > data = new HashMap < > ( ) ; for ( Computer c : Jenkins . getInstance ( ) . getComputers ( ) ) { try { Thread . currentThread ( ) . setName ( "Monitoring " + c . getDisplayName ( ) + " for " + getDisplayName ( ) ) ; if ( c . g...
Performs monitoring across the board .
16,569
public T get ( Computer c ) { if ( record == null || ! record . data . containsKey ( c ) ) { triggerUpdate ( ) ; return null ; } return record . data . get ( c ) ; }
Obtains the monitoring result currently available or null if no data is available .
16,570
public boolean isIgnored ( ) { NodeMonitor m = ComputerSet . getMonitors ( ) . get ( this ) ; return m == null || m . isIgnored ( ) ; }
Is this monitor currently ignored?
16,571
protected boolean markOnline ( Computer c ) { if ( isIgnored ( ) || c . isOnline ( ) ) return false ; c . setTemporarilyOffline ( false , null ) ; return true ; }
Utility method to mark the computer online for derived classes .
16,572
protected boolean markOffline ( Computer c , OfflineCause oc ) { if ( isIgnored ( ) || c . isTemporarilyOffline ( ) ) return false ; c . setTemporarilyOffline ( true , oc ) ; MonitorMarkedNodeOffline no = AdministrativeMonitor . all ( ) . get ( MonitorMarkedNodeOffline . class ) ; if ( no != null ) no . active = true ;...
Utility method to mark the computer offline for derived classes .
16,573
public String getCrumb ( ServletRequest request ) { String crumb = null ; if ( request != null ) { crumb = ( String ) request . getAttribute ( CRUMB_ATTRIBUTE ) ; } if ( crumb == null ) { crumb = issueCrumb ( request , getDescriptor ( ) . getCrumbSalt ( ) ) ; if ( request != null ) { if ( ( crumb != null ) && crumb . l...
Get a crumb value based on user specific information in the request .
16,574
public boolean validateCrumb ( ServletRequest request ) { CrumbIssuerDescriptor < CrumbIssuer > desc = getDescriptor ( ) ; String crumbField = desc . getCrumbRequestField ( ) ; String crumbSalt = desc . getCrumbSalt ( ) ; return validateCrumb ( request , crumbSalt , request . getParameter ( crumbField ) ) ; }
Get a crumb from a request parameter and validate it against other data in the current request . The salt and request parameter that is used is defined by the current configuration .
16,575
public boolean validateCrumb ( ServletRequest request , MultipartFormDataParser parser ) { CrumbIssuerDescriptor < CrumbIssuer > desc = getDescriptor ( ) ; String crumbField = desc . getCrumbRequestField ( ) ; String crumbSalt = desc . getCrumbSalt ( ) ; return validateCrumb ( request , crumbSalt , parser . get ( crumb...
Get a crumb from multipart form data and validate it against other data in the current request . The salt and request parameter that is used is defined by the current configuration .
16,576
public static void initStaplerCrumbIssuer ( ) { WebApp . get ( Jenkins . getInstance ( ) . servletContext ) . setCrumbIssuer ( new org . kohsuke . stapler . CrumbIssuer ( ) { public String issueCrumb ( StaplerRequest request ) { CrumbIssuer ci = Jenkins . getInstance ( ) . getCrumbIssuer ( ) ; return ci != null ? ci . ...
Sets up Stapler to use our crumb issuer .
16,577
public String getPublicKey ( ) { RSAPublicKey key = InstanceIdentityProvider . RSA . getPublicKey ( ) ; if ( key == null ) { return null ; } byte [ ] encoded = Base64 . encodeBase64 ( key . getEncoded ( ) ) ; int index = 0 ; StringBuilder buf = new StringBuilder ( encoded . length + 20 ) ; while ( index < encoded . len...
Returns the PEM encoded public key .
16,578
public String getFingerprint ( ) { RSAPublicKey key = InstanceIdentityProvider . RSA . getPublicKey ( ) ; if ( key == null ) { return null ; } try { MessageDigest digest = MessageDigest . getInstance ( "MD5" ) ; digest . reset ( ) ; byte [ ] bytes = digest . digest ( key . getEncoded ( ) ) ; StringBuilder result = new ...
Returns the fingerprint of the public key .
16,579
public void doJson ( StaplerRequest req , StaplerResponse rsp ) throws IOException , ServletException { if ( req . getParameter ( "jsonp" ) == null || permit ( req ) ) { setHeaders ( rsp ) ; rsp . serveExposedBean ( req , bean , req . getParameter ( "jsonp" ) == null ? Flavor . JSON : Flavor . JSONP ) ; } else { rsp . ...
Exposes the bean as JSON .
16,580
public void doPython ( StaplerRequest req , StaplerResponse rsp ) throws IOException , ServletException { setHeaders ( rsp ) ; rsp . serveExposedBean ( req , bean , Flavor . PYTHON ) ; }
Exposes the bean as Python literal .
16,581
@ Restricted ( NoExternalUse . class ) public static CauseAction getBuildCause ( ParameterizedJob job , StaplerRequest req ) { Cause cause ; @ SuppressWarnings ( "deprecation" ) hudson . model . BuildAuthorizationToken authToken = job . getAuthToken ( ) ; if ( authToken != null && authToken . getToken ( ) != null && re...
Computes the build cause using RemoteCause or UserCause as appropriate .
16,582
public static < T extends Trigger < ? > > T getTrigger ( Job < ? , ? > job , Class < T > clazz ) { if ( ! ( job instanceof ParameterizedJob ) ) { return null ; } for ( Trigger < ? > t : ( ( ParameterizedJob < ? , ? > ) job ) . getTriggers ( ) . values ( ) ) { if ( clazz . isInstance ( t ) ) { return clazz . cast ( t ) ...
Checks for the existence of a specific trigger on a job .
16,583
public synchronized String get ( ) { ConfidentialStore cs = ConfidentialStore . get ( ) ; if ( secret == null || cs != lastCS ) { lastCS = cs ; try { byte [ ] payload = load ( ) ; if ( payload == null ) { payload = cs . randomBytes ( length / 2 ) ; store ( payload ) ; } secret = Util . toHexString ( payload ) . substri...
Returns the persisted hex string value .
16,584
public void replaceBy ( Map < ? extends K , ? extends V > data ) { Map < K , V > d = copy ( ) ; d . clear ( ) ; d . putAll ( data ) ; update ( d ) ; }
Atomically replaces the entire map by the copy of the specified map .
16,585
public FilePath getWorkspaceRoot ( ) { FilePath r = getRootPath ( ) ; if ( r == null ) return null ; return r . child ( WORKSPACE_ROOT ) ; }
Root directory on this agent where all the job workspaces are laid out .
16,586
public Launcher createLauncher ( TaskListener listener ) { SlaveComputer c = getComputer ( ) ; if ( c == null ) { listener . error ( "Issue with creating launcher for agent " + name + ". Computer has been disconnected" ) ; return new Launcher . DummyLauncher ( listener ) ; } else { Slave node = c . getNode ( ) ; if ( n...
Creates a launcher for the agent .
16,587
public static void skip ( DataInputStream in ) throws IOException { byte [ ] preamble = new byte [ PREAMBLE . length ] ; in . readFully ( preamble ) ; if ( ! Arrays . equals ( preamble , PREAMBLE ) ) return ; DataInputStream decoded = new DataInputStream ( new UnbufferedBase64InputStream ( in ) ) ; int macSz = - decode...
Skips the encoded console note .
16,588
public static int findPreamble ( byte [ ] buf , int start , int len ) { int e = start + len - PREAMBLE . length + 1 ; OUTER : for ( int i = start ; i < e ; i ++ ) { if ( buf [ i ] == PREAMBLE [ 0 ] ) { for ( int j = 1 ; j < PREAMBLE . length ; j ++ ) { if ( buf [ i + j ] != PREAMBLE [ j ] ) continue OUTER ; } return i ...
Locates the preamble in the given buffer .
16,589
public static List < String > removeNotes ( Collection < String > logLines ) { List < String > r = new ArrayList < > ( logLines . size ( ) ) ; for ( String l : logLines ) r . add ( removeNotes ( l ) ) ; return r ; }
Removes the embedded console notes in the given log lines .
16,590
public static String removeNotes ( String line ) { while ( true ) { int idx = line . indexOf ( PREAMBLE_STR ) ; if ( idx < 0 ) return line ; int e = line . indexOf ( POSTAMBLE_STR , idx ) ; if ( e < 0 ) return line ; line = line . substring ( 0 , idx ) + line . substring ( e + POSTAMBLE_STR . length ( ) ) ; } }
Removes the embedded console notes in the given log line .
16,591
protected String getDisplayNameOf ( Method e , T i ) { Class < ? > c = e . getDeclaringClass ( ) ; String key = displayNameOf ( i ) ; if ( key . length ( ) == 0 ) return c . getSimpleName ( ) + "." + e . getName ( ) ; try { ResourceBundleHolder rb = ResourceBundleHolder . get ( c . getClassLoader ( ) . loadClass ( c . ...
Obtains the display name of the given initialization task
16,592
protected void invoke ( Method e ) { try { Class < ? > [ ] pt = e . getParameterTypes ( ) ; Object [ ] args = new Object [ pt . length ] ; for ( int i = 0 ; i < args . length ; i ++ ) args [ i ] = lookUp ( pt [ i ] ) ; e . invoke ( Modifier . isStatic ( e . getModifiers ( ) ) ? null : lookUp ( e . getDeclaringClass ( )...
Invokes the given initialization method .
16,593
private Object lookUp ( Class < ? > type ) { Jenkins j = Jenkins . getInstance ( ) ; assert j != null : "This method is only invoked after the Jenkins singleton instance has been set" ; if ( type == Jenkins . class || type == Hudson . class ) return j ; Injector i = j . getInjector ( ) ; if ( i != null ) return i . get...
Determines the parameter injection of the initialization method .
16,594
public String getDescription ( ) { Stapler stapler = Stapler . getCurrent ( ) ; if ( stapler != null ) { try { WebApp webapp = WebApp . getCurrent ( ) ; MetaClass meta = webapp . getMetaClass ( this ) ; Script s = meta . loadTearOff ( JellyClassTearOff . class ) . findScript ( "newInstanceDetail" ) ; if ( s == null ) {...
A description of this kind of item type . This description can contain HTML code but it is recommended that you use plain text in order to be consistent with the rest of Jenkins .
16,595
public String getIconFilePath ( String size ) { if ( ! StringUtils . isBlank ( getIconFilePathPattern ( ) ) ) { return getIconFilePathPattern ( ) . replace ( ":size" , size ) ; } return null ; }
An icon file path associated to a specific size .
16,596
public MavenInstallation getMaven ( ) { for ( MavenInstallation i : getDescriptor ( ) . getInstallations ( ) ) { if ( mavenName != null && mavenName . equals ( i . getName ( ) ) ) return i ; } return null ; }
Gets the Maven to invoke or null to invoke the default one .
16,597
protected void buildEnvVars ( EnvVars env , MavenInstallation mi ) throws IOException , InterruptedException { if ( mi != null ) { mi . buildEnvVars ( env ) ; } env . put ( "MAVEN_TERMINATE_CMD" , "on" ) ; String jvmOptions = env . expand ( this . jvmOptions ) ; if ( jvmOptions != null ) env . put ( "MAVEN_OPTS" , jvmO...
Build up the environment variables toward the Maven launch .
16,598
public static boolean checkIsReachable ( InetAddress ia , int timeout ) throws IOException { for ( ComputerPinger pinger : ComputerPinger . all ( ) ) { try { if ( pinger . isReachable ( ia , timeout ) ) { return true ; } } catch ( IOException e ) { LOGGER . fine ( "Error checking reachability with " + pinger + ": " + e...
Is this computer reachable via the given address?
16,599
protected PluginStrategy createPluginStrategy ( ) { String strategyName = SystemProperties . getString ( PluginStrategy . class . getName ( ) ) ; if ( strategyName != null ) { try { Class < ? > klazz = getClass ( ) . getClassLoader ( ) . loadClass ( strategyName ) ; Object strategy = klazz . getConstructor ( PluginMana...
Creates a hudson . PluginStrategy looking at the corresponding system property .