text:
.class Landroid/support/v7/view/SupportMenuInflater$MenuState;
.super Ljava/lang/Object;
.source "SupportMenuInflater.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Landroid/support/v7/view/SupportMenuInflater;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x2
    name = "MenuState"
.end annotation

# static fields
.field private static final defaultGroupId:I = 0x0

.field private static final defaultItemCategory:I = 0x0

.field private static final defaultItemCheckable:I = 0x0

.field private static final defaultItemChecked:Z = false

.field private static final defaultItemEnabled:Z = true

.field private static final defaultItemId:I = 0x0

.field private static final defaultItemOrder:I = 0x0

.field private static final defaultItemVisible:Z = true

# instance fields
.field private groupCategory:I

.field private groupCheckable:I

.field private groupEnabled:Z

.field private groupId:I

.field private groupOrder:I

.field private groupVisible:Z

.field itemActionProvider:Landroid/support/v4/view/ActionProvider;

.field private itemActionProviderClassName:Ljava/lang/String;

.field private itemActionViewClassName:Ljava/lang/String;

.field private itemActionViewLayout:I

.field private itemAdded:Z

.field private itemAlphabeticShortcut:C

.field private itemCategoryOrder:I

.field private itemCheckable:I

.field private itemChecked:Z

.field private itemContentDescription:Ljava/lang/CharSequence;

.field private itemEnabled:Z

.field private itemIconResId:I

.field private itemId:I

.field private itemListenerMethodName:Ljava/lang/String;

.field private itemNumericShortcut:C

.field private itemShowAsAction:I

.field private itemTitle:Ljava/lang/CharSequence;

.field private itemTitleCondensed:Ljava/lang/CharSequence;

.field private itemTooltipText:Ljava/lang/CharSequence;

.field private itemVisible:Z

.field private menu:Landroid/view/Menu;

.field final synthetic this$0:Landroid/support/v7/view/SupportMenuInflater;

# direct methods
.method public constructor <init>(Landroid/support/v7/view/SupportMenuInflater;Landroid/view/Menu;)V
    .registers 3
    .param p2, "menu"    # Landroid/view/Menu;

    .prologue
    .line 336
    iput-object p1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->this$0:Landroid/support/v7/view/SupportMenuInflater;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 337
    iput-object p2, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->menu:Landroid/view/Menu;

    .line 339
    invoke-virtual {p0}, Landroid/support/v7/view/SupportMenuInflater$MenuState;->resetGroup()V

    .line 340
    return-void
.end method

.method private getShortcut(Ljava/lang/String;)C
    .registers 3
    .param p1, "shortcutString"    # Ljava/lang/String;

    .prologue
    const/4 v0, 0x0

    .line 427
    if-nez p1, :cond_4

    .line 430
    :goto_3
    return v0

    :cond_4
    invoke-virtual {p1, v0}, Ljava/lang/String;->charAt(I)C

    move-result v0

    goto :goto_3
.end method

