idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
5,100
public static void downloadImageToFile ( String url , Path file ) throws IOException { if ( Files . exists ( file . getParent ( ) ) ) { URL urlObject = new URL ( url ) ; URLConnection connection = urlObject . openConnection ( ) ; connection . setRequestProperty ( "User-Agent" , "Mozilla/5.0 (Windows; U; WindowsNT 5.1; ...
Downloads an image to a file with the adequate headers to the http query
168
15
5,101
static String getSherdogPageUrl ( Document doc ) { String url = Optional . ofNullable ( doc . head ( ) ) . map ( h -> h . select ( "meta" ) ) . map ( es -> es . stream ( ) . filter ( e -> e . attr ( "property" ) . equalsIgnoreCase ( "og:url" ) ) . findFirst ( ) . orElse ( null ) ) . map ( m -> m . attr ( "content" ) ) ...
Gets the url of a page using the meta tags in head
178
13
5,102
@ Override public void visitJumpInsn ( final int opcode , final Label lbl ) { super . visitJumpInsn ( opcode , lbl ) ; LabelNode ln = ( ( JumpInsnNode ) instructions . getLast ( ) ) . label ; if ( opcode == JSR && ! subroutineHeads . containsKey ( ln ) ) { subroutineHeads . put ( ln , new BitSet ( ) ) ; } }
Detects a JSR instruction and sets a flag to indicate we will need to do inlining .
100
20
5,103
@ Override public void visitEnd ( ) { if ( ! subroutineHeads . isEmpty ( ) ) { markSubroutines ( ) ; if ( LOGGING ) { log ( mainSubroutine . toString ( ) ) ; Iterator < BitSet > it = subroutineHeads . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { BitSet sub = it . next ( ) ; log ( sub . toString ( ) ) ; } } ...
If any JSRs were seen triggers the inlining process . Otherwise forwards the byte codes untouched .
139
20
5,104
private void emitCode ( ) { LinkedList < Instantiation > worklist = new LinkedList < Instantiation > ( ) ; // Create an instantiation of the "root" subroutine, which is just the // main routine worklist . add ( new Instantiation ( null , mainSubroutine ) ) ; // Emit instantiations of each subroutine we encounter, inclu...
Creates the new instructions inlining each instantiation of each subroutine until the code is fully elaborated .
228
22
5,105
private static void getDescriptor ( final StringBuffer buf , final Class < ? > c ) { Class < ? > d = c ; while ( true ) { if ( d . isPrimitive ( ) ) { char car ; if ( d == Integer . TYPE ) { car = ' ' ; } else if ( d == Void . TYPE ) { car = ' ' ; } else if ( d == Boolean . TYPE ) { car = ' ' ; } else if ( d == Byte . ...
Appends the descriptor of the given class to the given string buffer .
317
14
5,106
static Handler remove ( Handler h , Label start , Label end ) { if ( h == null ) { return null ; } else { h . next = remove ( h . next , start , end ) ; } int hstart = h . start . position ; int hend = h . end . position ; int s = start . position ; int e = end == null ? Integer . MAX_VALUE : end . position ; // if [hs...
Removes the range between start and end from the given exception handlers .
323
14
5,107
public void check ( final int api ) { if ( api == Opcodes . ASM4 ) { if ( visibleTypeAnnotations != null && visibleTypeAnnotations . size ( ) > 0 ) { throw new RuntimeException ( ) ; } if ( invisibleTypeAnnotations != null && invisibleTypeAnnotations . size ( ) > 0 ) { throw new RuntimeException ( ) ; } for ( FieldNode...
Checks that this class node is compatible with the given ASM API version . This methods checks that this node and all its nodes recursively do not contain elements that were introduced in more recent versions of the ASM API than the given version .
115
50
5,108
public void accept ( final ClassVisitor cv ) { // visits header String [ ] interfaces = new String [ this . interfaces . size ( ) ] ; this . interfaces . toArray ( interfaces ) ; cv . visit ( version , access , name , signature , superName , interfaces ) ; // visits source if ( sourceFile != null || sourceDebug != null...
Makes the given class visitor visit this class .
593
10
5,109
public void run ( ) { this . running = true ; while ( this . running ) { DatagramPacket packet = new DatagramPacket ( this . buf , this . buf . length ) ; try { this . socket . receive ( packet ) ; } catch ( IOException ignored ) { continue ; } byte [ ] worker = new byte [ 2 ] ; System . arraycopy ( this . buf , 2 , wo...
Start the de . sg_o . app . miio . server .
397
16
5,110
@ Override public final void startElement ( final String ns , final String lName , final String qName , final Attributes list ) throws SAXException { // the actual element name is either in lName or qName, depending // on whether the parser is namespace aware String name = lName == null || lName . length ( ) == 0 ? qNa...
Process notification of the start of an XML element being reached .
179
12
5,111
@ Override public final void endElement ( final String ns , final String lName , final String qName ) throws SAXException { // the actual element name is either in lName or qName, depending // on whether the parser is namespace aware String name = lName == null || lName . length ( ) == 0 ? qName : lName ; // Fire "end"...
Process notification of the end of an XML element being reached .
164
12
5,112
public AbstractInsnNode get ( final int index ) { if ( index < 0 || index >= size ) { throw new IndexOutOfBoundsException ( ) ; } if ( cache == null ) { cache = toArray ( ) ; } return cache [ index ] ; }
Returns the instruction whose index is given . This method builds a cache of the instructions in this list to avoid scanning the whole list each time it is called . Once the cache is built this method run in constant time . This cache is invalidated by all the methods that modify the list .
57
57
5,113
public void accept ( final MethodVisitor mv ) { AbstractInsnNode insn = first ; while ( insn != null ) { insn . accept ( mv ) ; insn = insn . next ; } }
Makes the given visitor visit all of the instructions in this list .
48
14
5,114
public AbstractInsnNode [ ] toArray ( ) { int i = 0 ; AbstractInsnNode elem = first ; AbstractInsnNode [ ] insns = new AbstractInsnNode [ size ] ; while ( elem != null ) { insns [ i ] = elem ; elem . index = i ++ ; elem = elem . next ; } return insns ; }
Returns an array containing all of the instructions in this list .
83
12
5,115
public void set ( final AbstractInsnNode location , final AbstractInsnNode insn ) { AbstractInsnNode next = location . next ; insn . next = next ; if ( next != null ) { next . prev = insn ; } else { last = insn ; } AbstractInsnNode prev = location . prev ; insn . prev = prev ; if ( prev != null ) { prev . next = insn ;...
Replaces an instruction of this list with another instruction .
180
11
5,116
public void add ( final AbstractInsnNode insn ) { ++ size ; if ( last == null ) { first = insn ; last = insn ; } else { last . next = insn ; insn . prev = last ; } last = insn ; cache = null ; insn . index = 0 ; // insn now belongs to an InsnList }
Adds the given instruction to the end of this list .
78
11
5,117
public void insert ( final AbstractInsnNode insn ) { ++ size ; if ( first == null ) { first = insn ; last = insn ; } else { first . prev = insn ; insn . next = first ; } first = insn ; cache = null ; insn . index = 0 ; // insn now belongs to an InsnList }
Inserts the given instruction at the begining of this list .
78
13
5,118
public void insert ( final InsnList insns ) { if ( insns . size == 0 ) { return ; } size += insns . size ; if ( first == null ) { first = insns . first ; last = insns . last ; } else { AbstractInsnNode elem = insns . last ; first . prev = elem ; elem . next = first ; first = insns . first ; } cache = null ; insns . rem...
Inserts the given instructions at the begining of this list .
104
13
5,119
public void insert ( final AbstractInsnNode location , final AbstractInsnNode insn ) { ++ size ; AbstractInsnNode next = location . next ; if ( next == null ) { last = insn ; } else { next . prev = insn ; } location . next = insn ; insn . next = next ; insn . prev = location ; cache = null ; insn . index = 0 ; // insn ...
Inserts the given instruction after the specified instruction .
99
10
5,120
public void insert ( final AbstractInsnNode location , final InsnList insns ) { if ( insns . size == 0 ) { return ; } size += insns . size ; AbstractInsnNode ifirst = insns . first ; AbstractInsnNode ilast = insns . last ; AbstractInsnNode next = location . next ; if ( next == null ) { last = ilast ; } else { next . pr...
Inserts the given instructions after the specified instruction .
131
10
5,121
public void insertBefore ( final AbstractInsnNode location , final AbstractInsnNode insn ) { ++ size ; AbstractInsnNode prev = location . prev ; if ( prev == null ) { first = insn ; } else { prev . next = insn ; } location . prev = insn ; insn . next = location ; insn . prev = prev ; cache = null ; insn . index = 0 ; /...
Inserts the given instruction before the specified instruction .
100
10
5,122
public void insertBefore ( final AbstractInsnNode location , final InsnList insns ) { if ( insns . size == 0 ) { return ; } size += insns . size ; AbstractInsnNode ifirst = insns . first ; AbstractInsnNode ilast = insns . last ; AbstractInsnNode prev = location . prev ; if ( prev == null ) { first = ifirst ; } else { p...
Inserts the given instructions before the specified instruction .
132
10
5,123
public void remove ( final AbstractInsnNode insn ) { -- size ; AbstractInsnNode next = insn . next ; AbstractInsnNode prev = insn . prev ; if ( next == null ) { if ( prev == null ) { first = null ; last = null ; } else { prev . next = null ; last = prev ; } } else { if ( prev == null ) { first = next ; next . prev = nu...
Removes the given instruction from this list .
149
9
5,124
void removeAll ( final boolean mark ) { if ( mark ) { AbstractInsnNode insn = first ; while ( insn != null ) { AbstractInsnNode next = insn . next ; insn . index = - 1 ; // insn no longer belongs to an InsnList insn . prev = null ; insn . next = null ; insn = next ; } } size = 0 ; first = null ; last = null ; cache = n...
Removes all of the instructions of this list .
99
10
5,125
@ Override public Event parseDocument ( Document doc ) { Event event = new Event ( ) ; event . setSherdogUrl ( ParserUtils . getSherdogPageUrl ( doc ) ) ; //getting name Elements name = doc . select ( ".header .section_title h1 span[itemprop=\"name\"]" ) ; event . setName ( name . html ( ) . replace ( "<br>" , " - " ) ...
parses an event from a jsoup document
305
10
5,126
private void getFights ( Document doc , Event event ) { logger . info ( "Getting fights for event #{}[{}]" , event . getSherdogUrl ( ) , event . getName ( ) ) ; SherdogBaseObject sEvent = new SherdogBaseObject ( ) ; sEvent . setName ( event . getName ( ) ) ; sEvent . setSherdogUrl ( event . getSherdogUrl ( ) ) ; List <...
Gets the fight of the event
667
7
5,127
private List < Fight > parseEventFights ( Elements trs , Event event ) { SherdogBaseObject sEvent = new SherdogBaseObject ( ) ; sEvent . setName ( event . getName ( ) ) ; sEvent . setSherdogUrl ( event . getSherdogUrl ( ) ) ; List < Fight > fights = new ArrayList <> ( ) ; if ( trs . size ( ) > 0 ) { trs . remove ( 0 ) ...
Parse fights of an old event
357
7
5,128
private SherdogBaseObject getFighter ( Element td ) { Elements name1 = td . select ( "span[itemprop=\"name\"]" ) ; if ( name1 . size ( ) > 0 ) { String name = name1 . get ( 0 ) . html ( ) ; Elements select = td . select ( "a[itemprop=\"url\"]" ) ; if ( select . size ( ) > 0 ) { String url = select . get ( 0 ) . attr ( ...
Get a fighter
149
3
5,129
private List < Event > parseEvent ( Elements trs , Organization organization ) throws ParseException { List < Event > events = new ArrayList <> ( ) ; if ( trs . size ( ) > 0 ) { trs . remove ( 0 ) ; SherdogBaseObject sOrg = new SherdogBaseObject ( ) ; sOrg . setName ( organization . getName ( ) ) ; sOrg . setSherdogUrl...
Get all the events of an organization
307
7
5,130
public void reset ( String name ) { if ( name . equals ( Names . MAIN_BRUSH . toString ( ) ) ) mainBrushWorkTime = 0 ; if ( name . equals ( Names . SENSOR . toString ( ) ) ) sensorTimeSinceCleaning = 0 ; if ( name . equals ( Names . SIDE_BRUSH . toString ( ) ) ) sideBrushWorkTime = 0 ; if ( name . equals ( Names . FILT...
Reset a consumable .
114
6
5,131
@ Override public void accept ( final MethodVisitor mv ) { switch ( type ) { case Opcodes . F_NEW : case Opcodes . F_FULL : mv . visitFrame ( type , local . size ( ) , asArray ( local ) , stack . size ( ) , asArray ( stack ) ) ; break ; case Opcodes . F_APPEND : mv . visitFrame ( type , local . size ( ) , asArray ( loc...
Makes the given visitor visit this stack map frame .
203
11
5,132
public Organization getOrganizationFromHtml ( String html ) throws IOException , ParseException , SherdogParserException { return new OrganizationParser ( zoneId ) . parseFromHtml ( html ) ; }
Gets an organization via it s sherdog page HTML in case you want to have your own way of getting teh HTML content
43
26
5,133
public Event getEventFromHtml ( String html ) throws IOException , ParseException , SherdogParserException { return new EventParser ( zoneId ) . parseFromHtml ( html ) ; }
Gets an event via it s shergog page HTML
42
12
5,134
public Event getEvent ( String sherdogUrl ) throws IOException , ParseException , SherdogParserException { return new EventParser ( zoneId ) . parse ( sherdogUrl ) ; }
Gets an event via it s sherdog URL .
40
11
5,135
public Fighter getFighterFromHtml ( String html ) throws IOException , ParseException , SherdogParserException { return new FighterParser ( pictureProcessor , zoneId ) . parseFromHtml ( html ) ; }
Get a fighter via it ; s sherdog page HTML
47
11
5,136
public Fighter getFighter ( String sherdogUrl ) throws IOException , ParseException , SherdogParserException { return new FighterParser ( pictureProcessor , zoneId ) . parse ( sherdogUrl ) ; }
Get a fighter via it ; s sherdog URL .
45
11
5,137
public static Object createProxyBean ( Class < ? > clazz , BeanBox box , BeanBoxContext ctx ) { BeanBoxException . assureNotNull ( clazz , "Try to create a proxy bean, but beanClass not found." ) ; Enhancer enhancer = new Enhancer ( ) ; enhancer . setSuperclass ( clazz ) ; if ( box . getConstructorParams ( ) != null &&...
Create a ProxyBean
324
5
5,138
public Map < Prop . Names , String > getProps ( Prop . Names [ ] props ) throws CommandExecutionException { Prop prop = new Prop ( props ) ; return prop . parseResponse ( sendToArray ( "get_prop" , prop . getRequestArray ( ) ) ) ; }
Get several property values at once from the device .
62
10
5,139
public String getSingleProp ( Prop . Names prop ) throws CommandExecutionException { Map < Prop . Names , String > value = getProps ( new Prop . Names [ ] { prop } ) ; String valueString = value . get ( prop ) ; if ( valueString == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID...
Get a single property value from the device .
89
9
5,140
public int getIntProp ( Prop . Names prop ) throws CommandExecutionException { String value = getSingleProp ( prop ) ; if ( value . equals ( "" ) ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_RESPONSE ) ; try { return Integer . valueOf ( value ) ; } catch ( Exception e ) { throw ne...
Get a single property value and try to convert it to an int .
104
14
5,141
public boolean powerOffAfterTime ( int minutes ) throws CommandExecutionException { JSONArray col = new JSONArray ( ) ; col . put ( 0 ) ; col . put ( minutes ) ; return sendOk ( "cron_add" , col ) ; }
Power the device off after some time .
55
8
5,142
public static BeanBox getUniqueBeanBox ( BeanBoxContext ctx , Class < ? > clazz ) { BeanBoxException . assureNotNull ( clazz , "Target class can not be null" ) ; BeanBox box = ctx . beanBoxMetaCache . get ( clazz ) ; if ( box != null ) return box ; if ( BeanBox . class . isAssignableFrom ( clazz ) ) try { box = ( BeanB...
Translate a BeanBox class or normal class to a readOnly BeanBox instance
175
16
5,143
private static Annotation [ ] getAnnotations ( Object targetClass ) { if ( targetClass instanceof Field ) return ( ( Field ) targetClass ) . getAnnotations ( ) ; else if ( targetClass instanceof Method ) return ( ( Method ) targetClass ) . getAnnotations ( ) ; else if ( targetClass instanceof Constructor ) return ( ( C...
give a class or Field or Method return annotations
144
9
5,144
private static Map < String , Object > getAnnoAsMap ( Object targetClass , String annoFullName ) { Annotation [ ] anno = getAnnotations ( targetClass ) ; for ( Annotation a : anno ) { Class < ? extends Annotation > type = a . annotationType ( ) ; if ( annoFullName . equals ( type . getName ( ) ) ) return changeAnnotati...
Return all annotations for Class or Field
99
7
5,145
private static boolean checkAnnoExist ( Object targetClass , Class < ? > annoClass ) { Annotation [ ] anno = getAnnotations ( targetClass ) ; for ( Annotation annotation : anno ) { Class < ? extends Annotation > type = annotation . annotationType ( ) ; if ( annoClass . equals ( type ) ) return true ; } return false ; }
Check if annotation exist in Class or Field
82
8
5,146
protected static BeanBox wrapParamToBox ( Object param ) { if ( param != null ) { if ( param instanceof Class ) return new BeanBox ( ) . setTarget ( param ) ; if ( param instanceof BeanBox ) return ( BeanBox ) param ; } return new BeanBox ( ) . setAsValue ( param ) ; }
If param is class wrap it to BeanBox if param is BeanBox instance direct return it otherwise wrap it as pure Value BeanBox
71
26
5,147
public static String [ ] addConfigurationClasses ( String [ ] configurationClasses , AdditionalWebAppJettyConfigurationClass [ ] optionalAdditionalsWebappConfigurationClasses ) { List < String > newConfigurationClasses = new ArrayList <> ( Arrays . asList ( configurationClasses ) ) ; for ( AdditionalWebAppJettyConfigur...
Add the optionalAdditionalsWebappConfigurationClasses to the configurationClasses if available
532
18
5,148
public void catchException ( final Label start , final Label end , final Type exception ) { if ( exception == null ) { mv . visitTryCatchBlock ( start , end , mark ( ) , null ) ; } else { mv . visitTryCatchBlock ( start , end , mark ( ) , exception . getInternalName ( ) ) ; } }
Marks the start of an exception handler .
76
9
5,149
public static StringSwitcher create ( String [ ] strings , int [ ] ints , boolean fixedInput ) { Generator gen = new Generator ( ) ; gen . setStrings ( strings ) ; gen . setInts ( ints ) ; gen . setFixedInput ( fixedInput ) ; return gen . create ( ) ; }
Helper method to create a StringSwitcher . For finer control over the generated instance use a new instance of StringSwitcher . Generator instead of this static method .
68
32
5,150
public Map /*<Signature, Signature>*/ resolveAll ( ) { Map resolved = new HashMap ( ) ; for ( Iterator entryIter = declToBridge . entrySet ( ) . iterator ( ) ; entryIter . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) entryIter . next ( ) ; Class owner = ( Class ) entry . getKey ( ) ; Set bridges = ( Set ) entr...
Finds all bridge methods that are being called with invokespecial & returns them .
156
18
5,151
public void check ( final int api ) { if ( api == Opcodes . ASM4 ) { if ( visibleTypeAnnotations != null && visibleTypeAnnotations . size ( ) > 0 ) { throw new RuntimeException ( ) ; } if ( invisibleTypeAnnotations != null && invisibleTypeAnnotations . size ( ) > 0 ) { throw new RuntimeException ( ) ; } } }
Checks that this field node is compatible with the given ASM API version . This methods checks that this node and all its nodes recursively do not contain elements that were introduced in more recent versions of the ASM API than the given version .
81
50
5,152
public void accept ( final ClassVisitor cv ) { FieldVisitor fv = cv . visitField ( access , name , desc , signature , value ) ; if ( fv == null ) { return ; } int i , n ; n = visibleAnnotations == null ? 0 : visibleAnnotations . size ( ) ; for ( i = 0 ; i < n ; ++ i ) { AnnotationNode an = visibleAnnotations . get ( i ...
Makes the given class visitor visit this field .
400
10
5,153
protected byte [ ] computeSHAdigest ( final byte [ ] value ) { try { return MessageDigest . getInstance ( "SHA" ) . digest ( value ) ; } catch ( Exception e ) { throw new UnsupportedOperationException ( e . toString ( ) ) ; } }
Returns the SHA - 1 message digest of the given value .
61
12
5,154
private static void writeItems ( final Collection < Item > itemCollection , final DataOutput dos , final boolean dotted ) throws IOException { int size = itemCollection . size ( ) ; Item [ ] items = itemCollection . toArray ( new Item [ size ] ) ; Arrays . sort ( items ) ; for ( int i = 0 ; i < size ; i ++ ) { dos . wr...
Sorts the items in the collection and writes it to the data output stream
137
15
5,155
public VacuumStatus status ( ) throws CommandExecutionException { JSONArray resp = sendToArray ( "get_status" ) ; JSONObject stat = resp . optJSONObject ( 0 ) ; if ( stat == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_RESPONSE ) ; return new VacuumStatus ( stat ) ; }
Get the vacuums status .
81
7
5,156
public TimeZone getTimezone ( ) throws CommandExecutionException { JSONArray resp = sendToArray ( "get_timezone" ) ; String zone = resp . optString ( 0 , null ) ; if ( zone == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_RESPONSE ) ; return TimeZone . getTimeZone ( zone ) ; }
Get the vacuums current timezone .
85
9
5,157
public boolean setTimezone ( TimeZone zone ) throws CommandExecutionException { if ( zone == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_PARAMETERS ) ; JSONArray tz = new JSONArray ( ) ; tz . put ( zone . getID ( ) ) ; return sendOk ( "set_timezone" , tz ) ; }
Set the vacuums timezone
86
7
5,158
public VacuumConsumableStatus consumableStatus ( ) throws CommandExecutionException { JSONArray resp = sendToArray ( "get_consumable" ) ; JSONObject stat = resp . optJSONObject ( 0 ) ; if ( stat == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_RESPONSE ) ; return new VacuumCon...
Get the vacuums consumables status .
91
9
5,159
public boolean resetConsumable ( VacuumConsumableStatus . Names consumable ) throws CommandExecutionException { if ( consumable == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_PARAMETERS ) ; JSONArray params = new JSONArray ( ) ; params . put ( consumable . toString ( ) ) ; r...
Reset a vacuums consumable .
94
9
5,160
public int getFanSpeed ( ) throws CommandExecutionException { int resp = sendToArray ( "get_custom_mode" ) . optInt ( 0 , - 1 ) ; if ( ( resp < 0 ) || ( resp > 100 ) ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_RESPONSE ) ; return resp ; }
Get the vacuums current fan speed setting .
80
10
5,161
public boolean setFanSpeed ( int speed ) throws CommandExecutionException { if ( speed < 0 || speed > 100 ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_PARAMETERS ) ; JSONArray params = new JSONArray ( ) ; params . put ( speed ) ; return sendOk ( "set_custom_mode" , params ) ; }
Set the vacuums fan speed setting .
82
9
5,162
public VacuumTimer [ ] getTimers ( ) throws CommandExecutionException { JSONArray tm = sendToArray ( "get_timer" ) ; if ( tm == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_RESPONSE ) ; VacuumTimer [ ] timers = new VacuumTimer [ tm . length ( ) ] ; for ( int i = 0 ; i < tm . ...
Get all stored scheduled cleanups .
130
7
5,163
public boolean addTimer ( VacuumTimer timer ) throws CommandExecutionException { if ( timer == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_PARAMETERS ) ; JSONArray tm = timer . construct ( ) ; if ( tm == null ) return false ; JSONArray payload = new JSONArray ( ) ; payload ....
Add a new scheduled cleanup .
99
6
5,164
public boolean setTimerEnabled ( VacuumTimer timer ) throws CommandExecutionException { if ( timer == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_PARAMETERS ) ; JSONArray payload = new JSONArray ( ) ; payload . put ( timer . getID ( ) ) ; payload . put ( timer . getOnOff ( )...
Enable or disable a scheduled cleanup .
97
7
5,165
public boolean removeTimer ( VacuumTimer timer ) throws CommandExecutionException { if ( timer == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_PARAMETERS ) ; JSONArray payload = new JSONArray ( ) ; payload . put ( timer . getID ( ) ) ; return sendOk ( "del_timer" , payload ) ...
Delete a scheduled cleanup .
82
5
5,166
public boolean setDoNotDisturb ( VacuumDoNotDisturb dnd ) throws CommandExecutionException { if ( dnd == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_PARAMETERS ) ; return sendOk ( "set_dnd_timer" , dnd . construct ( ) ) ; }
Set the do not disturb timer .
76
7
5,167
public boolean goTo ( int [ ] p ) throws CommandExecutionException { if ( p == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_PARAMETERS ) ; if ( p . length != 2 ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_PARAMETERS ) ; JSONArray payload...
Go to the specified position on the map .
125
9
5,168
public VacuumCleanup [ ] getAllCleanups ( ) throws CommandExecutionException { JSONArray cleanupIDs = getCleaningSummary ( ) . optJSONArray ( 3 ) ; if ( cleanupIDs == null ) return null ; VacuumCleanup [ ] res = new VacuumCleanup [ cleanupIDs . length ( ) ] ; for ( int i = 0 ; i < cleanupIDs . length ( ) ; i ++ ) { JSO...
Get an array with the details of all cleanups .
159
11
5,169
public int getSoundVolume ( ) throws CommandExecutionException { JSONArray res = sendToArray ( "get_sound_volume" ) ; if ( res == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_RESPONSE ) ; int vol = res . optInt ( 0 , - 1 ) ; if ( vol < 0 ) throw new CommandExecutionException ...
Get the current volume .
108
5
5,170
public boolean setSoundVolume ( int volume ) throws CommandExecutionException { if ( volume < 0 ) volume = 0 ; if ( volume > 100 ) volume = 100 ; JSONArray payload = new JSONArray ( ) ; payload . put ( volume ) ; return sendOk ( "change_sound_volume" , payload ) ; }
Set the vacuums volume .
68
7
5,171
public boolean manualControlMove ( float rotationSpeed , float speed , int runDuration ) throws CommandExecutionException { if ( manualControlSequence < 1 ) manualControlStart ( ) ; JSONObject payload = new JSONObject ( ) ; if ( rotationSpeed > 180.0f ) rotationSpeed = 180.0f ; if ( rotationSpeed < - 180.0f ) rotationS...
Manually control the robot
263
5
5,172
public VacuumSounpackInstallState installSoundpack ( String url , String md5 , int soundId ) throws CommandExecutionException { if ( url == null || md5 == null ) throw new CommandExecutionException ( CommandExecutionException . Error . INVALID_PARAMETERS ) ; JSONObject install = new JSONObject ( ) ; install . put ( "ur...
Install a new soundpack to the device .
160
9
5,173
public VacuumSounpackInstallState soundpackInstallStatus ( ) throws CommandExecutionException { JSONArray ret = sendToArray ( "get_sound_progress" ) ; if ( ret == null ) return null ; return new VacuumSounpackInstallState ( ret . optJSONObject ( 0 ) ) ; }
Get the current soundpack installation status .
67
8
5,174
public JSONObject getCarpetModeState ( ) throws CommandExecutionException { JSONArray ret = sendToArray ( "get_carpet_mode" ) ; if ( ret == null ) return null ; return ret . optJSONObject ( 0 ) ; }
Get the current carpet cleaning settings .
56
7
5,175
public boolean setCarpetMode ( boolean enabled , int high , int low , int integral , int stallTime ) throws CommandExecutionException { JSONObject payload = new JSONObject ( ) ; payload . put ( "enable" , enabled ? 1 : 0 ) ; payload . put ( "current_high" , high ) ; payload . put ( "current_low" , low ) ; payload . put...
Change the carped cleaning settings .
144
7
5,176
public String getSerialnumber ( ) throws CommandExecutionException { JSONArray ret = sendToArray ( "get_serial_number" ) ; if ( ret == null ) return null ; return ret . optJSONObject ( 0 ) . optString ( "serial_number" ) ; }
Get the vacuums serial number .
60
8
5,177
public int newLocal ( final Type type ) { Object t ; switch ( type . getSort ( ) ) { case Type . BOOLEAN : case Type . CHAR : case Type . BYTE : case Type . SHORT : case Type . INT : t = Opcodes . INTEGER ; break ; case Type . FLOAT : t = Opcodes . FLOAT ; break ; case Type . LONG : t = Opcodes . LONG ; break ; case Ty...
Creates a new local variable of the given type .
192
11
5,178
private List < Fight > getFights ( Elements trs , Fighter fighter ) throws ArrayIndexOutOfBoundsException { List < Fight > fights = new ArrayList <> ( ) ; logger . info ( "{} TRs to parse through" , trs . size ( ) ) ; SherdogBaseObject sFighter = new SherdogBaseObject ( ) ; sFighter . setName ( fighter . getName ( ) ) ...
Get a fighter fights
373
4
5,179
private SherdogBaseObject getOpponent ( Element td ) { SherdogBaseObject opponent = new SherdogBaseObject ( ) ; Element opponentLink = td . select ( "a" ) . get ( 0 ) ; opponent . setName ( opponentLink . html ( ) ) ; opponent . setSherdogUrl ( opponentLink . attr ( "abs:href" ) ) ; return opponent ; }
Get the fight result
83
4
5,180
private SherdogBaseObject getEvent ( Element td ) { Element link = td . select ( "a" ) . get ( 0 ) ; SherdogBaseObject event = new SherdogBaseObject ( ) ; event . setName ( link . html ( ) . replaceAll ( "<span itemprop=\"award\">|</span>" , "" ) ) ; event . setSherdogUrl ( link . attr ( "abs:href" ) ) ; return event ;...
Get the fight event
98
4
5,181
private ZonedDateTime getDate ( Element td ) { //date Element date = td . select ( "span.sub_line" ) . first ( ) ; return ParserUtils . getDateFromStringToZoneId ( date . html ( ) , ZONE_ID , DateTimeFormatter . ofPattern ( "MMM / dd / yyyy" , Locale . US ) ) ; }
Get the date of the fight
86
6
5,182
private static int parseType ( final String signature , int pos , final SignatureVisitor v ) { char c ; int start , end ; boolean visited , inner ; String name ; switch ( c = signature . charAt ( pos ++ ) ) { case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : v . visitBas...
Parses a field type signature and makes the given visitor visit it .
448
15
5,183
protected int getSortFieldIndex ( ) { SortParam sp = getSort ( ) ; Integer index = fieldNameToIndex . get ( sp . getProperty ( ) ) ; if ( index == null ) { index = 1 ; } return index ; }
Returns an index of the currently selected sort field .
52
10
5,184
@ Override public Map < BeanId , Bean > getBeanToValidate ( Collection < Bean > beans ) throws AbortRuntimeException { Map < BeanId , Bean > beansToValidate = new HashMap <> ( ) ; for ( Bean bean : beans ) { Map < BeanId , Bean > predecessors = new HashMap <> ( ) ; // beans read from xml storage will only have their ba...
The direct but no further successors that references this bean will also be fetched and initialized with their direct but no further predecessors .
402
25
5,185
protected ApplicationContext getApplicationContext ( JobExecutionContext context ) throws SchedulerException { final SchedulerContext schedulerContext = context . getScheduler ( ) . getContext ( ) ; ApplicationContext applicationContext = ( ApplicationContext ) schedulerContext . get ( APPLICATION_CONTEXT_KEY ) ; // sh...
Obtains Spring s application context .
187
7
5,186
private void checkSystemInput ( ) throws IOException { while ( System . in . available ( ) > 0 ) { int input = System . in . read ( ) ; if ( input >= 0 ) { char c = ( char ) input ; if ( c == ' ' ) { synchronized ( lock ) { finished = true ; lock . notifyAll ( ) ; } } } else { synchronized ( lock ) { finished = true ; ...
Checks for the user pressing Enter .
99
8
5,187
protected void executePostMethod ( HttpInvokerClientConfiguration config , HttpClient httpClient , PostMethod postMethod ) throws IOException { httpClient . executeMethod ( postMethod ) ; }
Execute the given PostMethod instance .
40
8
5,188
public static KeyValue getReferenceKeyValue ( byte [ ] rowkey , String propertyName , String schemaName , List < BeanId > refs , UniqueIds uids ) { final byte [ ] pid = uids . getUsid ( ) . getId ( propertyName ) ; final byte [ ] sid = uids . getUsid ( ) . getId ( schemaName ) ; final byte [ ] qual = new byte [ ] { sid...
Get a particular type of references identified by propertyName into key value form .
159
15
5,189
public void setReferencesOn ( Bean bean ) { for ( KeyValue ref : references . values ( ) ) { final byte [ ] sidpid = ref . getQualifier ( ) ; final byte [ ] iids = ref . getValue ( ) ; final byte [ ] sid = new byte [ ] { sidpid [ 0 ] , sidpid [ 1 ] } ; final byte [ ] pid = new byte [ ] { sidpid [ 2 ] , sidpid [ 3 ] } ;...
Set references on a bean using a set of key values containing references .
253
14
5,190
public static boolean isReference ( KeyValue kv ) { if ( Bytes . equals ( kv . getFamily ( ) , REF_COLUMN_FAMILY ) ) { return true ; } return false ; }
If this key value is of reference familiy type .
48
12
5,191
public static byte [ ] getIids ( final List < String > ids , final UniqueIds uids ) { final int size = ids . size ( ) ; final byte [ ] iids = new byte [ IID_WIDTH * size ] ; for ( int i = 0 ; i < size ; i ++ ) { final String instanceId = ids . get ( i ) ; final byte [ ] iid = uids . getUiid ( ) . getId ( instanceId ) ;...
Compress a set of instances ids into a byte array where each id consist of 4 bytes each .
144
21
5,192
private static byte [ ] getIids2 ( final List < BeanId > ids , final UniqueIds uids ) { if ( ids == null ) { return new byte [ 0 ] ; } final AbstractList < String > list = new AbstractList < String > ( ) { @ Override public String get ( int index ) { return ids . get ( index ) . getInstanceId ( ) ; } @ Override public ...
Second version of getIids that takes a set of bean ids instead .
119
16
5,193
public static DateLabel forDateTime ( String id , Date date ) { return DateLabel . forDatePattern ( id , new Model < Date > ( date ) , DATE_TIME_PATTERN ) ; }
Creates a label which displays date and time .
45
10
5,194
protected Entry get ( DirectoryEntry parent , String name ) { parent . getClass ( ) ; Entry [ ] entries = listEntries ( parent ) ; if ( entries != null ) { for ( int i = 0 ; i < entries . length ; i ++ ) { if ( name . equals ( entries [ i ] . getName ( ) ) ) { return entries [ i ] ; } } } return null ; }
Gets the named entry in the specified directory . The default implementation lists all the entries in the directory and looks for the one with the matching name . Caching implementations will likely want to override this behaviour .
86
41
5,195
private File toFile ( Entry entry ) { Stack < String > stack = new Stack < String > ( ) ; Entry entryRoot = entry . getFileSystem ( ) . getRoot ( ) ; while ( entry != null && ! entryRoot . equals ( entry ) ) { String name = entry . getName ( ) ; if ( ".." . equals ( name ) ) { if ( ! stack . isEmpty ( ) ) { stack . pop...
Convert an entry into the corresponding file path .
167
10
5,196
public static void validateSchema ( Bean bean ) { validateId ( bean ) ; validatePropertyNames ( bean ) ; validateReferences ( bean ) ; validateProperties ( bean ) ; validatePropertyList ( bean ) ; validatePropertyReferences ( bean ) ; validatePropertyRefList ( bean ) ; validatePropertyRefMap ( bean ) ; }
Validate that the value of the bean is according to schema .
68
13
5,197
public final void initializeReferences ( Collection < Bean > beans ) { Map < BeanId , Bean > indexed = BeanUtils . uniqueIndex ( beans ) ; for ( Bean bean : beans ) { for ( String name : bean . getReferenceNames ( ) ) { List < BeanId > ids = bean . getReference ( name ) ; if ( ids == null ) { continue ; } for ( BeanId ...
Initialize references that lack a bean instance eagerly .
157
10
5,198
public static Schema create ( SchemaId id , final String classType , final String name , final String description ) { return new Schema ( id , classType , name , description ) ; }
Creates a new schema . Not to be used by users schemas are created when a configurable class are registered in the system .
41
27
5,199
public Class < ? > getClassType ( ) { try { return Class . forName ( getType ( ) , true , ClassLoaderHolder . getClassLoader ( ) ) ; } catch ( ClassNotFoundException e ) { throw new IllegalStateException ( e ) ; } }
This is the fully qualified classname of the configurable class that this schema originates from .
59
19