.method private newInstance(Ljava/lang/String;[Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;
    .registers 10
    .param p1, "className"    # Ljava/lang/String;
    .param p3, "arguments"    # [Ljava/lang/Object;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "<T:",
            "Ljava/lang/Object;",
            ">(",
            "Ljava/lang/String;",
            "[",
            "Ljava/lang/Class",
            "<*>;[",
            "Ljava/lang/Object;",
            ")TT;"
        }
    .end annotation

    .prologue
    .line 510
    .local p2, "constructorSignature":[Ljava/lang/Class;, "[Ljava/lang/Class<*>;"
    :try_start_0
    iget-object v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->this$0:Landroid/support/v7/view/SupportMenuInflater;

    iget-object v3, v3, Landroid/support/v7/view/SupportMenuInflater;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getClassLoader()Ljava/lang/ClassLoader;

    move-result-object v3

    invoke-virtual {v3, p1}, Ljava/lang/ClassLoader;->loadClass(Ljava/lang/String;)Ljava/lang/Class;

    move-result-object v0

    .line 511
    .local v0, "clazz":Ljava/lang/Class;, "Ljava/lang/Class<*>;"
    invoke-virtual {v0, p2}, Ljava/lang/Class;->getConstructor([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;

    move-result-object v1

    .line 512
    .local v1, "constructor":Ljava/lang/reflect/Constructor;, "Ljava/lang/reflect/Constructor<*>;"
    const/4 v3, 0x1

    invoke-virtual {v1, v3}, Ljava/lang/reflect/Constructor;->setAccessible(Z)V

    .line 513
    invoke-virtual {v1, p3}, Ljava/lang/reflect/Constructor;->newInstance([Ljava/lang/Object;)Ljava/lang/Object;
    :try_end_17
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_17} :catch_19

    move-result-object v3

    .line 517
    .end local v0    # "clazz":Ljava/lang/Class;, "Ljava/lang/Class<*>;"
    .end local v1    # "constructor":Ljava/lang/reflect/Constructor;, "Ljava/lang/reflect/Constructor<*>;"
    :goto_18
    return-object v3

    .line 514
    :catch_19
    move-exception v2

    .line 515
    .local v2, "e":Ljava/lang/Exception;
    const-string v3, "SupportMenuInflater"

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    const-string v5, "Cannot instantiate class: "

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-static {v3, v4, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    .line 517
    const/4 v3, 0x0

    goto :goto_18
.end method

.method private setItem(Landroid/view/MenuItem;)V
    .registers 9
    .param p1, "item"    # Landroid/view/MenuItem;

    .prologue
    const/4 v4, 0x1

    .line 435
    iget-boolean v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemChecked:Z

    invoke-interface {p1, v3}, Landroid/view/MenuItem;->setChecked(Z)Landroid/view/MenuItem;

    move-result-object v3

    iget-boolean v5, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemVisible:Z

    .line 436
    invoke-interface {v3, v5}, Landroid/view/MenuItem;->setVisible(Z)Landroid/view/MenuItem;

    move-result-object v3

    iget-boolean v5, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemEnabled:Z

    .line 437
    invoke-interface {v3, v5}, Landroid/view/MenuItem;->setEnabled(Z)Landroid/view/MenuItem;

    move-result-object v5

    iget v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemCheckable:I

    if-lt v3, v4, :cond_52

    move v3, v4

    .line 438
    :goto_18
    invoke-interface {v5, v3}, Landroid/view/MenuItem;->setCheckable(Z)Landroid/view/MenuItem;

    move-result-object v3

    iget-object v5, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemTitleCondensed:Ljava/lang/CharSequence;

    .line 439
    invoke-interface {v3, v5}, Landroid/view/MenuItem;->setTitleCondensed(Ljava/lang/CharSequence;)Landroid/view/MenuItem;

    move-result-object v3

    iget v5, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemIconResId:I

    .line 440
    invoke-interface {v3, v5}, Landroid/view/MenuItem;->setIcon(I)Landroid/view/MenuItem;

    move-result-object v3

    iget-char v5, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemAlphabeticShortcut:C

    .line 441
    invoke-interface {v3, v5}, Landroid/view/MenuItem;->setAlphabeticShortcut(C)Landroid/view/MenuItem;

    move-result-object v3

    iget-char v5, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemNumericShortcut:C

    .line 442
    invoke-interface {v3, v5}, Landroid/view/MenuItem;->setNumericShortcut(C)Landroid/view/MenuItem;

    .line 444
    iget v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemShowAsAction:I

    if-ltz v3, :cond_3c

    .line 445
    iget v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemShowAsAction:I

    invoke-interface {p1, v3}, Landroid/view/MenuItem;->setShowAsAction(I)V

    .line 448
    :cond_3c
    iget-object v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemListenerMethodName:Ljava/lang/String;

    if-eqz v3, :cond_64

    .line 449
    iget-object v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->this$0:Landroid/support/v7/view/SupportMenuInflater;

    iget-object v3, v3, Landroid/support/v7/view/SupportMenuInflater;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->isRestricted()Z

    move-result v3

    if-eqz v3, :cond_54

    .line 450
    new-instance v3, Ljava/lang/IllegalStateException;

    const-string v4, "The android:onClick attribute cannot be used within a restricted context"

    invoke-direct {v3, v4}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v3

    .line 437
    :cond_52
    const/4 v3, 0x0

    goto :goto_18

    .line 453
    :cond_54
    new-instance v3, Landroid/support/v7/view/SupportMenuInflater$InflatedOnMenuItemClickListener;

    iget-object v5, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->this$0:Landroid/support/v7/view/SupportMenuInflater;

    .line 454
    invoke-virtual {v5}, Landroid/support/v7/view/SupportMenuInflater;->getRealOwner()Ljava/lang/Object;

    move-result-object v5

    iget-object v6, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemListenerMethodName:Ljava/lang/String;

    invoke-direct {v3, v5, v6}, Landroid/support/v7/view/SupportMenuInflater$InflatedOnMenuItemClickListener;-><init>(Ljava/lang/Object;Ljava/lang/String;)V

    .line 453
    invoke-interface {p1, v3}, Landroid/view/MenuItem;->setOnMenuItemClickListener(Landroid/view/MenuItem$OnMenuItemClickListener;)Landroid/view/MenuItem;

    .line 457
    :cond_64
    instance-of v3, p1, Landroid/support/v7/view/menu/MenuItemImpl;

    if-eqz v3, :cond_b2

    move-object v3, p1

    check-cast v3, Landroid/support/v7/view/menu/MenuItemImpl;

    move-object v2, v3

    .line 458
    .local v2, "impl":Landroid/support/v7/view/menu/MenuItemImpl;
    :goto_6c
    iget v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemCheckable:I

    const/4 v5, 0x2

    if-lt v3, v5, :cond_7b

    .line 459
    instance-of v3, p1, Landroid/support/v7/view/menu/MenuItemImpl;

    if-eqz v3, :cond_b4

    move-object v3, p1

    .line 460
    check-cast v3, Landroid/support/v7/view/menu/MenuItemImpl;

    invoke-virtual {v3, v4}, Landroid/support/v7/view/menu/MenuItemImpl;->setExclusiveCheckable(Z)V

    .line 466
    :cond_7b
    :goto_7b
    const/4 v1, 0x0

    .line 467
    .local v1, "actionViewSpecified":Z
    iget-object v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionViewClassName:Ljava/lang/String;

    if-eqz v3, :cond_92

    .line 468
    iget-object v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionViewClassName:Ljava/lang/String;

    sget-object v4, Landroid/support/v7/view/SupportMenuInflater;->ACTION_VIEW_CONSTRUCTOR_SIGNATURE:[Ljava/lang/Class;

    iget-object v5, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->this$0:Landroid/support/v7/view/SupportMenuInflater;

    iget-object v5, v5, Landroid/support/v7/view/SupportMenuInflater;->mActionViewConstructorArguments:[Ljava/lang/Object;

    invoke-direct {p0, v3, v4, v5}, Landroid/support/v7/view/SupportMenuInflater$MenuState;->newInstance(Ljava/lang/String;[Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/view/View;

    .line 470
    .local v0, "actionView":Landroid/view/View;
    invoke-interface {p1, v0}, Landroid/view/MenuItem;->setActionView(Landroid/view/View;)Landroid/view/MenuItem;

    .line 471
    const/4 v1, 0x1

    .line 473
    .end local v0    # "actionView":Landroid/view/View;
    :cond_92
    iget v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionViewLayout:I

    if-lez v3, :cond_9e

    .line 474
    if-nez v1, :cond_bf

    .line 475
    iget v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionViewLayout:I

    invoke-interface {p1, v3}, Landroid/view/MenuItem;->setActionView(I)Landroid/view/MenuItem;

    .line 476
    const/4 v1, 0x1

    .line 482
    :cond_9e
    :goto_9e
    iget-object v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionProvider:Landroid/support/v4/view/ActionProvider;

    if-eqz v3, :cond_a7

    .line 483
    iget-object v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionProvider:Landroid/support/v4/view/ActionProvider;

    invoke-static {p1, v3}, Landroid/support/v4/view/MenuItemCompat;->setActionProvider(Landroid/view/MenuItem;Landroid/support/v4/view/ActionProvider;)Landroid/view/MenuItem;

    .line 486
    :cond_a7
    iget-object v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemContentDescription:Ljava/lang/CharSequence;

    invoke-static {p1, v3}, Landroid/support/v4/view/MenuItemCompat;->setContentDescription(Landroid/view/MenuItem;Ljava/lang/CharSequence;)V

    .line 487
    iget-object v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemTooltipText:Ljava/lang/CharSequence;

    invoke-static {p1, v3}, Landroid/support/v4/view/MenuItemCompat;->setTooltipText(Landroid/view/MenuItem;Ljava/lang/CharSequence;)V

    .line 488
    return-void

    .line 457
    .end local v1    # "actionViewSpecified":Z
    .end local v2    # "impl":Landroid/support/v7/view/menu/MenuItemImpl;
    :cond_b2
    const/4 v2, 0x0

    goto :goto_6c

    .line 461
    .restart local v2    # "impl":Landroid/support/v7/view/menu/MenuItemImpl;
    :cond_b4
    instance-of v3, p1, Landroid/support/v7/view/menu/MenuItemWrapperICS;

    if-eqz v3, :cond_7b

    move-object v3, p1

    .line 462
    check-cast v3, Landroid/support/v7/view/menu/MenuItemWrapperICS;

    invoke-virtual {v3, v4}, Landroid/support/v7/view/menu/MenuItemWrapperICS;->setExclusiveCheckable(Z)V

    goto :goto_7b

    .line 478
    .restart local v1    # "actionViewSpecified":Z
    :cond_bf
    const-string v3, "SupportMenuInflater"

    const-string v4, "Ignoring attribute \'itemActionViewLayout\'. Action view already specified."

    invoke-static {v3, v4}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_9e
.end method

# virtual methods
.method public addItem()V
    .registers 6

    .prologue
    .line 491
    const/4 v0, 0x1

    iput-boolean v0, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemAdded:Z

    .line 492
    iget-object v0, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->menu:Landroid/view/Menu;

    iget v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupId:I

    iget v2, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemId:I

    iget v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemCategoryOrder:I

    iget-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemTitle:Ljava/lang/CharSequence;

    invoke-interface {v0, v1, v2, v3, v4}, Landroid/view/Menu;->add(IIILjava/lang/CharSequence;)Landroid/view/MenuItem;

    move-result-object v0

    invoke-direct {p0, v0}, Landroid/support/v7/view/SupportMenuInflater$MenuState;->setItem(Landroid/view/MenuItem;)V

    .line 493
    return-void
.end method

.method public addSubMenuItem()Landroid/view/SubMenu;
    .registers 7

    .prologue
    .line 496
    const/4 v1, 0x1

    iput-boolean v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemAdded:Z

    .line 497
    iget-object v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->menu:Landroid/view/Menu;

    iget v2, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupId:I

    iget v3, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemId:I

    iget v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemCategoryOrder:I

    iget-object v5, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemTitle:Ljava/lang/CharSequence;

    invoke-interface {v1, v2, v3, v4, v5}, Landroid/view/Menu;->addSubMenu(IIILjava/lang/CharSequence;)Landroid/view/SubMenu;

    move-result-object v0

    .line 498
    .local v0, "subMenu":Landroid/view/SubMenu;
    invoke-interface {v0}, Landroid/view/SubMenu;->getItem()Landroid/view/MenuItem;

    move-result-object v1

    invoke-direct {p0, v1}, Landroid/support/v7/view/SupportMenuInflater$MenuState;->setItem(Landroid/view/MenuItem;)V

    .line 499
    return-object v0
.end method

.method public hasAddedItem()Z
    .registers 2

    .prologue
    .line 503
    iget-boolean v0, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemAdded:Z

    return v0
.end method

.method public readGroup(Landroid/util/AttributeSet;)V
    .registers 7
    .param p1, "attrs"    # Landroid/util/AttributeSet;

    .prologue
    const/4 v4, 0x1

    const/4 v3, 0x0

    .line 355
    iget-object v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->this$0:Landroid/support/v7/view/SupportMenuInflater;

    iget-object v1, v1, Landroid/support/v7/view/SupportMenuInflater;->mContext:Landroid/content/Context;

    sget-object v2, Landroid/support/v7/appcompat/R$styleable;->MenuGroup:[I

    invoke-virtual {v1, p1, v2}, Landroid/content/Context;->obtainStyledAttributes(Landroid/util/AttributeSet;[I)Landroid/content/res/TypedArray;

    move-result-object v0

    .line 357
    .local v0, "a":Landroid/content/res/TypedArray;
    sget v1, Landroid/support/v7/appcompat/R$styleable;->MenuGroup_android_id:I

    invoke-virtual {v0, v1, v3}, Landroid/content/res/TypedArray;->getResourceId(II)I

    move-result v1

    iput v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupId:I

    .line 358
    sget v1, Landroid/support/v7/appcompat/R$styleable;->MenuGroup_android_menuCategory:I

    invoke-virtual {v0, v1, v3}, Landroid/content/res/TypedArray;->getInt(II)I

    move-result v1

    iput v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupCategory:I

    .line 360
    sget v1, Landroid/support/v7/appcompat/R$styleable;->MenuGroup_android_orderInCategory:I

    invoke-virtual {v0, v1, v3}, Landroid/content/res/TypedArray;->getInt(II)I

    move-result v1

    iput v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupOrder:I

    .line 361
    sget v1, Landroid/support/v7/appcompat/R$styleable;->MenuGroup_android_checkableBehavior:I

    invoke-virtual {v0, v1, v3}, Landroid/content/res/TypedArray;->getInt(II)I

    move-result v1

    iput v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupCheckable:I

    .line 363
    sget v1, Landroid/support/v7/appcompat/R$styleable;->MenuGroup_android_visible:I

    invoke-virtual {v0, v1, v4}, Landroid/content/res/TypedArray;->getBoolean(IZ)Z

    move-result v1

    iput-boolean v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupVisible:Z

    .line 364
    sget v1, Landroid/support/v7/appcompat/R$styleable;->MenuGroup_android_enabled:I

    invoke-virtual {v0, v1, v4}, Landroid/content/res/TypedArray;->getBoolean(IZ)Z

    move-result v1

    iput-boolean v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupEnabled:Z

    .line 366
    invoke-virtual {v0}, Landroid/content/res/TypedArray;->recycle()V

    .line 367
    return-void
.end method

.method public readItem(Landroid/util/AttributeSet;)V
    .registers 10
    .param p1, "attrs"    # Landroid/util/AttributeSet;

    .prologue
    const/4 v5, 0x1

    const/4 v6, 0x0

    .line 373
    iget-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->this$0:Landroid/support/v7/view/SupportMenuInflater;

    iget-object v4, v4, Landroid/support/v7/view/SupportMenuInflater;->mContext:Landroid/content/Context;

    sget-object v7, Landroid/support/v7/appcompat/R$styleable;->MenuItem:[I

    invoke-virtual {v4, p1, v7}, Landroid/content/Context;->obtainStyledAttributes(Landroid/util/AttributeSet;[I)Landroid/content/res/TypedArray;

    move-result-object v0

    .line 376
    .local v0, "a":Landroid/content/res/TypedArray;
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_id:I

    invoke-virtual {v0, v4, v6}, Landroid/content/res/TypedArray;->getResourceId(II)I

    move-result v4

    iput v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemId:I

    .line 377
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_menuCategory:I

    iget v7, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupCategory:I

    invoke-virtual {v0, v4, v7}, Landroid/content/res/TypedArray;->getInt(II)I

    move-result v1

    .line 378
    .local v1, "category":I
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_orderInCategory:I

    iget v7, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupOrder:I

    invoke-virtual {v0, v4, v7}, Landroid/content/res/TypedArray;->getInt(II)I

    move-result v3

    .line 379
    .local v3, "order":I
    const/high16 v4, -0x10000

    and-int/2addr v4, v1

    const v7, 0xffff

    and-int/2addr v7, v3

    or-int/2addr v4, v7

    iput v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemCategoryOrder:I

    .line 381
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_title:I

    invoke-virtual {v0, v4}, Landroid/content/res/TypedArray;->getText(I)Ljava/lang/CharSequence;

    move-result-object v4

    iput-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemTitle:Ljava/lang/CharSequence;

    .line 382
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_titleCondensed:I

    invoke-virtual {v0, v4}, Landroid/content/res/TypedArray;->getText(I)Ljava/lang/CharSequence;

    move-result-object v4

    iput-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemTitleCondensed:Ljava/lang/CharSequence;

    .line 383
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_icon:I

    invoke-virtual {v0, v4, v6}, Landroid/content/res/TypedArray;->getResourceId(II)I

    move-result v4

    iput v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemIconResId:I

    .line 384
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_alphabeticShortcut:I

    .line 385
    invoke-virtual {v0, v4}, Landroid/content/res/TypedArray;->getString(I)Ljava/lang/String;

    move-result-object v4

    invoke-direct {p0, v4}, Landroid/support/v7/view/SupportMenuInflater$MenuState;->getShortcut(Ljava/lang/String;)C

    move-result v4

    iput-char v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemAlphabeticShortcut:C

    .line 386
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_numericShortcut:I

    .line 387
    invoke-virtual {v0, v4}, Landroid/content/res/TypedArray;->getString(I)Ljava/lang/String;

    move-result-object v4

    invoke-direct {p0, v4}, Landroid/support/v7/view/SupportMenuInflater$MenuState;->getShortcut(Ljava/lang/String;)C

    move-result v4

    iput-char v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemNumericShortcut:C

    .line 388
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_checkable:I

    invoke-virtual {v0, v4}, Landroid/content/res/TypedArray;->hasValue(I)Z

    move-result v4

    if-eqz v4, :cond_ed

    .line 390
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_checkable:I

    invoke-virtual {v0, v4, v6}, Landroid/content/res/TypedArray;->getBoolean(IZ)Z

    move-result v4

    if-eqz v4, :cond_eb

    move v4, v5

    :goto_6f
    iput v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemCheckable:I

    .line 396
    :goto_71
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_checked:I

    invoke-virtual {v0, v4, v6}, Landroid/content/res/TypedArray;->getBoolean(IZ)Z

    move-result v4

    iput-boolean v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemChecked:Z

    .line 397
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_visible:I

    iget-boolean v7, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupVisible:Z

    invoke-virtual {v0, v4, v7}, Landroid/content/res/TypedArray;->getBoolean(IZ)Z

    move-result v4

    iput-boolean v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemVisible:Z

    .line 398
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_enabled:I

    iget-boolean v7, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupEnabled:Z

    invoke-virtual {v0, v4, v7}, Landroid/content/res/TypedArray;->getBoolean(IZ)Z

    move-result v4

    iput-boolean v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemEnabled:Z

    .line 399
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_showAsAction:I

    const/4 v7, -0x1

    invoke-virtual {v0, v4, v7}, Landroid/content/res/TypedArray;->getInt(II)I

    move-result v4

    iput v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemShowAsAction:I

    .line 400
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_android_onClick:I

    invoke-virtual {v0, v4}, Landroid/content/res/TypedArray;->getString(I)Ljava/lang/String;

    move-result-object v4

    iput-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemListenerMethodName:Ljava/lang/String;

    .line 401
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_actionLayout:I

    invoke-virtual {v0, v4, v6}, Landroid/content/res/TypedArray;->getResourceId(II)I

    move-result v4

    iput v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionViewLayout:I

    .line 402
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_actionViewClass:I

    invoke-virtual {v0, v4}, Landroid/content/res/TypedArray;->getString(I)Ljava/lang/String;

    move-result-object v4

    iput-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionViewClassName:Ljava/lang/String;

    .line 403
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_actionProviderClass:I

    invoke-virtual {v0, v4}, Landroid/content/res/TypedArray;->getString(I)Ljava/lang/String;

    move-result-object v4

    iput-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionProviderClassName:Ljava/lang/String;

    .line 405
    iget-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionProviderClassName:Ljava/lang/String;

    if-eqz v4, :cond_f2

    move v2, v5

    .line 406
    .local v2, "hasActionProvider":Z
    :goto_bb
    if-eqz v2, :cond_f4

    iget v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionViewLayout:I

    if-nez v4, :cond_f4

    iget-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionViewClassName:Ljava/lang/String;

    if-nez v4, :cond_f4

    .line 407
    iget-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionProviderClassName:Ljava/lang/String;

    sget-object v5, Landroid/support/v7/view/SupportMenuInflater;->ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE:[Ljava/lang/Class;

    iget-object v7, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->this$0:Landroid/support/v7/view/SupportMenuInflater;

    iget-object v7, v7, Landroid/support/v7/view/SupportMenuInflater;->mActionProviderConstructorArguments:[Ljava/lang/Object;

    invoke-direct {p0, v4, v5, v7}, Landroid/support/v7/view/SupportMenuInflater$MenuState;->newInstance(Ljava/lang/String;[Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Landroid/support/v4/view/ActionProvider;

    iput-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionProvider:Landroid/support/v4/view/ActionProvider;

    .line 418
    :goto_d5
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_contentDescription:I

    invoke-virtual {v0, v4}, Landroid/content/res/TypedArray;->getText(I)Ljava/lang/CharSequence;

    move-result-object v4

    iput-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemContentDescription:Ljava/lang/CharSequence;

    .line 419
    sget v4, Landroid/support/v7/appcompat/R$styleable;->MenuItem_tooltipText:I

    invoke-virtual {v0, v4}, Landroid/content/res/TypedArray;->getText(I)Ljava/lang/CharSequence;

    move-result-object v4

    iput-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemTooltipText:Ljava/lang/CharSequence;

    .line 421
    invoke-virtual {v0}, Landroid/content/res/TypedArray;->recycle()V

    .line 423
    iput-boolean v6, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemAdded:Z

    .line 424
    return-void

    .end local v2    # "hasActionProvider":Z
    :cond_eb
    move v4, v6

    .line 390
    goto :goto_6f

    .line 394
    :cond_ed
    iget v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupCheckable:I

    iput v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemCheckable:I

    goto :goto_71

    :cond_f2
    move v2, v6

    .line 405
    goto :goto_bb

    .line 411
    .restart local v2    # "hasActionProvider":Z
    :cond_f4
    if-eqz v2, :cond_fd

    .line 412
    const-string v4, "SupportMenuInflater"

    const-string v5, "Ignoring attribute \'actionProviderClass\'. Action view already specified."

    invoke-static {v4, v5}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 415
    :cond_fd
    const/4 v4, 0x0

    iput-object v4, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->itemActionProvider:Landroid/support/v4/view/ActionProvider;

    goto :goto_d5
.end method

.method public resetGroup()V
    .registers 3

    .prologue
    const/4 v1, 0x1

    const/4 v0, 0x0

    .line 343
    iput v0, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupId:I

    .line 344
    iput v0, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupCategory:I

    .line 345
    iput v0, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupOrder:I

    .line 346
    iput v0, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupCheckable:I

    .line 347
    iput-boolean v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupVisible:Z

    .line 348
    iput-boolean v1, p0, Landroid/support/v7/view/SupportMenuInflater$MenuState;->groupEnabled:Z

    .line 349
    return-void
.end method


text:
package ua.kpi.ecampus.model.dao;

import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import ua.kpi.ecampus.model.pojo.Bulletin;
import ua.kpi.ecampus.model.pojo.Item;
import ua.kpi.ecampus.model.pojo.User;

import static ua.kpi.ecampus.util.BulletinPredicates.filterBulletins;
import static ua.kpi.ecampus.util.BulletinPredicates.getIdsCollection;
import static ua.kpi.ecampus.util.BulletinPredicates.isMatchesProfile;
import static ua.kpi.ecampus.util.BulletinPredicates.isMatchesSubdivision;

/**
 * Implementation of IDataAccessObject for the Bulletin data model.
 */
public class BulletinDao implements IDataAccessObject<Bulletin> {
    /**
     * All unique bulletins available for current user
     */
    private Set<Bulletin> mAll = new LinkedHashSet<>();
    /**
     * Bulletins filtered by user profile
     */
    private Set<Bulletin> mByProfile = new LinkedHashSet<>();
    /**
     * Bulletins filtered by user subdivision
     */
    private Set<Bulletin> mBySubdivision = new LinkedHashSet<>();

    @Override
    public Collection<Bulletin> getData() {
        return mAll;
    }

    @Override
    public void setData(Collection<Bulletin> data) {
        if (data.isEmpty()) return;

        for (Bulletin b : data) {
            trimTime(b);
            mAll.add(b);
        }

        List<Item> userProfile = User.getInstance().position;
        List<Item> userSubdivision = User.getInstance().subdivision;

        if (userProfile != null && userSubdivision != null) {
            List<Integer> ids = getIdsCollection(userProfile);
            mByProfile.addAll(filterBulletins(data, isMatchesProfile(ids)));
            ids = getIdsCollection(userSubdivision);
            mBySubdivision.addAll(filterBulletins(data, isMatchesSubdivision(ids)));
        }
    }

    @Override
    public void update(Bulletin object) {
    }

    @Override
    public void delete(Bulletin object) {
    }

    /**
     * Trim time value in datetime strings in object
     * @param bulletin with datetime strings
     */
    private void trimTime(Bulletin bulletin) {
        bulletin.setDateStart(bulletin.getDateStart().split(" ")[0]);
        bulletin.setDateStop(bulletin.getDateStop().split(" ")[0]);
        bulletin.setDateCreate(bulletin.getDateCreate().split(" ")[0]);
    }

    /**
     * Get Bulletins filtered by user's profile.
     *
     * @return list of bulletins.
     */
    public Collection<Bulletin> getFilteredByProfile() {
        return mByProfile;
    }

    /**
     * Get Bulletins filtered by user's subdivision.
     *
     * @return list of bulletins.
     */
    public Collection<Bulletin> getFilteredBySubdiv() {
        return mBySubdivision;
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

declare(strict_types=1);

namespace Sonata\AdminBundle\Twig;

use Twig\Extension\RuntimeExtensionInterface;

final class IconRuntime implements RuntimeExtensionInterface
{
    public function parseIcon(string $icon): string
    {
        if ('' === $icon || 0 === strpos($icon, '<')) {
            return $icon;
        }

        if (
            0 !== strpos($icon, 'fa ')
            && 0 !== strpos($icon, 'fas ')
            && 0 !== strpos($icon, 'far ')
            && 0 !== strpos($icon, 'fab ')
            && 0 !== strpos($icon, 'fal ')
            && 0 !== strpos($icon, 'fad ')
        ) {
            throw new \InvalidArgumentException(sprintf('The icon format "%s" is not supported.', $icon));
        }

        return sprintf('<i class="%s" aria-hidden="true"></i>', $icon);
    }
}


text:
package com.salesforce.storm.spout.dynamic;

import com.salesforce.storm.spout.dynamic.consumer.ConsumerPeerContext;
import com.salesforce.storm.spout.dynamic.consumer.ConsumerState;
import com.salesforce.storm.spout.dynamic.metrics.LogRecorder;
import com.salesforce.storm.spout.dynamic.metrics.MetricsRecorder;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * Test that the factory correctly create {@link VirtualSpout instances}.
 */
public class VirtualSpoutFactoryTest {

    /**
     * Test that the factory correctly create {@link VirtualSpout instances}.
     */
    @Test
    public void testCreate() {
        final Map<String,Object> config = new HashMap<>();
        final FactoryManager factoryManager = new FactoryManager(config);
        final MetricsRecorder metricsRecorder = new LogRecorder();

        final VirtualSpoutFactory virtualSpoutFactory = new VirtualSpoutFactory(
            config,
            new ConsumerPeerContext(0, 1),
            factoryManager,
            metricsRecorder
        );

        final VirtualSpoutIdentifier identifier = new DefaultVirtualSpoutIdentifier("test");

        final ConsumerState startingState = ConsumerState.builder()
            .withPartition(new ConsumerPartition("foo", 0), 42L)
            .build();

        final ConsumerState endingState = ConsumerState.builder()
            .withPartition(new ConsumerPartition("bar", 1), 72L)
            .build();

        final VirtualSpout virtualSpout = (VirtualSpout) virtualSpoutFactory.create(identifier, startingState, endingState);

        assertEquals(
            config,
            virtualSpout.getSpoutConfig(),
            "Config doesn't match"
        );

        assertEquals(
            factoryManager,
            virtualSpout.getFactoryManager(),
            "Factory manager does not match"
        );

        assertEquals(
            metricsRecorder,
            virtualSpout.getMetricsRecorder(),
            "Metrics recorder does not match"
        );

        assertEquals(
            startingState,
            virtualSpout.getStartingState(),
            "Starting state does not match"
        );

        assertEquals(
            endingState,
            virtualSpout.getEndingState(),
            "Ending state does not match"
        );
    }
}


text:
import abc
import os
import re
import shutil
import socket
import StringIO
import sys

import netaddr
from oslo.config import cfg

from quantum.agent.linux import ip_lib
from quantum.agent.linux import utils
from quantum.openstack.common import jsonutils
from quantum.openstack.common import log as logging
from quantum.openstack.common import uuidutils

LOG = logging.getLogger(__name__)

OPTS = [
    cfg.StrOpt('dhcp_confs',
               default='$state_path/dhcp',
               help=_('Location to store DHCP server config files')),
    cfg.IntOpt('dhcp_lease_time',
               default=120,
               help=_('Lifetime of a DHCP lease in seconds')),
    cfg.StrOpt('dhcp_domain',
               default='openstacklocal',
               help=_('Domain to use for building the hostnames')),
    cfg.StrOpt('dnsmasq_config_file',
               default='',
               help=_('Override the default dnsmasq settings with this file')),
    cfg.StrOpt('dnsmasq_dns_server',
               help=_('Use another DNS server before any in '
                      '/etc/resolv.conf.')),
]

IPV4 = 4
IPV6 = 6
UDP = 'udp'
TCP = 'tcp'
DNS_PORT = 53
DHCPV4_PORT = 67
DHCPV6_PORT = 467
METADATA_DEFAULT_IP = '169.254.169.254'

class DhcpBase(object):
    __metaclass__ = abc.ABCMeta

    def __init__(self, conf, network, root_helper='sudo',
                 device_delegate=None, namespace=None):
        self.conf = conf
        self.network = network
        self.root_helper = root_helper
        self.device_delegate = device_delegate
        self.namespace = namespace

    @abc.abstractmethod
    def enable(self):
        """Enables DHCP for this network."""

    @abc.abstractmethod
    def disable(self, retain_port=False):
        """Disable dhcp for this network."""

    def restart(self):
        """Restart the dhcp service for the network."""
        self.disable(retain_port=True)
        self.enable()

    @abc.abstractproperty
    def active(self):
        """Boolean representing the running state of the DHCP server."""

    @abc.abstractmethod
    def reload_allocations(self):
        """Force the DHCP server to reload the assignment database."""

    @classmethod
    def existing_dhcp_networks(cls, conf, root_helper):
        """Return a list of existing networks ids (ones we have configs for)"""

        raise NotImplementedError

class DhcpLocalProcess(DhcpBase):
    PORTS = []

    def _enable_dhcp(self):
        """check if there is a subnet within the network with dhcp enabled."""
        for subnet in self.network.subnets:
            if subnet.enable_dhcp:
                return True
        return False

    def enable(self):
        """Enables DHCP for this network by spawning a local process."""
        interface_name = self.device_delegate.setup(self.network,
                                                    reuse_existing=True)
        if self.active:
            self.restart()
        elif self._enable_dhcp():
            self.interface_name = interface_name
            self.spawn_process()

    def disable(self, retain_port=False):
        """Disable DHCP for this network by killing the local process."""
        pid = self.pid

        if self.active:
            cmd = ['kill', '-9', pid]
            utils.execute(cmd, self.root_helper)
            if not retain_port:
                self.device_delegate.destroy(self.network, self.interface_name)

        elif pid:
            LOG.debug(_('DHCP for %(net_id)s pid %(pid)d is stale, ignoring '
                        'command'), {'net_id': self.network.id, 'pid': pid})
        else:
            LOG.debug(_('No DHCP started for %s'), self.network.id)

        self._remove_config_files()

    def _remove_config_files(self):
        confs_dir = os.path.abspath(os.path.normpath(self.conf.dhcp_confs))
        conf_dir = os.path.join(confs_dir, self.network.id)
        shutil.rmtree(conf_dir, ignore_errors=True)

    def get_conf_file_name(self, kind, ensure_conf_dir=False):
        """Returns the file name for a given kind of config file."""
        confs_dir = os.path.abspath(os.path.normpath(self.conf.dhcp_confs))
        conf_dir = os.path.join(confs_dir, self.network.id)
        if ensure_conf_dir:
            if not os.path.isdir(conf_dir):
                os.makedirs(conf_dir, 0755)

        return os.path.join(conf_dir, kind)

    def _get_value_from_conf_file(self, kind, converter=None):
        """A helper function to read a value from one of the state files."""
        file_name = self.get_conf_file_name(kind)
        msg = _('Error while reading %s')

        try:
            with open(file_name, 'r') as f:
                try:
                    return converter and converter(f.read()) or f.read()
                except ValueError, e:
                    msg = _('Unable to convert value in %s')
        except IOError, e:
            msg = _('Unable to access %s')

        LOG.debug(msg % file_name)
        return None

    @property
    def pid(self):
        """Last known pid for the DHCP process spawned for this network."""
        return self._get_value_from_conf_file('pid', int)

    @property
    def active(self):
        pid = self.pid
        if pid is None:
            return False

        cmd = ['cat', '/proc/%s/cmdline' % pid]
        try:
            return self.network.id in utils.execute(cmd, self.root_helper)
        except RuntimeError, e:
            return False

    @property
    def interface_name(self):
        return self._get_value_from_conf_file('interface')

    @interface_name.setter
    def interface_name(self, value):
        interface_file_path = self.get_conf_file_name('interface',
                                                      ensure_conf_dir=True)
        utils.replace_file(interface_file_path, value)

    @abc.abstractmethod
    def spawn_process(self):
        pass

class Dnsmasq(DhcpLocalProcess):
    # The ports that need to be opened when security policies are active
    # on the Quantum port used for DHCP.  These are provided as a convenience
    # for users of this class.
    PORTS = {IPV4: [(UDP, DNS_PORT), (TCP, DNS_PORT), (UDP, DHCPV4_PORT)],
             IPV6: [(UDP, DNS_PORT), (TCP, DNS_PORT), (UDP, DHCPV6_PORT)],
             }

    _TAG_PREFIX = 'tag%d'

    QUANTUM_NETWORK_ID_KEY = 'QUANTUM_NETWORK_ID'
    QUANTUM_RELAY_SOCKET_PATH_KEY = 'QUANTUM_RELAY_SOCKET_PATH'

    @classmethod
    def existing_dhcp_networks(cls, conf, root_helper):
        """Return a list of existing networks ids (ones we have configs for)"""

        confs_dir = os.path.abspath(os.path.normpath(conf.dhcp_confs))

        class FakeNetwork:
            def __init__(self, net_id):
                self.id = net_id

        return [
            c for c in os.listdir(confs_dir)
            if (uuidutils.is_uuid_like(c) and
                cls(conf, FakeNetwork(c), root_helper).active)
        ]

    def spawn_process(self):
        """Spawns a Dnsmasq process for the network."""
        env = {
            self.QUANTUM_NETWORK_ID_KEY: self.network.id,
            self.QUANTUM_RELAY_SOCKET_PATH_KEY:
            self.conf.dhcp_lease_relay_socket
        }

        cmd = [
            'dnsmasq',
            '--no-hosts',
            '--no-resolv',
            '--strict-order',
            '--bind-interfaces',
            '--interface=%s' % self.interface_name,
            '--except-interface=lo',
            '--pid-file=%s' % self.get_conf_file_name(
                'pid', ensure_conf_dir=True),
            #TODO (mark): calculate value from cidr (defaults to 150)
            #'--dhcp-lease-max=%s' % ?,
            '--dhcp-hostsfile=%s' % self._output_hosts_file(),
            '--dhcp-optsfile=%s' % self._output_opts_file(),
            '--dhcp-script=%s' % self._lease_relay_script_path(),
            '--leasefile-ro',
        ]

        for i, subnet in enumerate(self.network.subnets):
            # if a subnet is specified to have dhcp disabled
            if not subnet.enable_dhcp:
                continue
            if subnet.ip_version == 4:
                mode = 'static'
            else:
                # TODO (mark): how do we indicate other options
                # ra-only, slaac, ra-nameservers, and ra-stateless.
                mode = 'static'
            cmd.append('--dhcp-range=set:%s,%s,%s,%ss' %
                       (self._TAG_PREFIX % i,
                        netaddr.IPNetwork(subnet.cidr).network,
                        mode,
                        self.conf.dhcp_lease_time))

        cmd.append('--conf-file=%s' % self.conf.dnsmasq_config_file)
        if self.conf.dnsmasq_dns_server:
            cmd.append('--server=%s' % self.conf.dnsmasq_dns_server)

        if self.conf.dhcp_domain:
            cmd.append('--domain=%s' % self.conf.dhcp_domain)

        if self.namespace:
            ip_wrapper = ip_lib.IPWrapper(self.root_helper, self.namespace)
            ip_wrapper.netns.execute(cmd, addl_env=env)
        else:
            # For normal sudo prepend the env vars before command
            cmd = ['%s=%s' % pair for pair in env.items()] + cmd
            utils.execute(cmd, self.root_helper)

    def reload_allocations(self):
        """Rebuild the dnsmasq config and signal the dnsmasq to reload."""

        # If all subnets turn off dhcp, kill the process.
        if not self._enable_dhcp():
            self.disable()
            LOG.debug(_('Killing dhcpmasq for network since all subnets have '
                        'turned off DHCP: %s'), self.network.id)
            return

        self._output_hosts_file()
        self._output_opts_file()
        cmd = ['kill', '-HUP', self.pid]
        utils.execute(cmd, self.root_helper)
        LOG.debug(_('Reloading allocations for network: %s'), self.network.id)

    def _output_hosts_file(self):
        """Writes a dnsmasq compatible hosts file."""
        r = re.compile('[:.]')
        buf = StringIO.StringIO()

        for port in self.network.ports:
            for alloc in port.fixed_ips:
                name = '%s.%s' % (r.sub('-', alloc.ip_address),
                                  self.conf.dhcp_domain)
                buf.write('%s,%s,%s\n' %
                          (port.mac_address, name, alloc.ip_address))

        name = self.get_conf_file_name('host')
        utils.replace_file(name, buf.getvalue())
        return name

    def _output_opts_file(self):
        """Write a dnsmasq compatible options file."""

        if self.conf.enable_isolated_metadata:
            subnet_to_interface_ip = self._make_subnet_interface_ip_map()

        options = []
        for i, subnet in enumerate(self.network.subnets):
            if not subnet.enable_dhcp:
                continue
            if subnet.dns_nameservers:
                options.append(
                    self._format_option(i, 'dns-server',
                                        ','.join(subnet.dns_nameservers)))

            host_routes = ["%s,%s" % (hr.destination, hr.nexthop)
                           for hr in subnet.host_routes]

            # Add host routes for isolated network segments
            enable_metadata = (
                self.conf.enable_isolated_metadata
                and not subnet.gateway_ip
                and subnet.ip_version == 4)

            if enable_metadata:
                subnet_dhcp_ip = subnet_to_interface_ip[subnet.id]
                host_routes.append(
                    '%s/32,%s' % (METADATA_DEFAULT_IP, subnet_dhcp_ip)
                )

            if host_routes:
                options.append(
                    self._format_option(i, 'classless-static-route',
                                        ','.join(host_routes)))

            if subnet.ip_version == 4:
                if subnet.gateway_ip:
                    options.append(self._format_option(i, 'router',
                                                       subnet.gateway_ip))
                else:
                    options.append(self._format_option(i, 'router'))

        name = self.get_conf_file_name('opts')
        utils.replace_file(name, '\n'.join(options))
        return name

    def _make_subnet_interface_ip_map(self):
        ip_dev = ip_lib.IPDevice(
            self.interface_name,
            self.root_helper,
            self.namespace
        )

        subnet_lookup = dict(
            (netaddr.IPNetwork(subnet.cidr), subnet.id)
            for subnet in self.network.subnets
        )

        retval = {}

        for addr in ip_dev.addr.list():
            ip_net = netaddr.IPNetwork(addr['cidr'])

            if ip_net in subnet_lookup:
                retval[subnet_lookup[ip_net]] = addr['cidr'].split('/')[0]

        return retval

    def _lease_relay_script_path(self):
        return os.path.join(os.path.dirname(sys.argv[0]),
                            'quantum-dhcp-agent-dnsmasq-lease-update')

    def _format_option(self, index, option_name, *args):
        return ','.join(('tag:' + self._TAG_PREFIX % index,
                         'option:%s' % option_name) + args)

    @classmethod
    def lease_update(cls):
        network_id = os.environ.get(cls.QUANTUM_NETWORK_ID_KEY)
        dhcp_relay_socket = os.environ.get(cls.QUANTUM_RELAY_SOCKET_PATH_KEY)

        action = sys.argv[1]
        if action not in ('add', 'del', 'old'):
            sys.exit()

        mac_address = sys.argv[2]
        ip_address = sys.argv[3]

        if action == 'del':
            lease_remaining = 0
        else:
            lease_remaining = int(os.environ.get('DNSMASQ_TIME_REMAINING', 0))

        data = dict(network_id=network_id, mac_address=mac_address,
                    ip_address=ip_address, lease_remaining=lease_remaining)

        if os.path.exists(dhcp_relay_socket):
            sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
            sock.connect(dhcp_relay_socket)
            sock.send(jsonutils.dumps(data))
            sock.close()


text:
package org.thingsboard.server.dao.service.validator;

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.widget.WidgetsBundle;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.model.ModelConstants;
import org.thingsboard.server.dao.service.DataValidator;
import org.thingsboard.server.dao.tenant.TenantService;
import org.thingsboard.server.dao.widget.WidgetsBundleDao;

@Component
@AllArgsConstructor
public class WidgetsBundleDataValidator extends DataValidator<WidgetsBundle> {

    private final WidgetsBundleDao widgetsBundleDao;
    private final TenantService tenantService;

    @Override
    protected void validateDataImpl(TenantId tenantId, WidgetsBundle widgetsBundle) {
        if (StringUtils.isEmpty(widgetsBundle.getTitle())) {
            throw new DataValidationException("Widgets bundle title should be specified!");
        }
        if (widgetsBundle.getTenantId() == null) {
            widgetsBundle.setTenantId(TenantId.fromUUID(ModelConstants.NULL_UUID));
        }
        if (!widgetsBundle.getTenantId().getId().equals(ModelConstants.NULL_UUID)) {
            if (!tenantService.tenantExists(widgetsBundle.getTenantId())) {
                throw new DataValidationException("Widgets bundle is referencing to non-existent tenant!");
            }
        }
    }

    @Override
    protected void validateCreate(TenantId tenantId, WidgetsBundle widgetsBundle) {
        String alias = widgetsBundle.getAlias();
        if (alias == null || alias.trim().isEmpty()) {
            alias = widgetsBundle.getTitle().toLowerCase().replaceAll("\\W+", "_");
        }
        String originalAlias = alias;
        int c = 1;
        WidgetsBundle withSameAlias;
        do {
            withSameAlias = widgetsBundleDao.findWidgetsBundleByTenantIdAndAlias(widgetsBundle.getTenantId().getId(), alias);
            if (withSameAlias != null) {
                alias = originalAlias + (++c);
            }
        } while (withSameAlias != null);
        widgetsBundle.setAlias(alias);
    }

    @Override
    protected WidgetsBundle validateUpdate(TenantId tenantId, WidgetsBundle widgetsBundle) {
        WidgetsBundle storedWidgetsBundle = widgetsBundleDao.findById(tenantId, widgetsBundle.getId().getId());
        if (!storedWidgetsBundle.getTenantId().getId().equals(widgetsBundle.getTenantId().getId())) {
            throw new DataValidationException("Can't move existing widgets bundle to different tenant!");
        }
        if (!storedWidgetsBundle.getAlias().equals(widgetsBundle.getAlias())) {
            throw new DataValidationException("Update of widgets bundle alias is prohibited!");
        }
        return storedWidgetsBundle;
    }
}


text:
using System.Collections.Generic;

namespace Contacts.Data.DTO
{

    public class TownDTO
    {
        private readonly IList<AddressDTO> addresses = new List<AddressDTO>();

        public virtual long Id { get; set; }
        public virtual CountryDTO Country { get; set; }
        public virtual string Name { get; set; }
        public virtual IList<AddressDTO> Addresses { get { return addresses; } }
    }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Botryosphaeria abrupta Berk. & M.A. Curtis

### Remarks
null


text:
    MENU

Products

About Us

Contact

Testimonials

More

Submenu Item

Another Item

Item with submenu

Sub-submenu Item

Another Item

Another submenu

Sub-submenu

An Item

Sign up


text:
"""Remove duplicated object files

Usage: python rdof.py source target

Remove all object files contains in target from source and create a new source static library file in current directory.

Arguments:
    source  static library file to deal with
    target  static library file which contains object files to be removed

Example:
    rdof.py libcocos2d-x.a libssl.a     remove ssl from cocos2d-x
"""

import sys
import tempfile
import shutil
import subprocess

FAT_MAGIC = b'\xca\xfe\xba\xbe'

def usage():
    print __doc__

def is_fat(lib):
    with open(lib, 'rb') as f:
        header = f.read(4)
    return header == FAT_MAGIC

def get_obj_files(lib):
    def get_obj_files_from_thin_file(thin):
        results = {}
        output = subprocess.check_output(['ar', '-t', thin])
        for o in [f.strip() for f in output.split('\n') if f.endswith('.o')]:
            results[o] = True
        return results

    if is_fat(lib):
        obj_files = {}
        try:
            temp = tempfile.mkdtemp(dir='.')
            for arch in get_arches(lib):
                thin_file = "%s/%s.%s" % (temp, arch, lib)
                subprocess.check_call(['lipo', lib, '-thin', arch, '-o', thin_file])
                obj_files.update(get_obj_files_from_thin_file(thin_file))
        finally:
            shutil.rmtree(temp)

        print 'Get obj files from', lib, ':', obj_files.keys()
        return obj_files
    else:
        files = get_obj_files_from_thin_file(lib)
        print 'Get obj files from', lib, ':', files.keys()
        return files

def get_arches(static_lib):
    info = subprocess.check_output(['lipo', '-info', static_lib])
    arches = info.split(':')[-1].split()
    print 'Arches of', static_lib, ':', arches
    return arches

def delete_obj_files(source, obj_files):
    files = get_obj_files(source).keys()
    files_to_delete = []
    for f in files:
        if f not in obj_files:
            continue
        files_to_delete.append(f)

    print 'Delete', files_to_delete, 'from', source
    subprocess.check_call(['ar', '-d', source] + files_to_delete)

def remove_target_from_source(source, target):
    removes = get_obj_files(target)

    if not is_fat(source):
        delete_obj_files(source, removes)
        return

    temp = tempfile.mkdtemp(dir='.')
    thin_files = []

    try:
        for arch in get_arches(source):
            thin_file = "%s/%s.%s" % (temp, arch, source)
            thin_files.append(thin_file)

            subprocess.check_call(['lipo', source, '-thin', arch, '-o', thin_file])

            delete_obj_files(thin_file, removes)

        print 'Done, create %s' % ('new.' + source)
        command = ['lipo', '-create'] + thin_files + ['-o', 'new.' + source]
        subprocess.check_call(command)
    finally:
        shutil.rmtree(temp)

if __name__ == '__main__':
    if len(sys.argv) < 3:
        usage()
        sys.exit(2)

    remove_target_from_source(sys.argv[1], sys.argv[2])


text:
package org.fusesource.scalate
package camel

import java.io.File
import java.util.Map

import org.apache.camel.Endpoint
import org.apache.camel.impl.DefaultComponent
import org.springframework.core.io.DefaultResourceLoader
import org.fusesource.scalate.util.FileResourceLoader

/**
 * @version $Revision : 1.1 $
 */

class ScalateComponent() extends DefaultComponent {

  var defaultTemplateExtension: String = "ssp"
  var templateEngine: TemplateEngine = new TemplateEngine()

  var resourceLoader = new DefaultResourceLoader();

  templateEngine.resourceLoader = new FileResourceLoader() {

    override protected def toFile(uri:String):File = {
      return resourceLoader.getResource(uri).getFile
    }
  }
  def createEndpoint(uri: String, remaining: String, parameters: Map[String, Object]): Endpoint = {
    new ScalateEndpoint(this, uri, remaining, defaultTemplateExtension)
  }
}


text:
const _ = require('underscore');

const BaseStep = require('../basestep.js');

class FulfillMilitaryClaim extends BaseStep {
    constructor(game, player, claim) {
        super(game);
        this.player = player;
        this.claim = claim;
        this.forcedClaim = [];
    }

    continue() {
        this.forcedClaim = _.filter(this.player.mustChooseAsClaim, card => card.controller === this.player && card.location === 'play area');

        let claimToSelect = this.claim;

        if(this.forcedClaim.length >= 1 && this.forcedClaim.length < this.claim) {
            claimToSelect = this.claim - this.forcedClaim.length;
            this.game.addMessage('{0} {1} automatically chosen for claim',
                this.forcedClaim, this.forcedClaim.length > 1 ? 'are' : 'is');
        }

        let promptMessage = 'Select ' + claimToSelect + ' ' + (claimToSelect > 1 ? 'characters' : 'character') + ' to fulfill military claim';
        this.game.promptForSelect(this.player, {
            numCards: claimToSelect,
            activePromptTitle: promptMessage,
            waitingPromptTitle: 'Waiting for opponent to fulfill military claim',
            cardCondition: card =>
                card.location === 'play area'
                && card.controller === this.player
                && card.getType() === 'character'
                && this.mustChooseAsClaim(card),
            gameAction: 'kill',
            onSelect: (p, cards) => this.fulfillClaim(p, cards),
            onCancel: () => this.cancelClaim()
        });

        return true;
    }

    mustChooseAsClaim(card) {
        if(_.isEmpty(this.forcedClaim)) {
            return true;
        }

        if(this.forcedClaim.length < this.claim) {
            return !this.forcedClaim.includes(card);
        }

        return this.forcedClaim.includes(card);
    }

    fulfillClaim(p, cards) {
        if(!_.isArray(cards)) {
            cards = [cards];
        }

        if(this.forcedClaim.length < this.claim) {
            cards = cards.concat(this.forcedClaim);
        }

        var charactersAvailable = this.player.getNumberOfCardsInPlay(c => c.getType() === 'character');
        var maxAppliedClaim = Math.min(this.claim, charactersAvailable);

        if(cards.length < maxAppliedClaim) {
            return false;
        }

        this.game.addMessage('{0} chooses {1} for claim', this.player, cards);

        this.game.killCharacters(cards);

        return true;
    }

    cancelClaim() {
        this.game.addMessage('{0} has cancelled claim effects', this.player);
    }
}

module.exports = FulfillMilitaryClaim;


text:
package nxt;

import java.io.UnsupportedEncodingException;
import nxt.crypto.Crypto;
import nxt.util.Convert;

public final class Token
{
  private final byte[] publicKey;
  private final int timestamp;
  private final boolean isValid;

  public static String generateToken(String paramString1, String paramString2)
  {
    try
    {
      byte[] arrayOfByte1 = paramString2.getBytes("UTF-8");
      byte[] arrayOfByte2 = new byte[arrayOfByte1.length + 32 + 4];
      System.arraycopy(arrayOfByte1, 0, arrayOfByte2, 0, arrayOfByte1.length);
      System.arraycopy(Crypto.getPublicKey(paramString1), 0, arrayOfByte2, arrayOfByte1.length, 32);
      int i = Convert.getEpochTime();
      arrayOfByte2[(arrayOfByte1.length + 32)] = ((byte)i);
      arrayOfByte2[(arrayOfByte1.length + 32 + 1)] = ((byte)(i >> 8));
      arrayOfByte2[(arrayOfByte1.length + 32 + 2)] = ((byte)(i >> 16));
      arrayOfByte2[(arrayOfByte1.length + 32 + 3)] = ((byte)(i >> 24));

      byte[] arrayOfByte3 = new byte[100];
      System.arraycopy(arrayOfByte2, arrayOfByte1.length, arrayOfByte3, 0, 36);
      System.arraycopy(Crypto.sign(arrayOfByte2, paramString1), 0, arrayOfByte3, 36, 64);

      StringBuilder localStringBuilder = new StringBuilder();
      for (int j = 0; j < 100; j += 5)
      {
        long l = arrayOfByte3[j] & 0xFF | (arrayOfByte3[(j + 1)] & 0xFF) << 8 | (arrayOfByte3[(j + 2)] & 0xFF) << 16 | (arrayOfByte3[(j + 3)] & 0xFF) << 24 | (arrayOfByte3[(j + 4)] & 0xFF) << 32;
        if (l < 32L) {
          localStringBuilder.append("0000000");
        } else if (l < 1024L) {
          localStringBuilder.append("000000");
        } else if (l < 32768L) {
          localStringBuilder.append("00000");
        } else if (l < 1048576L) {
          localStringBuilder.append("0000");
        } else if (l < 33554432L) {
          localStringBuilder.append("000");
        } else if (l < 1073741824L) {
          localStringBuilder.append("00");
        } else if (l < 34359738368L) {
          localStringBuilder.append("0");
        }
        localStringBuilder.append(Long.toString(l, 32));
      }
      return localStringBuilder.toString();
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      throw new RuntimeException(localUnsupportedEncodingException.toString(), localUnsupportedEncodingException);
    }
  }

  public static Token parseToken(String paramString1, String paramString2)
  {
    try
    {
      byte[] arrayOfByte1 = paramString2.getBytes("UTF-8");
      byte[] arrayOfByte2 = new byte[100];
      int i = 0;
      for (int j = 0; i < paramString1.length(); j += 5)
      {
        long l = Long.parseLong(paramString1.substring(i, i + 8), 32);
        arrayOfByte2[j] = ((byte)(int)l);
        arrayOfByte2[(j + 1)] = ((byte)(int)(l >> 8));
        arrayOfByte2[(j + 2)] = ((byte)(int)(l >> 16));
        arrayOfByte2[(j + 3)] = ((byte)(int)(l >> 24));
        arrayOfByte2[(j + 4)] = ((byte)(int)(l >> 32));i += 8;
      }
      if (i != 160) {
        throw new IllegalArgumentException("Invalid token string: " + paramString1);
      }
      byte[] arrayOfByte3 = new byte[32];
      System.arraycopy(arrayOfByte2, 0, arrayOfByte3, 0, 32);
      int k = arrayOfByte2[32] & 0xFF | (arrayOfByte2[33] & 0xFF) << 8 | (arrayOfByte2[34] & 0xFF) << 16 | (arrayOfByte2[35] & 0xFF) << 24;
      byte[] arrayOfByte4 = new byte[64];
      System.arraycopy(arrayOfByte2, 36, arrayOfByte4, 0, 64);

      byte[] arrayOfByte5 = new byte[arrayOfByte1.length + 36];
      System.arraycopy(arrayOfByte1, 0, arrayOfByte5, 0, arrayOfByte1.length);
      System.arraycopy(arrayOfByte2, 0, arrayOfByte5, arrayOfByte1.length, 36);
      boolean bool = Crypto.verify(arrayOfByte4, arrayOfByte5, arrayOfByte3);

      return new Token(arrayOfByte3, k, bool);
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      throw new RuntimeException(localUnsupportedEncodingException.toString(), localUnsupportedEncodingException);
    }
  }

  private Token(byte[] paramArrayOfByte, int paramInt, boolean paramBoolean)
  {
    this.publicKey = paramArrayOfByte;
    this.timestamp = paramInt;
    this.isValid = paramBoolean;
  }

  public byte[] getPublicKey()
  {
    return this.publicKey;
  }

  public int getTimestamp()
  {
    return this.timestamp;
  }

  public boolean isValid()
  {
    return this.isValid;
  }
}


text:
require.config({
  baseUrl: "scripts",
  paths: {
    "text": "../bower_components/requirejs-text/text",
    "jquery": "../bower_components/jquery/dist/jquery",
    "jquery-ui": "../bower_components/jqueryui/jquery-ui",
    "handlebars.runtime": "../bower_components/handlebars/handlebars.runtime.amd",
    "templates": "../dom/all-templates",
    "paper": "../bower_components/paper/dist/paper-full",
    "underscore": "../bower_components/underscore/underscore",
    "FileSaver": "../bower_components/file-saver.js/FileSaver",
    "jquery-mousewheel": "../bower_components/jquery-mousewheel/jquery.mousewheel",
    "semantic": "../bower_components/semantic-ui/dist/semantic.min",
    "html": "../dom"
  }
});


text:
package status

import (
	"time"

	"k8s.io/kubectl/pkg/cmd/util"
	"sigs.k8s.io/cli-utils/pkg/kstatus/polling"
	"sigs.k8s.io/cli-utils/pkg/kstatus/polling/clusterreader"
	"sigs.k8s.io/cli-utils/pkg/kstatus/polling/engine"
	"sigs.k8s.io/cli-utils/pkg/kstatus/polling/statusreaders"
	"sigs.k8s.io/cli-utils/pkg/kstatus/watcher"
)

func NewStatusPoller(f util.Factory) (*polling.StatusPoller, error) {
	mapper, err := f.ToRESTMapper()
	if err != nil {
		return nil, err
	}

	return polling.NewStatusPollerFromFactory(f, polling.Options{
		CustomStatusReaders: []engine.StatusReader{
			&ConfigConnectorStatusReader{
				Mapper: mapper,
			},
			&RolloutStatusReader{
				Mapper: mapper,
			},
		},
	})
}

func NewStatusWatcher(f util.Factory) (watcher.StatusWatcher, error) {
	mapper, err := f.ToRESTMapper()
	if err != nil {
		return nil, err
	}

	dynamicClient, err := f.DynamicClient()
	if err != nil {
		return nil, err
	}

	return &watcher.DefaultStatusWatcher{
		DynamicClient: dynamicClient,
		Mapper:        mapper,
		ResyncPeriod:  1 * time.Hour,
		StatusReader: statusreaders.NewStatusReader(
			mapper,
			NewConfigConnectorStatusReader(mapper),
			NewRolloutStatusReader(mapper)),
		ClusterReader: &clusterreader.DynamicClusterReader{
			DynamicClient: dynamicClient,
			Mapper:        mapper,
		},
	}, nil
}


text:
local Evaluator = torch.class('Evaluator')

--[[ Create a new Evaluator. ]]
function Evaluator:__init()
end

--[[ Run the evaluator on a dataset.

Parameters:

  * `model` - the model to evaluate.
  * `data` - the `Dataset` to evaluate on.
  * `saveFile` - optional filename to save the translation.

Returns: the evaluation score.

]]
function Evaluator:eval(_, _, _)
  error('Not implemented')
end

--[[ Return true if the evaluator can save the translation result. ]]
function Evaluator:canSaveTranslation()
  return false
end

--[[ Compare two scores as returned by the evaluator.

Also see `Evaluator.lowerIsBetter` and `Evaluator.higherIsBetter`.

Parameters:

  * `a` - the score to compare.
  * `b` - the score to compare against.
  * `delta` - the error margin to tolerate.

Returns: `true` if `a` is not worse than `b`, `false` otherwise.

]]
function Evaluator:compare(_, _, _)
  error('Not implemented')
end

-- Predefine common comparison methods.
function Evaluator.lowerIsBetter(a, b, delta)
  delta = delta or 0
  return a - (b - delta) <= 0
end
function Evaluator.higherIsBetter(a, b, delta)
  delta = delta or 0
  return a - (b + delta) >= 0
end

--[[ Return the name of the evaluation metric. ]]
function Evaluator:__tostring__()
  error('Not implemented')
end

return Evaluator


text:
layout: post
title: How bad do you thirst for success!
modified:
categories: blog
excerpt: How bad do you thirst for success!
tags: [life, success]
author:
image:
  feature:
date: 2013-07-06 02:37
comments: true
share: true
---

How bad do you thirst for success!

There is a young men, you know, who wanted to make a lot of money and so he went to this Guru, right.

And he told Guru, you know, "I wanna be the same level you are".

And the Guru said:"If you wanna be the same level I'm on, I'll meet you tomorrow at the beach."

So the young man get there 4 AM. He already to rock n' roll. Got on the suit should of wore shorts.

The old grab his hands and said:"How bad do you wanna be success?"

He said:"Real bad!"

He said:"Walk on out in the water."

So he walk out into the water. Watch this, when he walk out to the water, he gose waist deep and goes like this guy crazy.

Hey I wanna make money and he got me out here swimming. I didn't ask to be a lifeguard. I wanna make money he get me in.

So he said:"Come on, little further, walk out a littel further."

Then he had it rignt around this area, the shoulder area. so this old man crazy. He making money but he crazy.

So he said:"Come on out a litte further."

It was right at his mouth.

"My man, I'm about to go back in. This guy is out of his mind."

And the old man said:"I thought you said you wanna be successful?"

He said:"I do"

He said:"Then walk a littel further."

He came, dropped his head in, held him down, hold in down, my man (kept scratching) hold him down. He had him held down, just before my man was about to pass out. He raise him up.

He said:"I get a question for you." He told the guy, he said:"When you want to success as bad as you wanna breathe than you will be successful."

I don't know how many of you all got asthma here today? If you ever had a asthma attack before your short of breathe. S.O.B, shortness of breath, you wheezing(breath sound). The only thing you trying to do is get some air. You don't care about basketball game, you don't care about what's on TV, you don't care about nobody calling you, you don't care about a party. The only thing you care about when you try to breathe is to get some fresh air.

That's it!

And when you get to the point, where all you wannna do is be successful as bad as you wanna breathe, then you'll be successful.

And I'm here to you that No.1, most of you say you wanna be successful, but you don't want it bad. You just kind of want it.You don't want it bad than you wanna party. You don't want it as much as you wanna be coll. Most of you don't want success as much as you wanna sleep. Some of you lost sleep more than you lost success. And I'm here to tell you today, If you going to be successful, you gotta be willing to give up sleep. You gotta be willing work with 3 hours of sleep, 2 hours of sleep. If you really wanna be successful, some day you gonna have to stay up 3 days in a row. Because if you go to sleep, you might miss the opportunity to be successful. That's how bad you gotta. You gotta go day without...

Listen to me.

You gotta want to be successful so bad that you forget to eat. Some said that, once she was on the set doing her thing three days had gone by and she forget she didn't eat. Cause she was engaged. I never forget. I went, 50cent was doing his movie. I did a littel research on 50. and 50 said that when he wasn't do the movie he was doing the soundtrack. And they said:"When do you sleep?50". And 50 said:"You said sleep? Sleep is for those people who are broke. I don't sleep, see I get opportunity to make my dream become a raality."

Don't cry to quits. You are already in pain, you already hurt. Get reward from it.

Don't go to sleep until you succeed.

Listen to me. I'm here to tell you today, you can come here and you can jump up, you can do flips and you can be excited when we give away  money. But listen to me, you will never be successful. I don't have to give you a dime if you don't do what you should do.


text:
Serves 2.

## Ingredients

- 4 cups water
- 4 inch by 5 inch piece of kombu, with slits cut
- 3 cups loosely packed bonito flakes
- 6 dry shiitake mushrooms, soaked about 10 minutes in warm water
- Soy sauce and mirin to taste
- Fresh ginger
- 600 grams of fresh udon noodles
- 2-3 bok choys, chopped
- 4 pieces thick-cut bacon, halved
- 4 soft-boiled eggs
- 2 green onions

## Instructions

1. Start by preparing the dashi stock. Put kombu and water in a pot over medium-low heat. Remove kombu just before the water begins to boil.
2. Add bonito flakes and simmer for 30 seconds. Let cool slightly, then strain back into pot through a mesh strainer lined with a paper towel.
3. Turn the heat to medium-high and add shiitake mushrooms, soy sauce, mirin, salt, and ginger.
4. In a separate pot, boil noodles for two minutes. When the broth reaches a simmer, add bok choy bottoms, then tops.
5. Combine noodles and broth in bowls. Top with bacon and eggs.

Garnish with green onion.


text:
package com.interopbridges.scx.jeestats;

import java.util.ArrayList;
import java.util.List;

/**
 *

 * Generic Statistic group class to encapsulate a group of item statistics.
 *

 *
 * @author Geoff Erasmus
 *
 */
public class StatisticGroup {
    /**
     *

     * Internal container to hold Item groups of statistics
     *

     */
     List<StatisticItemGroup> _statsgroup;

     /**
      *

      * The name for the group
      *

      */
      String _Name;

    /**
     *

     * Generic Constructor
     *

     * @param Name
     *            The name for the group of statistic items
     */
    public StatisticGroup(String Name)
    {
        _statsgroup = new ArrayList<StatisticItemGroup>();
        _Name = Name;
    }

    /**
     *

     * Get the name of the group.
     *

     * @return
     *         The name of the group.
     */
    public String getName()
    {
        return _Name;
    }

    /**
     *

     * Add a statistic item group.
     *

     * @param stat
     *       A statistic item group to add to the group
     */
    public void addStatisticItemGroup(StatisticItemGroup stat)
    {
        _statsgroup.add(stat);
    }

    /**
     *

     * Get the statistics item group from this group.
     *

     * @return
     *      The statistics item group of this group
     */
    public List<StatisticItemGroup> getStatisticItemGroup()
    {
        return _statsgroup;
    }
}


text:
package com.corwinjv.mobtotems.interfaces;

import net.minecraft.util.math.BlockPos;

import java.util.List;

/**
 * Created by CorwinJV on 1/21/2017.
 */
public interface IMultiblock<T> {
    String IS_MASTER = "isMaster";
    String SLAVES = "slaves";
    String MASTER_POS = "masterPos";

    boolean getIsMaster();

    void setIsMaster(boolean isMaster);

    void verifyMultiblock();

    void setSlaves(List<BlockPos> slaves);

    void invalidateSlaves();

    List<BlockPos> getSlaves();

    List<T> getSlaveTypes();

    T getType();

    void setType(T type);

    void setMaster(IMultiblock<T> master);

    IMultiblock<T> getMaster();
}


text:
hqDefine('app_manager/js/supported_languages',[
    "jquery",
    "knockout",
    "underscore",
    "hqwebapp/js/initial_page_data",
    "hqwebapp/js/main",
    "hqwebapp/js/knockout_bindings.ko",
], function ($, ko, _, initialPageData, hqMain) {
    function Language(langcode, languages) {
        var self = {};
        self.langcode = ko.observable(langcode);
        self.originalLangcode = ko.observable(langcode);
        self.message_content = ko.observable('');
        self.show_error = ko.observable();
        self.languages = languages;
        self.message = ko.computed(function () {
            if (self.langcode()) {
                var lang = self.langcode().toLowerCase();
                $.getJSON('/langcodes/langs.json', {term: lang}, function (res) {
                    var index = _.map(res, function (r) { return r.code; }).indexOf(lang);
                    if (index === -1) {
                        self.message_content(gettext("Warning: unrecognized language"));
                        self.show_error(true);
                    } else if (!self.show_error()) {
                        self.message_content(res[index].name);
                        self.show_error(false);
                    }
                });
            }

            return self.message_content();
        });
        self.originalLangcodeMessage = ko.computed(function () {
            if (!self.originalLangcode()) {
                return '';
            }

            return "(" + _.template("originally <%- originalLanguage %>")({
                originalLanguage: self.originalLangcode(),
            }) + ")";
        });

        self.isDefaultLang = ko.computed(function () {
            return self.languages()[0] === self;
        });
        return self;
    }
    function SupportedLanguages(options) {
        var langs = options.langs;
        var saveURL = options.saveURL;
        var validate = options.validate;
        var self = {};

        self.addLanguageDisabled = ko.observable(false);
        self._seen = ko.observable(false);
        self.seen = ko.computed({
            read: function () {
                return self._seen();
            },
            write: function () {
                self._seen(true);
            },
        });
        self.saveButton = hqMain.initSaveButton({
            unsavedMessage: gettext("You have unsaved changes in your supported languages"),
            save: function () {
                var message = self.validateGeneral();
                if (message) {
                    alert(message);
                    return;
                }
                for (var i = 0; i < self.languages().length; i++) {
                    if (self.validateLanguage(self.languages()[i])) {
                        alert(gettext("There are errors in your configuration"));
                        return;
                    }
                }
                var langs = [];
                var rename = {};
                ko.utils.arrayForEach(self.languages(), function (language) {
                    langs.push(language.langcode());
                    if (language.originalLangcode()) {
                        rename[language.originalLangcode()] = language.langcode();
                    }
                });
                self.saveButton.ajax({
                    url: saveURL,
                    type: 'post',
                    dataType: 'json',
                    data: ko.toJSON({
                        langs: langs,
                        rename: rename,
                        smart_lang_display: self.smartLangDisplay,
                    }),
                    success: function (data) {
                        var i;
                        for (i = 0; i < langs.length; i++) {
                            if (langs[i] !== data[i]) {
                                throw "There was an error saving.";
                            }
                        }
                        self.removedLanguages.removeAll();
                        self.addLanguageDisabled(false);
                        ko.utils.arrayForEach(self.languages(), function (language) {
                            language.originalLangcode(language.langcode());
                        });
                    },
                });
            },
        });

        var changeSaveButton = function () {
            self.saveButton.fire('change');
        };
        var smartLangDisplayEnabled = initialPageData.get("smart_lang_display_enabled");
        self.smartLangDisplay = ko.observable(smartLangDisplayEnabled);
        self.smartLangDisplay.subscribe(changeSaveButton);

        self.languages = ko.observableArray([]);
        self.removedLanguages = ko.observableArray([]);
        function newLanguage(langcode) {
            var language = Language(langcode, self.languages);
            language.langcode.subscribe(changeSaveButton);
            language.langcode.subscribe(function () { self.validateLanguage(language); });
            return language;
        }
        self.addLanguage = function () {
            self.languages.push(newLanguage());
            self.addLanguageDisabled(true);
            self._seen(true);
        };
        self.removeLanguage = function (language) {
            self.languages(_.without(self.languages(), language));
            self.removedLanguages.push(language);
        };
        self.setAsDefault = function (language) {
            self.languages(_.without(self.languages(), language));
            self.languages.unshift(language);
        };
        self.unremoveLanguage = function (language) {
            self.removedLanguages(_.without(self.removedLanguages(), language));
            self.languages.push(language);
        };
        for (var i = 0; i < langs.length; i += 1) {
            var language = newLanguage(langs[i]);
            self.languages.push(language);
        }
        self.languages.subscribe(changeSaveButton);

        self.canSortLanguages = ko.computed(function () {
            return self.languages().length > 1;
        });

        self.validateGeneral = function () {
            var message = "";
            if (!validate) {
                return "";
            }
            if (!self.languages().length) {
                message = gettext("You must have at least one language");
            }
            return message;
        };

        self.validateLanguage = function (language) {
            if (!validate) {
                language.message_content("");
                return "";
            }
            var message = "";
            if (!language) {
                message = gettext("Please enter language");
            } else if (!/^[a-z]{2,3}(-[a-z]*)?$/.exec(language.langcode())) {
                message = gettext("Invalid language code");
            }
            for (var i = 0; i < self.languages().length; i++) {
                self.languages()[i].langcode();
                self.languages()[i].originalLangcode();
                if (message || language === self.languages()[i]) {
                    continue;
                } else if (language.langcode() === self.languages()[i].langcode()) {
                    message = gettext("Language appears twice");
                } else if (language.originalLangcode() === self.languages()[i].originalLangcode()) {
                    message = gettext("This conflicts with a current language");
                }
            }
            language.message_content(message);
            language.show_error(message);
            return message;
        };
        self.showSmartLangDisplayOption = ko.computed(function () {
            return self.languages().length > 2;
        });
        return self;
    }
    return {SupportedLanguages: SupportedLanguages};
});


text:
import socket
import sys
import errno
import array
import datetime

from WifiDataCheck import WifiData

HOST = ''
PORT = 5050

def getSystemTimeMillis():
    return int((datetime.datetime.utcnow()-datetime.datetime(1970,1,1)).total_seconds() * 1000)

# Create wifi socket
wifi_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print('Socket created')

# Bind socket to local host and port
try:
    wifi_socket.bind((HOST, PORT))
except socket.error as msg:
    print('Bind failed. Error code: ' + str(msg[0]) + ' - Message: ' + msg[1])
    sys.exit()

print('Socket bind complete')

# Start listening on socket
wifi_socket.listen(1)
print('Socket now listening')

# Keep talking with the client
while True:

    # Wait to accept a connection
    conn, addr = wifi_socket.accept()
    print('Connected with ' + addr[0] + ':' + str(addr[1]))
    oldmillis = 0
    length = 2
    data_list = []
    # Infinite loop so that function does not terminate
    while True:
        try:
            # Receive data from client
            data = array.array('B', conn.recv(length))
            # Check if connection is alive
            if not data:
                print('Connection closed')
                break
            if data[0] == 10:
                #print(data)
                currentmillis = getSystemTimeMillis()
                difmillis = currentmillis - oldmillis
                oldmillis = currentmillis
                calcchecksum = data[1]
                count = 2
                while(count < length - 4):
                    calcchecksum ^= data[count]
                    count = count + 1
                incchecksum = (data[length-4] << 24 | data[length-3] << 16 | data[length-2] << 8 | data[length-1])
                isRight = calcchecksum == incchecksum
                #print(str(calcchecksum) + " " + str(incchecksum))
                bandwidth = round(length / (difmillis / 1000.5), 2)
                data_list.append(WifiData(isRight, difmillis, bandwidth))
            elif data[0] == 11:
                i = len(data_list) - 1
                while(i > -1):
                    send_str = data_list[i].getAll()
                    if i == 0:
                        send_str = send_str + "#"
                    conn.send(send_str)
                    data_list.pop()
                    i = i - 1
            elif data[0] == 1:
                length = data[1]
                oldmillis = getSystemTimeMillis()

        except socket.error as msg:
            if msg.errno != errno.ECONNRESET:
                raise
            print('Connection reset by peer')
            pass
wifi_socket.close()


text:
angular.module('mnAdminServers').controller('mnAdminServersListController',
  function ($scope, $stateParams, mnAdminService, mnAdminServersService) {
    $scope.$watch(function () {
      var nodes = mnAdminService.model.nodes;
      return nodes && nodes[$stateParams.list];
    }, function (nodes) {
      $scope.nodesList = nodes;
    });
  });


text:
package gudusoft.gsqlparser.sql2xml.model;

public class role_revoked
{

}


text:
#ifndef __DFG_INCLUDE_H__
#define __DFG_INCLUDE_H__

/*!	\file dfg_include.h
 *	\brief Includes all necessary headers for dfg-gameplay project.
 */

#include "pch.h"

#include "main/archive.h"
#include "main/asset.h"
#include "main/cache.h"
#include "main/dictionary.h"
#include "main/gameplay_assets.h"
#include "main/idb_stream.h"
#include "main/memory_stream.h"
#include "main/settings.h"
#include "main/socket_stream.h"
#include "main/variant.h"
#include "main/zip_packages.h"
#include "main/zip_stream.h"
#include "render/particle_system.h"
#include "services/debug_service.h"
#include "services/httprequest_service.h"
#include "services/input_service.h"
#include "services/render_service.h"
#include "services/service.h"
#include "services/service_manager.h"
#include "services/signals.h"
#include "services/social_service.h"
#include "services/storefront_service.h"
#include "services/taskqueue_service.h"
#include "services/taskscheduler_service.h"
#include "services/tracker_service.h"
#include "ui/carousel.h"
#include "ui/clip_label.h"
#include "ui/control_event_handler.h"
#include "ui/dial_button.h"
#include "ui/expanded_tab.h"
#include "ui/http_image_control.h"
#include "ui/slide_menu.h"
#include "utils/curve.h"
#include "utils/intrusive_list.h"
#include "utils/noncopyable.h"
#include "utils/priority_signal.h"
#include "utils/profiler.h"
#include "utils/ref_ptr.h"
#include "utils/singleton.h"
#include "utils/utils.h"
#include "main.h"
#include "game_advanced.h"

#endif // __DFG_INCLUDE_H__