text:
.class Lcn/com/smartdevices/bracelet/lua/m;
.super Landroid/support/v4/widget/ViewDragHelper$Callback;

# instance fields
.field final synthetic a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

# direct methods
.method private constructor <init>(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)V
    .locals 0

    iput-object p1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-direct {p0}, Landroid/support/v4/widget/ViewDragHelper$Callback;-><init>()V

    return-void
.end method

.method synthetic constructor <init>(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;Lcn/com/smartdevices/bracelet/lua/l;)V
    .locals 0

    invoke-direct {p0, p1}, Lcn/com/smartdevices/bracelet/lua/m;-><init>(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)V

    return-void
.end method

# virtual methods
.method public clampViewPositionVertical(Landroid/view/View;II)I
    .locals 3

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mIsSlidingUp:Z
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$1000(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Z

    move-result v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #calls: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->getSlidingTop()I
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$1100(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v1

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v0

    add-int/2addr v0, v1

    :goto_0
    invoke-static {p2, v1}, Ljava/lang/Math;->max(II)I

    move-result v1

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->getPullDownDistance()I

    move-result v2

    add-int/2addr v0, v2

    invoke-static {v1, v0}, Ljava/lang/Math;->min(II)I

    move-result v0

    return v0

    :cond_0
    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->getPaddingTop()I

    move-result v0

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v1

    sub-int v1, v0, v1

    goto :goto_0
.end method

.method public getViewVerticalDragRange(Landroid/view/View;)I
    .locals 1

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v0

    return v0
.end method

.method public onViewCaptured(Landroid/view/View;I)V
    .locals 2

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->setAllChildrenVisible()V

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    const/4 v1, 0x1

    invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v1

    #setter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->isPressed:Ljava/lang/Boolean;
    invoke-static {v0, v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$802(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;Ljava/lang/Boolean;)Ljava/lang/Boolean;

    return-void
.end method

.method public onViewDragStateChanged(I)V
    .locals 3

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mAnchorPoint:F
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$200(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v0

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v1

    int-to-float v1, v1

    mul-float/2addr v0, v1

    float-to-int v0, v0

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mDragHelper:Landroid/support/v4/widget/ViewDragHelper;
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$400(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Landroid/support/v4/widget/ViewDragHelper;

    move-result-object v1

    invoke-virtual {v1}, Landroid/support/v4/widget/ViewDragHelper;->getViewDragState()I

    move-result v1

    if-nez v1, :cond_0

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideOffset:F
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$500(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v1

    const/4 v2, 0x0

    cmpl-float v1, v1, v2

    if-nez v1, :cond_1

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideState:Lcn/com/smartdevices/bracelet/lua/o;
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$600(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Lcn/com/smartdevices/bracelet/lua/o;

    move-result-object v0

    sget-object v1, Lcn/com/smartdevices/bracelet/lua/o;->a:Lcn/com/smartdevices/bracelet/lua/o;

    if-eq v0, v1, :cond_0

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->updateObscuredViewVisibility()V

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideableView:Landroid/view/View;
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$700(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Landroid/view/View;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->dispatchOnPanelExpanded(Landroid/view/View;)V

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    sget-object v1, Lcn/com/smartdevices/bracelet/lua/o;->a:Lcn/com/smartdevices/bracelet/lua/o;

    #setter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideState:Lcn/com/smartdevices/bracelet/lua/o;
    invoke-static {v0, v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$602(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;Lcn/com/smartdevices/bracelet/lua/o;)Lcn/com/smartdevices/bracelet/lua/o;

    :cond_0
    :goto_0
    return-void

    :cond_1
    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideOffset:F
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$500(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v1

    int-to-float v0, v0

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v2

    int-to-float v2, v2

    div-float/2addr v0, v2

    cmpl-float v0, v1, v0

    if-nez v0, :cond_2

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideState:Lcn/com/smartdevices/bracelet/lua/o;
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$600(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Lcn/com/smartdevices/bracelet/lua/o;

    move-result-object v0

    sget-object v1, Lcn/com/smartdevices/bracelet/lua/o;->c:Lcn/com/smartdevices/bracelet/lua/o;

    if-eq v0, v1, :cond_0

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->updateObscuredViewVisibility()V

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideableView:Landroid/view/View;
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$700(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Landroid/view/View;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->dispatchOnPanelAnchored(Landroid/view/View;)V

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    sget-object v1, Lcn/com/smartdevices/bracelet/lua/o;->c:Lcn/com/smartdevices/bracelet/lua/o;

    #setter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideState:Lcn/com/smartdevices/bracelet/lua/o;
    invoke-static {v0, v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$602(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;Lcn/com/smartdevices/bracelet/lua/o;)Lcn/com/smartdevices/bracelet/lua/o;

    goto :goto_0

    :cond_2
    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideState:Lcn/com/smartdevices/bracelet/lua/o;
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$600(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Lcn/com/smartdevices/bracelet/lua/o;

    move-result-object v0

    sget-object v1, Lcn/com/smartdevices/bracelet/lua/o;->b:Lcn/com/smartdevices/bracelet/lua/o;

    if-eq v0, v1, :cond_0

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideableView:Landroid/view/View;
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$700(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Landroid/view/View;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->dispatchOnPanelCollapsed(Landroid/view/View;)V

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    sget-object v1, Lcn/com/smartdevices/bracelet/lua/o;->b:Lcn/com/smartdevices/bracelet/lua/o;

    #setter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideState:Lcn/com/smartdevices/bracelet/lua/o;
    invoke-static {v0, v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$602(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;Lcn/com/smartdevices/bracelet/lua/o;)Lcn/com/smartdevices/bracelet/lua/o;

    goto :goto_0
.end method

.method public onViewPositionChanged(Landroid/view/View;IIII)V
    .locals 1

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #calls: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->onPanelDragged(I)V
    invoke-static {v0, p3}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$900(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;I)V

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->invalidate()V

    return-void
.end method

.method public onViewReleased(Landroid/view/View;FF)V
    .locals 7

    const/high16 v6, 0x3f80

    const/high16 v5, 0x4000

    const/4 v4, 0x0

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    const/4 v1, 0x0

    invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v1

    #setter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->isPressed:Ljava/lang/Boolean;
    invoke-static {v0, v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$802(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;Ljava/lang/Boolean;)Ljava/lang/Boolean;

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mIsSlidingUp:Z
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$1000(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Z

    move-result v0

    if-eqz v0, :cond_2

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #calls: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->getSlidingTop()I
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$1100(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v0

    :goto_0
    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mAnchorPoint:F
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$200(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v1

    cmpl-float v1, v1, v4

    if-eqz v1, :cond_5

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mIsSlidingUp:Z
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$1000(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Z

    move-result v1

    if-eqz v1, :cond_3

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mAnchorPoint:F
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$200(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v1

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v2

    int-to-float v2, v2

    mul-float/2addr v1, v2

    float-to-int v1, v1

    int-to-float v1, v1

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v2

    int-to-float v2, v2

    div-float/2addr v1, v2

    :goto_1
    cmpl-float v2, p3, v4

    if-gtz v2, :cond_0

    cmpl-float v2, p3, v4

    if-nez v2, :cond_4

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideOffset:F
    invoke-static {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$500(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v2

    add-float v3, v6, v1

    div-float/2addr v3, v5

    cmpl-float v2, v2, v3

    if-ltz v2, :cond_4

    :cond_0
    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v1

    add-int/2addr v0, v1

    :cond_1
    :goto_2
    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->getPullDownDockEnable()Ljava/lang/Boolean;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v1

    if-nez v1, :cond_7

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mDragHelper:Landroid/support/v4/widget/ViewDragHelper;
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$400(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Landroid/support/v4/widget/ViewDragHelper;

    move-result-object v1

    invoke-virtual {p1}, Landroid/view/View;->getLeft()I

    move-result v2

    invoke-virtual {v1, v2, v0}, Landroid/support/v4/widget/ViewDragHelper;->settleCapturedViewAt(II)Z

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->invalidate()V

    :goto_3
    return-void

    :cond_2
    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #calls: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->getSlidingTop()I
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$1100(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v0

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v1

    sub-int/2addr v0, v1

    goto :goto_0

    :cond_3
    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mPanelHeight:I
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$1200(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v1

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mAnchorPoint:F
    invoke-static {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$200(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v2

    iget-object v3, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v3}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v3

    int-to-float v3, v3

    mul-float/2addr v2, v3

    float-to-int v2, v2

    sub-int/2addr v1, v2

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mPanelHeight:I
    invoke-static {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$1200(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v2

    sub-int v1, v2, v1

    int-to-float v1, v1

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v2

    int-to-float v2, v2

    div-float/2addr v1, v2

    goto :goto_1

    :cond_4
    cmpl-float v2, p3, v4

    if-nez v2, :cond_1

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideOffset:F
    invoke-static {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$500(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v2

    add-float v3, v6, v1

    div-float/2addr v3, v5

    cmpg-float v2, v2, v3

    if-gez v2, :cond_1

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideOffset:F
    invoke-static {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$500(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v2

    div-float/2addr v1, v5

    cmpl-float v1, v2, v1

    if-ltz v1, :cond_1

    int-to-float v0, v0

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v1

    int-to-float v1, v1

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mAnchorPoint:F
    invoke-static {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$200(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v2

    mul-float/2addr v1, v2

    add-float/2addr v0, v1

    float-to-int v0, v0

    goto/16 :goto_2

    :cond_5
    cmpl-float v1, p3, v4

    if-gtz v1, :cond_6

    cmpl-float v1, p3, v4

    if-nez v1, :cond_1

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideOffset:F
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$500(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v1

    const/high16 v2, 0x3f00

    cmpl-float v1, v1, v2

    if-lez v1, :cond_1

    :cond_6
    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v1

    add-int/2addr v0, v1

    goto/16 :goto_2

    :cond_7
    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->getSlideThreshhold()F

    move-result v1

    iget-object v2, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v2}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->getSlideThreshhold2()F

    move-result v2

    cmpl-float v3, v4, v1

    if-eqz v3, :cond_8

    iget-object v3, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideOffset:F
    invoke-static {v3}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$500(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)F

    move-result v3

    cmpl-float v1, v3, v1

    if-lez v1, :cond_8

    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mDragHelper:Landroid/support/v4/widget/ViewDragHelper;
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$400(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Landroid/support/v4/widget/ViewDragHelper;

    move-result-object v1

    invoke-virtual {p1}, Landroid/view/View;->getLeft()I

    move-result v3

    iget-object v4, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v4}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v4

    sub-int/2addr v0, v4

    int-to-float v0, v0

    iget-object v4, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mSlideRange:I
    invoke-static {v4}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$300(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)I

    move-result v4

    int-to-float v4, v4

    mul-float/2addr v2, v4

    add-float/2addr v0, v2

    float-to-int v0, v0

    invoke-virtual {v1, v3, v0}, Landroid/support/v4/widget/ViewDragHelper;->settleCapturedViewAt(II)Z

    :goto_4
    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    invoke-virtual {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->invalidate()V

    goto/16 :goto_3

    :cond_8
    iget-object v1, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mDragHelper:Landroid/support/v4/widget/ViewDragHelper;
    invoke-static {v1}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$400(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Landroid/support/v4/widget/ViewDragHelper;

    move-result-object v1

    invoke-virtual {p1}, Landroid/view/View;->getLeft()I

    move-result v2

    invoke-virtual {v1, v2, v0}, Landroid/support/v4/widget/ViewDragHelper;->settleCapturedViewAt(II)Z

    goto :goto_4
.end method

.method public tryCaptureView(Landroid/view/View;I)Z
    .locals 1

    iget-object v0, p0, Lcn/com/smartdevices/bracelet/lua/m;->a:Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;

    #getter for: Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->mIsUnableToDrag:Z
    invoke-static {v0}, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;->access$100(Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout;)Z

    move-result v0

    if-eqz v0, :cond_0

    const/4 v0, 0x0

    :goto_0
    return v0

    :cond_0
    invoke-virtual {p1}, Landroid/view/View;->getLayoutParams()Landroid/view/ViewGroup$LayoutParams;

    move-result-object v0

    check-cast v0, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout$LayoutParams;

    iget-boolean v0, v0, Lcn/com/smartdevices/bracelet/lua/SlidingUpPanelLayout$LayoutParams;->slideable:Z

    goto :goto_0
.end method

redpajama_set_name: RedPajamaGithub


text:
version: 0.17
category: "Installation Guide"
title: "Install Sensu"
next:
  url: "install-sensu-client"
  text: "Install Sensu Client"
success: "NOTE: this is part 4 of 6 steps in the Sensu
  Installation Guide. For the best results, please make sure to follow the
  instructions carefully and complete all of the steps in each section before
  moving on."
---

# Overview

Having successfully completed installation of Sensu's dependencies ([RabbitMQ](install-rabbitmq), and [Redis](install-redis)) and the [Sensu Repositories](install-repositories), we are now ready to install Sensu!

This guide will help you to:

- Install Sensu Core
- Install Sensu Enterprise

_NOTE: Sensu Core and Sensu Enterprise may be installed alongside one another, however only one flavor of Sensu should be run at any given time (see [below](#running-sensu) for more info)._

# Install Sensu

## Sensu Core {#install-sensu-core}

Install Sensu Core from the Sensu repository:

### Ubuntu/Debian

~~~ shell
sudo apt-get update
sudo apt-get install sensu
~~~

### CentOS/RHEL

~~~ shell
sudo yum install sensu
~~~

## Sensu Enterprise {#install-sensu-enterprise}

Install Sensu Enterprise from the Sensu Enterprise repository:

_NOTE: access to the Sensu Enterprise repositories requires an active [Sensu Enterprise](http://sensuapp.org/enterprise#pricing) subscription, and valid access credentials._

### Ubuntu/Debian

~~~ shell
sudo apt-get update
sudo apt-get install sensu-enterprise
~~~

### CentOS/RHEL

~~~ shell
sudo yum install sensu-enterprise
~~~

# Configure Sensu

## Configure Connections

The primary configuration for Sensu is stored in JSON format at `/etc/sensu/config.json`. To configure the Sensu services, copy the following example configuration to `/etc/sensu/config.json` manually, or via:

~~~ shell
sudo wget -O /etc/sensu/config.json http://sensuapp.org/docs/0.17/files/config.json
~~~

_NOTE: this example file configures the RabbitMQ and Redis connection options and the Sensu API port._

~~~ json
{
  "rabbitmq": {
    "host": "localhost",
    "vhost": "/sensu",
    "user": "sensu",
    "password": "secret"
  },
  "redis": {
    "host": "localhost"
  },
  "api": {
    "port": 4567
  }
}
~~~

## Configure a Check

Sensu Checks & Event Handlers will be covered in detail later in this guide, however it will be helpful to have at least one check and handler configured as part of the installation process. If you don't fully understand these concepts - don't worry - we'll explain later.

Create a check definition by copying the following example configuration to `/etc/sensu/conf.d/check_memory.json` manually, or via:

~~~ shell
sudo wget -O /etc/sensu/conf.d/check_memory.json http://sensuapp.org/docs/0.17/files/check_memory.json
~~~

_NOTE: this example config creates a [Sensu Check](checks) that will alert based on memory thresholds (it will raise a warning if less than 128 MB of memory is available, and raise a critical alert if less than 64 MB of memory is available). The check script itself (the plugin) will be installed later in this guide._

~~~ json
{
  "checks": {
    "memory": {
      "command": "/etc/sensu/plugins/check-mem.sh -w 128 -c 64",
      "interval": 10,
      "subscribers": [
        "test"
      ]
    }
  }
}
~~~

Create a default handler definition by copying the following example configuration to `/etc/sensu/conf.d/default_handler.json` manually, or via:

~~~ shell
sudo wget -O /etc/sensu/conf.d/default_handler.json http://sensuapp.org/docs/0.17/files/default_handler.json
~~~

_NOTE: this example config creates a [Sensu Event Handler](handlers) that will be used by default for Sensu events that do not specify a handler._

~~~ json
{
  "handlers": {
    "default": {
      "type": "pipe",
      "command": "cat"
    }
  }
}
~~~

Ensure the Sensu configuration files are owned by the Sensu user and group `sensu`:

~~~ shell
sudo chown -R sensu:sensu /etc/sensu
~~~

# Running Sensu

_NOTE: Only **one** flavor of Sensu should be used at any given time: Sensu Core (sensu-server + sensu-api), or Sensu Enterprise. If you have previously run Sensu Core or Sensu Enterprise and are switching flavors, simply stop one and start the other._

## Sensu Core

~~~ shell
sudo /etc/init.d/sensu-server start
sudo /etc/init.d/sensu-api start
~~~

## Sensu Enterprise

~~~ shell
sudo /etc/init.d/sensu-enterprise start
~~~

# Observe Sensu

Congratulations! By now you should have successfully installed and configured Sensu! Now let's observe it in operation.

_NOTE: the check requests for "memory" are being published every 10 seconds, so it should be possible to observe log activity (i.e. the check requests) at least once every 10 seconds._

## Sensu Core

Tail the Sensu Core server and API log files to observe their operation:

Sensu Core server logs:

~~~ shell
sudo tail -f /var/log/sensu/sensu-server.log
~~~

Sensu Core API logs:

~~~ shell
sudo tail -f /var/log/sensu/sensu-api.log
~~~

## Sensu Enterprise

By default, Sensu Enterprise only logs at "WARN" log level. To temporarily view more log activity, we'll need to toggle the debug log level for Sensu Enterprise:

~~~ shell
sudo kill -TRAP `cat /var/run/sensu-enterprise.pid`
~~~

Tail the Sensu Enterprise log file to observe its operation:

~~~ shell
sudo tail -f /var/log/sensu-enterprise.log
~~~


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<TITLE>
LittleEndianOutputStream (POI API Documentation)
</TITLE>

<META NAME="date" CONTENT="2012-03-17">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

      Overview
      Package
    Class
      Use
      Tree
      Deprecated
      Index
      Help

 PREV CLASS
 NEXT CLASS

  FRAMES
 NO FRAMES

  All Classes

  SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

org.apache.poi.util

Class LittleEndianOutputStream

java.lang.Object
  java.io.OutputStream
      java.io.FilterOutputStream
          org.apache.poi.util.LittleEndianOutputStream

All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, LittleEndianOutput

public final class LittleEndianOutputStream
extends java.io.FilterOutputStream
implements LittleEndianOutput

Author:

Josh Micich

Field Summary

Fields inherited from class java.io.FilterOutputStream

out

Constructor Summary

LittleEndianOutputStream(java.io.OutputStream out)

Method Summary

 void
write(byte[] b)

 void
write(byte[] b,
      int off,
      int len)

 void
writeByte(int v)

 void
writeDouble(double v)

 void
writeInt(int v)

 void
writeLong(long v)

 void
writeShort(int v)

Methods inherited from class java.io.FilterOutputStream

close, flush, write

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

LittleEndianOutputStream

public LittleEndianOutputStream(java.io.OutputStream out)

Method Detail

writeByte

public void writeByte(int v)

Specified by:
writeByte in interface LittleEndianOutput

writeDouble

public void writeDouble(double v)

Specified by:
writeDouble in interface LittleEndianOutput

writeInt

public void writeInt(int v)

Specified by:
writeInt in interface LittleEndianOutput

writeLong

public void writeLong(long v)

Specified by:
writeLong in interface LittleEndianOutput

writeShort

public void writeShort(int v)

Specified by:
writeShort in interface LittleEndianOutput

write

public void write(byte[] b)

Specified by:
write in interface LittleEndianOutput
Overrides:
write in class java.io.FilterOutputStream

write

public void write(byte[] b,
                  int off,
                  int len)

Specified by:
write in interface LittleEndianOutput
Overrides:
write in class java.io.FilterOutputStream

      Overview
      Package
    Class
      Use
      Tree
      Deprecated
      Index
      Help

 PREV CLASS
 NEXT CLASS

  FRAMES
 NO FRAMES

  All Classes

  SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

                Copyright 2012 The Apache Software Foundation or
        its licensors, as applicable.


text:
//
//  main.m
//  Evothings
//
//  Created by Mikael Kindborg.
//  Copyright Evothings AB 2014. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface URLProtocolCordovaJs : NSURLProtocol
@end

static NSString* pathCordovaJs = @"/cordova.js";
static NSString* pathCordovaPluginJs = @"/cordova_plugins.js";
static NSString* pathPlugins = @"/plugins";

int main(int argc, char* argv[])
{
	@autoreleasepool {
		[NSURLProtocol registerClass:[URLProtocolCordovaJs class]];
		int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
		return retVal;
	}
}

static NSError* createError()
{
	NSError* error =
		[NSError
		errorWithDomain: @"/"
		code: -1
		userInfo: nil];
	return error;
}

static NSString* createMimeType(NSString* pathExtension)
{
	NSString* mimeType;
	if ([pathExtension isEqualToString: @"js"])
	{
		mimeType = @"application/javascript";
	}
	else
	{
		mimeType = @"text/html";
	}
	return mimeType;
}

// Check if string contains substring.
static BOOL stringContains(NSString* string, NSString* substring)
{
	if (!string) { return NO; }
	if (!substring) { return NO; }
	NSRange range = [string rangeOfString: substring];
	BOOL found = (range.location != NSNotFound);
	return found;
}

// Get the string starting with substring.
static NSString* stringSubstring(NSString* string, NSString* substring)
{
	if (!string) { return nil; }
	if (!substring) { return nil; }
	NSRange range = [string rangeOfString: substring];
	BOOL found = (range.location != NSNotFound);
	if (found)
	{
		return [string substringFromIndex: range.location];
	}
	else
	{
		return nil;
	}
}

// Get the Cordova part of the path.
static NSString* cordovaSubPath(NSString* path)
{
	NSString* subpath;

	if (!path) { return nil; }

	subpath = stringSubstring(path, pathCordovaJs);
	if (subpath) { return subpath; }

	subpath = stringSubstring(path, pathCordovaPluginJs);
	if (subpath) { return subpath; }

	subpath = stringSubstring(path, pathPlugins);
	if (subpath) { return subpath; }

	return nil;
}

// Get the full Cordova file path in the app bundle.
static NSString* cordovaFilePath(NSString* path)
{
	NSString* filePath = [NSString
		stringWithFormat: @"%@/www%@",
		[[NSBundle mainBundle] bundlePath],
		cordovaSubPath(path)];
	return filePath;
}

static BOOL pathIsCordovaJsFile(NSString* path)
{
	// First test if the path could be a local Cordova JS file.
	BOOL isCordovaPath = stringContains(path, pathCordovaJs)
		|| stringContains(path, pathCordovaPluginJs)
		|| stringContains(path, pathPlugins);
	if (!isCordovaPath) { return NO; }

	// Now see if the file exists.
	NSString* filePath = cordovaFilePath(path);
	BOOL fileExists = [[NSFileManager defaultManager]
		fileExistsAtPath: filePath];
	return fileExists;
}

@implementation URLProtocolCordovaJs

+ (BOOL)canInitWithRequest:(NSURLRequest*)theRequest
{
	// If the URL is a file: URL we do not need to handle it.
	if ([theRequest.URL isFileURL]) { return NO; }

	NSString* path = theRequest.URL.path;
	if (!path) { return NO; }

	return pathIsCordovaJsFile(path);
}

+ (NSURLRequest*)canonicalRequestForRequest:(NSURLRequest*)theRequest
{
	return theRequest;
}

- (void)startLoading
{
	NSString* path = self.request.URL.path;
	NSString* filePath = cordovaFilePath(path);

	BOOL success = FALSE;

	if (nil != filePath)
	{
		NSData* data = [NSData dataWithContentsOfFile: filePath];
		if (nil != data)
		{
			NSString* pathExtension = self.request.URL.pathExtension;
			NSString* mimeType = createMimeType(pathExtension);
			NSURLResponse* response = [[NSURLResponse alloc]
			   initWithURL: self.request.URL
			   MIMEType: mimeType
			   expectedContentLength: -1
			   textEncodingName: nil];
			[[self client]
				URLProtocol: self
				didReceiveResponse: response
				cacheStoragePolicy: NSURLCacheStorageNotAllowed];
			[[self client] URLProtocol: self didLoadData: data];
			[[self client] URLProtocolDidFinishLoading: self];
			success = TRUE;
		}
	}

	if (!success)
	{
		[[self client]
			URLProtocol: self
			didFailWithError: createError()];
	}
}

- (void)stopLoading
{
	// NSLog(@"request cancelled. stop loading the response, if possible");
}

@end


text:
module VagrantPlugins
  module Centos7Fix
    VERSION = "0.0.1"
  end
end


text:
* Updated the documentation of this package to clarify that is is discontinued.

# 0.4.0+1

* Removed the dependency on quiver.

# 0.4.0

* Replaced uses of deprecated `asExternalTypedData` with `asTypedList`.
* Updated to use Dart 2.6 and latest dart:ffi APIs

# 0.3.0

* Update to new tflite C API

# 0.3.0

* Update to new tflite C API

# 0.2.3

* Specify `>=2.5.0` in `pubspec.yaml`

# 0.2.2

* Use `Pointer.asExternalTypedData` for reading output tensor

# 0.2.1

* Rebuild tflite shared libraries to include
  [tensorflow/tensorflow@4735b9b#diff-4e94df4d2961961ba5f69bbd666e0552](https://github.com/tensorflow/tensorflow/commit/4735b9bc02d35864eaba6ab48d73b73b333390e2#diff-4e94df4d2961961ba5f69bbd666e0552)

# 0.2.0

* Load shared object as sibling when running from snapshot

# 0.1.0

* Apply fixes from `dartfmt`
* Update package description

# 0.0.3

* Bundle binaries for 64-bit linux, mac, and windows systems
* Bindings for 24 / 29 functions exposed by libtensorflow_c.so


text:
"""Add push notifications table

Revision ID: f66a92f1895f
Revises: ee38ddab5497
Create Date: 2017-08-22 12:51:40.938162

"""

# revision identifiers, used by Alembic.
revision = 'f66a92f1895f'
down_revision = 'ee38ddab5497'

from alembic import op
import sqlalchemy as sa
import cineapp.migration_types

def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('push_notifications',
    sa.Column('subscription_id', sa.String(length=255), nullable=False),
    sa.Column('session_id', sa.String(length=64), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('subscription_id'),
    mysql_charset='utf8',
    mysql_collate='utf8_general_ci'
    )
    # ### end Alembic commands ###

def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('push_notifications')
    # ### end Alembic commands ###


text:
[Voltar Início](../README.md)

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">

# Virtualenv

** O que vamos aprender? **

- [x] [Contextualização](#contexto)
- [x] [O que é um Ambiente Virtual Python?](#oquee)
- [x] [O que é o Virtualwrapper?](#obj_virtualwrapper)
- [x] [Instalando o Virtualenv e Virtualwrapper no Linux](#instalando)
- [x] [Criando um Ambiente chamado Flask](#criando)
- [x] [Ativando e Desativando os Ambientes Virtuais](#ativando)

#### Referências

**Documentation Virtualenv**

## Contextualização

Quando você escolheu aprender a programar em Python você teve que optar
entre o Python 2.x ou Python 3.x (recomendada) e além disso você escolheu
como instalar o python na sua máquina:

- [-] Minimalista - apenas o interpretador - sem os pacotes (aprox. 27.9Mb) **Download Python**
- [-] ou uma versão que já contivesse vários pacotes juntos:

  * Distribuição Científica Anaconda
  * Distribuição Científica WinPython

Portanto, ficou na sua mente que você tem UM computador com UMA versão de Python
instalada e dentro vários pacotes instalados.

### Pergunta:
**Será que é possível ter em UM computador com VÁRIAS versões de Python
onde CADA Python tenha o seu conjunto de pacotes específicos?**

**R:** Sim. Através do pacote **virtualenv**.

### Problema comum:
Uma vez que você tenha aprendido a desenvolver projetos em Python fica claro
que para cada projeto temos os **pacotes** necessários para aquele projeto.
E que cada pacote tem sua versão dependendo da versão do python
que foi desenvolvido (ex: python 2.7, python 3.4, ...).

**Problema**: você deseja passar seu projeto para outra pessoa, ou para outro computador.
Qual é a melhor maneira de se fazer isso sem **estragar** as configurações do python
daquele computador, daquela pessoa?

Em geral, a pessoa fica com receio de que você coloque o seu projeto na máquina
dela, uma vez que ela tem o Python 2.7 instalado, e o seu projeto exige o
Python 3.x (mais novo).

Como convencer a outra pessoa a instalar o seu projeto na máquina dela? Simples
explique que você **ISOLARÁ** o python 3.x com o **virtualenv** e todos
os pacotes do seu projeto ficarão encapsulados dentro do ambiente virtual
que você criará.

### Então, como faço isso?
Primeiro entenda o que é um ambiente virtual python (virtualenv) e logo
em seguida explico como criar seu ambiente virtual, e você poderá repetir
a ação criando quantos ambientes virtuais achar necessário.

## O que é um Ambiente Virtual Python?

**Virtualenv** é uma ferramenta para criar ambientes **isolados** de **Python**, ou seja,
você poderá ter na mesma máquina quantos pythons quiser, cada um de uma determinada versão (python 2.7
python 3.4, python 3.5, ...) e em cada ambiente você terá seus pacotes específicos.

Isso permitirá que você teste várias combinações de versões, e isole aquela que melhor
atente o seu projeto.

O que isto significa?
**R:** isto significa que você poderá ter diversas versões de python instaladas
no seu sistema operacional sem que um ambiente interfira no outro.  Imagine que
você esteja desenvolvendo um Projeto Web em Python e precise apenas dos pacotes
relacionados a Web (Django, Flask...), e em outro projeto você esteja desenvolvendo
um projeto que exige pacotes de análise científica. Isolando os projetos dentro do
ambiente, você estará isolando as versões de pacotes já testadas para aquele
projeto funcionar. E no momento de instalar em outra máquina você somente
terá que instalar "estes" pacotes.

#### Por quê utilizar o Virtualenv?

Imagine que você **Virtualenv** é um software que permite a criação de ambientes
virtuais com total independência dos outros ambientes criados no Virtualenv.
Isso permite que cada ambiente tenha sua própria autonomia para
instalar seus pacotes de forma que a configuração de
um ambiente não interfira nos demais ambientes de outros projetos.

Porém, criar **virtualenvs** manualmente em Python é uma tarefa que pode ser tediosa. Para facilitar vamos utilizar o **virtualenvwrapper** que facilitam significativamente a gestão de um grande número de ambientes virtuais. Primeiro, precisamos instalar o pacote mencionado no sistema.

* É importante que CADA projeto tenha seu próprio AMBIENTE VIRTUAL, ou seja, sua versão de PYTHON e seus PACOTES necessários para ele.

[Voltar para Índice](#indice)

## O que é o Virtualenvwrapper?

O objetivo dele é fornecer um conjunto de comandos que facilitam trabalhar
com vários ambientes virtuais. O VirtualenvWrapper também centraliza
todos os ambientes virtuais em um único diretório.

Vamos detalhar como instalá-lo no Linux e Windows nas seções abaixo.

[Voltar para Índice](#indice)

### Instalando o Virtualenv e Virtualenvwrapper no Linux

A melhor maneira de configurarmos no Linux é mostrada em 3 passos:

**Passos:**

**1)** Instale através do apt-get os seguintes pacotes:

~~~bash
$sudo aptitude install virtualenv python3-virtualenv virtualenvwrapper python3-pip

ou

$sudo apt-get install virtualenv python3-virtualenv virtualenvwrapper python3-pip

~~~

**2)** Crie o diretório que conterá todos os ambientes virtuais:

~~~bash
/home/user$ mkdir .venvs
~~~

**3)**  Configure o **.bashrc** para o Linux

#### Ubuntu
~~~bash
export WORKON_HOME=$HOME/.venvs
export PROJECT_HOME=$HOME/projs_python
export VIRTUALENVWRAPPER_SCRIPT=/usr/share/virtualenvwrapper/virtualenvwrapper.s
source /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh
export PYTHONPATH="$HOME/amperelib:$HOME:$PYTHONPATH"
~~~

#### Debian
~~~bash
export WORKON_HOME=$HOME/.venvs
export PROJECT_HOME=$HOME/projs_python
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
source /usr/local/bin/virtualenvwrapper_lazy.sh
export PYTHONPATH="$HOME/amperelib:$HOME:$PYTHONPATH"
~~~

#### Windows

Instale o Virutualenv:

~~~bash
c:/> pip install virtualenv
~~~

Depois instale o virtualenvwrapper.

Qual o objetivo de utilizar o virtualenvwrapper?
**R:** Ele force um conjunto de comandos que facilitam trabalhar
com vários ambientes virtuais. O VirtualenvWrapper também centraliza
todos os ambientes virtuais em um único diretório.

Para instalar no Windows faça:

~~~bash
c:\> pip install virtualenvwrapper-win
~~~

#### Comandos Básicos com o virtualenvwrapper instalado

##### 1)Para criar um ambiente virtual:

Sintaxe: **mkvirtualenv** \<nome do ambiente que deseja criar\>

**Exemplo:**
~~~bash
$ mkvirtualenv proj01_py3
~~~

Este comando criará um ambiente virtual chamado **proj01_py3** com a versão
padrão do python instalado dentro do diretório:

* **$HOME/.venvs**  no Linux (conforme configurado acima no .bashrc);
* **C:\Users\<nome do usuario windows>\Envs** no Windows;

~~~bash
$ mkvirtualenv -python=python3 proj01_py3

ou coloque o caminho completo onde está o executável do python:

$ mkvirtualenv -python=/usr/bin/python3 proj01_py3
~~~

##### 2)Para ativar o ambiente virtual:

Para listar todos os ambientes virtuais que existem na máquina execute:
~~~bash
$ workon
~~~

Para ativar o ambientes virtual específico (ex: proj01_py3)
~~~bash
$ workon proj01_py3
~~~

##### 3)Para desativar o ambiente virtual:

Você sabe que o Ambiente Virtual está ativo pois o comando de prompt (ou terminal)
mostra o nome do ambiente antes do cursor. Para desativá-lo faça:
~~~bash
(proj01_py3) c:\> deactivate
~~~

##### 4)Para deletar o ambiente virtual:

Supondo que você já entregou o projeto, e acha que não mais será necessário
aquele ambiente com o Python 3.x e seus pacotes, faça :
~~~bash
c:\> rmvirtualenv proj01_py3
~~~

[Voltar para Índice](#indice)

### Criando um Ambiente chamado Flask

Uma vez com o **virtualenv** e **virtualwrapper** instalados na sua
máquina e o diretório **.venvs** no seu diretório **HOME** vamos
agora **CRIAR** um ambiente virtual que conterá o **python 3.x** e
todos os pacotes necessários para rodarmos o projeto em **Flask**.

**Passos:**

**1)** Provavelmente seu linux já tenha o Python 3.x instalado, porém, o
Python 2.7 ainda é a versão padrão. Verifique com o comando:

~~~bash
mpi@mpi-pc:~$ python --version
Python 2.7.12
~~~

Verifique se seu python 3.x está instalado no diretório **/usr/bin** ou
**/usr/local/bin**:

~~~
mpi@mpi-pc:/usr/bin$ ls python*
python            python2.7-pyrexc  python3.5          python3-config
python2           python2-config    python3.5-config   python3m
python2.7         python2-pbr       python3.5m         python3m-config
python2.7-config  python3           python3.5m-config  python-config
~~~

Neste caso temo o **python 3.5** instalado no diretório **/usr/bin**,
vamos então criar um **Ambiente Virtual** chamado **flask**
que utilizará o **Python 3.5** como padrão.

Sintaxe: mkvirtualenv \<versão do python para o ambiente\> \<**nome** do ambiente\>

No Ubuntu verifiquei que o Python 3 está instalado no diretório **/usr/bin**:

> mpi@mpi-pc:~$ **mkvirtualenv** --python=/usr/bin/python3  *flask*

Se você observar agora no diretório:

~~~
mpi@mpi-pc:~$ cd .venvs/
mpi@mpi-pc:~/.venvs$ ls
flask                initialize      postmkvirtualenv  premkproject
Flask-SocketIO       postactivate    postrmvirtualenv  premkvirtualenv
Flask-SocketIO_py27  postdeactivate  preactivate       prermvirtualenv
get_env_details      postmkproject   predeactivate
~~~

> Vamos aprender a ativar e desativar o ambiente virtual no **terminal**
>e depois vamos aprender a instalar todos os pacotes necessários dentro dele.

[Voltar para Índice](#indice)

### Ativando e Desativando os Ambientes Virtuais

Antes de ativar o ambiente virtual você pode **listar** todos os  ambientes já criados com o comando:

Comando: mpi@mpi-pc:~/projs_python/meu_proj$ **workon**

Listará todos os ambientes criados na minha máquina:

~~~bash
mpi@mpi-pc:~/projs_python/meu_proj$ workon
flask
ambiente_cientifico
ambiente_web
ambiente_django
~~~

A **ativação** do ambiente virtual chamado **flask** será feita através do
seguinte comando:

> mpi@mpi-pc:~/projs_python/meu_proj$ **workon flask**

você perceberá que ele está ativo através do seu **prompt**:

> **(flask)** mpi@mpi-pc:~/projs_python/meu_proj$

**Desativação** do ambiente basta fazer:

> **(flask)** mpi@mpi-pc:~/projs_python/meu_proj$ **deactivate**

e seu prompt voltará ao normal:

> mpi@mpi-pc:~/projs_python/meu_proj$

[Voltar para Índice](#indice)

### Instalando pacotes python no Novo Ambiente

A instalação  dos pacotes python do projeto no novo
**ambiente virtual flask** pode ser executada de duas maneiras:

**Um pacote por vez:**

> Instale através do **pip3** do seu ambiente virtual **flask** que fica localizado
no diretório **/home/mpi/.venvs/bin/** no Linux (conforme configuramos acima):

~~~bash
(flask) mpi@mpi-pc:~/.venvs/flask/bin$ ls
activate                painter.py      python-config
activate.csh            pilconvert.py   rst2html.py
activate.fish           pildriver.py    rst2latex.py
activate_this.py        pilfile.py      rst2man.py
blockdiag               pilfont.py      rst2odt_prepstyles.py
createfontdatachunk.py  pilprint.py     rst2odt.py
dateadd                 pip             rst2pseudoxml.py
datediff                pip3            rst2s5.py
easy_install            pip3.5          rst2xetex.py
easy_install-3.5        player.py       rst2xml.py
enhancer.py             postactivate    rstpep2html.py
explode.py              postdeactivate  sphinx-apidoc
flask                   preactivate     sphinx-autogen
get_env_details         predeactivate   sphinx-build
gifmaker.py             pybabel         sphinx-quickstart
gunicorn                __pycache__     tabulate
gunicorn_django         pygmentize      thresholder.py
gunicorn_paster         python          viewer.py
mod_wsgi-apxs           python3         watchmedo
mod_wsgi-express        python3.5       wheel
~~~

> **(flask)** mpi@mpi-pc:~/projs_python/meu_proj$

~~~bash
sudo pip install -r require_flask.txt
~~~

[Voltar para Índice](#indice)


text:
// Copyright 2012 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.collide.client.ui.dropdown;

import elemental.html.Element;

/**
 * A controller to set the text on an element, optionally supporting a hint.
 */
public class TextContentsController {

  private static final String ATTR_VALUE = "value";

  public enum Setter {
    INNER_TEXT, VALUE
  }

  private final Element element;
  private final Setter setter;
  private boolean hasText;
  private String hint;

  public TextContentsController(Element element, Setter setter) {
    this.element = element;
    this.setter = setter;

  }

  public void setHint(String hint) {
    this.hint = hint;

    if (!hasText) {
      set(hint);
    }
  }

  /**
   * Clears the text of the element and reverts it to the hint specified in
   * #setHint(String)
   */
  public void clearText() {
    set(hint);
  }

  public void setText(String text) {
    hasText = !text.isEmpty();
    if (hasText) {
      set(text);
    } else {
      set(hint);
    }
  }

  public String getText() {
    switch (setter) {
      case INNER_TEXT:
        return element.getInnerText();

      case VALUE:
        return element.getAttribute(ATTR_VALUE);

      default:
        throw new IllegalStateException();
    }
  }

  private void set(String text) {
    switch (setter) {
      case INNER_TEXT:
        element.setInnerText(text);
        break;

      case VALUE:
        element.setAttribute(ATTR_VALUE, text);
        break;
    }
  }
}


text:
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSDictionary (PBMExtensions)

- (nonnull id)nullIfEmpty;

@end

NS_ASSUME_NONNULL_END


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>cn.brent</groupId>
		<artifactId>brent-demo</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<artifactId>brent-demo-autoconfig-web</artifactId>
	<version>1.0.0</version>
	<packaging>war</packaging>

	<build>
		<filters>
			<filter>src/main/resources/env.properties</filter>
		</filters>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>com.alibaba.citrus.tool</groupId>
				<artifactId>autoconfig-maven-plugin</artifactId>
				<version>1.2</version>
				<configuration>
					<userProperties>src/main/resources/env.properties</userProperties>
				</configuration>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>autoconfig</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>


text:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/public/test/content_browser_test_utils.h"

#include <string>
#include <utility>

#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/guid.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "content/browser/browser_main_loop.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/renderer_host/media/media_stream_manager.h"
#include "content/browser/renderer_host/media/video_capture_manager.h"
#include "content/browser/site_instance_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_frame_navigation_observer.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_javascript_dialog_manager.h"
#include "net/base/filename_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h"

#if defined(OS_WIN)
#include "ui/views/test/desktop_window_tree_host_win_test_api.h"  // nogncheck
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
#endif  // defined(OS_WIN)

namespace content {

base::FilePath GetTestFilePath(const char* dir, const char* file) {
  base::FilePath path;
  base::ScopedAllowBlockingForTesting allow_blocking;
  base::PathService::Get(DIR_TEST_DATA, &path);
  if (dir)
    path = path.AppendASCII(dir);
  return path.AppendASCII(file);
}

GURL GetTestUrl(const char* dir, const char* file) {
  return net::FilePathToFileURL(GetTestFilePath(dir, file));
}

void NavigateToURLBlockUntilNavigationsComplete(
    Shell* window,
    const GURL& url,
    int number_of_navigations,
    bool ignore_uncommitted_navigations) {
  NavigateToURLBlockUntilNavigationsComplete(window->web_contents(), url,
                                             number_of_navigations,
                                             ignore_uncommitted_navigations);
}

void ReloadBlockUntilNavigationsComplete(Shell* window,
                                         int number_of_navigations) {
  WaitForLoadStop(window->web_contents());
  TestNavigationObserver same_tab_observer(window->web_contents(),
                                           number_of_navigations);

  window->Reload();
  same_tab_observer.Wait();
}

void ReloadBypassingCacheBlockUntilNavigationsComplete(
    Shell* window,
    int number_of_navigations) {
  WaitForLoadStop(window->web_contents());
  TestNavigationObserver same_tab_observer(window->web_contents(),
                                           number_of_navigations);

  window->ReloadBypassingCache();
  same_tab_observer.Wait();
}

bool NavigateToURL(Shell* window, const GURL& url) {
  return NavigateToURL(window, url, url);
}

bool NavigateToURL(Shell* window,
                   const GURL& url,
                   const GURL& expected_commit_url) {
  return NavigateToURL(window->web_contents(), url, expected_commit_url);
}

bool NavigateToURLAndExpectNoCommit(Shell* window, const GURL& url) {
  NavigationEntry* old_entry =
      window->web_contents()->GetController().GetLastCommittedEntry();
  NavigateToURLBlockUntilNavigationsComplete(
      window->web_contents(), url,
      /*number_of_navigations=*/1,
      /*ignore_uncommitted_navigations=*/false);
  NavigationEntry* new_entry =
      window->web_contents()->GetController().GetLastCommittedEntry();
  return old_entry == new_entry;
}

AppModalDialogWaiter::AppModalDialogWaiter(Shell* shell) : shell_(shell) {
  Restart();
}

void AppModalDialogWaiter::Restart() {
  was_dialog_request_callback_called_ = false;
  ShellJavaScriptDialogManager* dialog_manager =
      static_cast<ShellJavaScriptDialogManager*>(
          shell_->GetJavaScriptDialogManager(shell_->web_contents()));
  dialog_manager->set_dialog_request_callback(base::BindOnce(
      &AppModalDialogWaiter::EarlyCallback, base::Unretained(this)));
}

void AppModalDialogWaiter::Wait() {
  if (!was_dialog_request_callback_called_) {
    ShellJavaScriptDialogManager* dialog_manager =
        static_cast<ShellJavaScriptDialogManager*>(
            shell_->GetJavaScriptDialogManager(shell_->web_contents()));

    base::RunLoop runner;
    dialog_manager->set_dialog_request_callback(runner.QuitClosure());
    runner.Run();
    was_dialog_request_callback_called_ = true;
  }
}

void AppModalDialogWaiter::EarlyCallback() {
  was_dialog_request_callback_called_ = true;
}

RenderFrameHost* ConvertToRenderFrameHost(Shell* shell) {
  return shell->web_contents()->GetMainFrame();
}

void LookupAndLogNameAndIdOfFirstCamera() {
  DCHECK(BrowserMainLoop::GetInstance());
  MediaStreamManager* media_stream_manager =
      BrowserMainLoop::GetInstance()->media_stream_manager();
  base::RunLoop run_loop;
  content::GetIOThreadTaskRunner({})->PostTask(
      FROM_HERE,
      base::BindOnce(
          [](MediaStreamManager* media_stream_manager,
             base::OnceClosure quit_closure) {
            media_stream_manager->video_capture_manager()->EnumerateDevices(
                base::BindOnce(
                    [](base::OnceClosure quit_closure,
                       const media::VideoCaptureDeviceDescriptors&
                           descriptors) {
                      if (descriptors.empty()) {
                        LOG(WARNING) << "No camera found";
                        return;
                      }
                      LOG(INFO) << "Using camera "
                                << descriptors.front().display_name() << " ("
                                << descriptors.front().model_id << ")";
                      std::move(quit_closure).Run();
                    },
                    std::move(quit_closure)));
          },
          media_stream_manager, run_loop.QuitClosure()));
  run_loop.Run();
}

ShellAddedObserver::ShellAddedObserver() {
  Shell::SetShellCreatedCallback(base::BindOnce(
      &ShellAddedObserver::ShellCreated, base::Unretained(this)));
}

ShellAddedObserver::~ShellAddedObserver() = default;

Shell* ShellAddedObserver::GetShell() {
  if (shell_)
    return shell_;

  runner_ = std::make_unique<base::RunLoop>();
  runner_->Run();
  return shell_;
}

void ShellAddedObserver::ShellCreated(Shell* shell) {
  DCHECK(!shell_);
  shell_ = shell;
  if (runner_)
    runner_->Quit();
}

void IsolateOriginsForTesting(
    net::test_server::EmbeddedTestServer* embedded_test_server,
    WebContents* web_contents,
    std::vector<std::string> hostnames_to_isolate) {
  std::vector<url::Origin> origins_to_isolate;
  for (const std::string& hostname : hostnames_to_isolate) {
    origins_to_isolate.push_back(
        url::Origin::Create(GURL(std::string("http://") + hostname + "/")));
  }

  auto* policy = ChildProcessSecurityPolicyImpl::GetInstance();
  policy->AddFutureIsolatedOrigins(
      origins_to_isolate,
      ChildProcessSecurityPolicy::IsolatedOriginSource::TEST);

  // Force a BrowsingInstance swap by navigating cross-site (the newly
  // isolated origin only affects *future* BrowsingInstances).
  scoped_refptr<SiteInstanceImpl> old_site_instance;
  scoped_refptr<SiteInstanceImpl> new_site_instance;
  do {
    old_site_instance = static_cast<SiteInstanceImpl*>(
        web_contents->GetMainFrame()->GetSiteInstance());
    std::string cross_site_hostname = base::GenerateGUID() + ".com";
    EXPECT_TRUE(NavigateToURL(
        web_contents,
        embedded_test_server->GetURL(cross_site_hostname, "/title1.html")));
    new_site_instance = static_cast<SiteInstanceImpl*>(
        web_contents->GetMainFrame()->GetSiteInstance());

    // The navigation might need to be repeated until we actually swap the
    // SiteInstance (no swap might happen when navigating away from the initial,
    // empty frame).
  } while (new_site_instance.get() == old_site_instance.get());
  EXPECT_FALSE(
      new_site_instance->IsRelatedSiteInstance(old_site_instance.get()));
  for (const url::Origin& origin : origins_to_isolate) {
    EXPECT_FALSE(policy->IsIsolatedOrigin(
        old_site_instance->GetIsolationContext(), origin,
        false /* origin_requests_isolation */));
    EXPECT_TRUE(policy->IsIsolatedOrigin(
        new_site_instance->GetIsolationContext(), origin,
        false /* origin_requests_isolation */));
  }
}

#if defined(OS_WIN)

void SetMockCursorPositionForTesting(WebContents* web_contents,
                                     const gfx::Point& position) {
  views::test::DesktopWindowTreeHostWinTestApi host(
      static_cast<views::DesktopWindowTreeHostWin*>(
          web_contents->GetNativeView()->GetHost()));
  host.SetMockCursorPositionForTesting(position);
}

#endif  // defined(OS_WIN)

}  // namespace content


text:
package nlp_automl

//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//
// Code generated by Alibaba Cloud SDK Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

import (
	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
)

// CreateAsyncPredict invokes the nlp_automl.CreateAsyncPredict API synchronously
// api document: https://help.aliyun.com/api/nlp-automl/createasyncpredict.html
func (client *Client) CreateAsyncPredict(request *CreateAsyncPredictRequest) (response *CreateAsyncPredictResponse, err error) {
	response = CreateCreateAsyncPredictResponse()
	err = client.DoAction(request, response)
	return
}

// CreateAsyncPredictWithChan invokes the nlp_automl.CreateAsyncPredict API asynchronously
// api document: https://help.aliyun.com/api/nlp-automl/createasyncpredict.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateAsyncPredictWithChan(request *CreateAsyncPredictRequest) (<-chan *CreateAsyncPredictResponse, <-chan error) {
	responseChan := make(chan *CreateAsyncPredictResponse, 1)
	errChan := make(chan error, 1)
	err := client.AddAsyncTask(func() {
		defer close(responseChan)
		defer close(errChan)
		response, err := client.CreateAsyncPredict(request)
		if err != nil {
			errChan <- err
		} else {
			responseChan <- response
		}
	})
	if err != nil {
		errChan <- err
		close(responseChan)
		close(errChan)
	}
	return responseChan, errChan
}

// CreateAsyncPredictWithCallback invokes the nlp_automl.CreateAsyncPredict API asynchronously
// api document: https://help.aliyun.com/api/nlp-automl/createasyncpredict.html
// asynchronous document: https://help.aliyun.com/document_detail/66220.html
func (client *Client) CreateAsyncPredictWithCallback(request *CreateAsyncPredictRequest, callback func(response *CreateAsyncPredictResponse, err error)) <-chan int {
	result := make(chan int, 1)
	err := client.AddAsyncTask(func() {
		var response *CreateAsyncPredictResponse
		var err error
		defer close(result)
		response, err = client.CreateAsyncPredict(request)
		callback(response, err)
		result <- 1
	})
	if err != nil {
		defer close(result)
		callback(nil, err)
		result <- 0
	}
	return result
}

// CreateAsyncPredictRequest is the request struct for api CreateAsyncPredict
type CreateAsyncPredictRequest struct {
	*requests.RpcRequest
	TopK         requests.Integer `position:"Body" name:"TopK"`
	FileType     string           `position:"Body" name:"FileType"`
	DetailTag    string           `position:"Body" name:"DetailTag"`
	Content      string           `position:"Body" name:"Content"`
	FileContent  string           `position:"Body" name:"FileContent"`
	ModelId      requests.Integer `position:"Body" name:"ModelId"`
	FileUrl      string           `position:"Body" name:"FileUrl"`
	ModelVersion string           `position:"Body" name:"ModelVersion"`
}

// CreateAsyncPredictResponse is the response struct for api CreateAsyncPredict
type CreateAsyncPredictResponse struct {
	*responses.BaseResponse
	RequestId      string `json:"RequestId" xml:"RequestId"`
	AsyncPredictId int64  `json:"AsyncPredictId" xml:"AsyncPredictId"`
}

// CreateCreateAsyncPredictRequest creates a request to invoke CreateAsyncPredict API
func CreateCreateAsyncPredictRequest() (request *CreateAsyncPredictRequest) {
	request = &CreateAsyncPredictRequest{
		RpcRequest: &requests.RpcRequest{},
	}
	request.InitWithApiInfo("nlp-automl", "2019-11-11", "CreateAsyncPredict", "nlpautoml", "openAPI")
	return
}

// CreateCreateAsyncPredictResponse creates a response to parse from CreateAsyncPredict response
func CreateCreateAsyncPredictResponse() (response *CreateAsyncPredictResponse) {
	response = &CreateAsyncPredictResponse{
		BaseResponse: &responses.BaseResponse{},
	}
	return
}


text:
'use strict';

angular.module('mean.system').controller('library_tranctions_Ctrl',['SessionService', '$scope','$http','Global', 'toaster', 'httpErrorService', 'spinnerService', '$location',
	function(SessionService, $scope, $http, Global, toaster, httpErrorService, spinnerService, $location){
	    $scope.limit                = 5;
	    $scope.currentPage          = 1;
	    $scope.maxSize              = 5;

		// Fuction callSuccessError to show sucees or error message /
	    $scope.callSuccessError = function(type, title){
	      toaster.pop({type: type, title: title});// Dispay a flash on brower along with title(message).
	    };

	    // Show details in pop-up functions
	    $scope.get_transaction_detail = function(data){
	     $scope.transaction_data = data;
	     console.log($scope.transaction_data.usrs.name);
	    };

		 // Show the the list of transactions.
		$scope.get_library_transactions = function(limit, pageNumber){
			spinnerService.show('userSpinner');
			$http.post('/api/lms/get_library_transactions', {limit:limit, pageNumber:pageNumber}).success(function(data){
				if(data.result == 'Success' && data.data.length>0){
					$scope.show_transactions = true;
					$scope.get_transactions  = data.data;
					$scope.total_trancations = data.count;
					$scope.indexIncrement = $scope.currentPage > 0 ? (($scope.currentPage-1)*$scope.limit): 0;
				}else{
					$scope.show_transactios = false;
	      			$scope.callSuccessError('error', 'No trancations found in database');
				}
				spinnerService.hide('userSpinner');
			}).error(function (data, status){
			  	spinnerService.hide('userSpinner');
	          	var httpError = httpErrorService.httpErrorMessage(data, status);
	         	$scope.callSuccessError('error', httpError);
			});
		};

		$scope.pageChanged = function() {
           $scope.get_library_transactions($scope.limit, $scope.currentPage);
	     };

	}]);


text:
<form [formGroup]="cameraForm" (ngSubmit)="onSubmit()" (keydown.enter)="$event.preventDefault()" novalidate>

      <md-input-container [dividerColor]="!(formErrors.name)? 'primary': 'warn'">
        <input mdInput placeholder="Name" formControlName="name">
      </md-input-container>

          {{ formErrors.name }}

      <md-input-container [dividerColor]="(!formErrors.src)? 'primary': 'warn'">
        <input mdInput placeholder="Source" formControlName="src">
      </md-input-container>

          {{ formErrors.src }}

      <md-input-container [dividerColor]="(!formErrors.host)? 'primary': 'warn'">
        <input mdInput placeholder="Host" formControlName="host">
      </md-input-container>

          {{ formErrors.host }}

      <md-input-container [dividerColor]="(!formErrors.port)? 'primary': 'warn'">
        <input mdInput placeholder="Port" formControlName="port">
      </md-input-container>

          {{ formErrors.port }}

      <md-input-container [dividerColor]="(!formErrors.public_url)? 'primary': 'warn'">
        <input mdInput placeholder="Public url" formControlName="public_url">
      </md-input-container>

          {{ formErrors.public_url }}

    <button md-button color="primary" (click)="closeDialog()">
      Cancel
    </button>

    <button md-raised-button [disabled]="!cameraForm.valid" type="submit" color="primary">
      Save
    </button>

</form>


text:
// Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading;

namespace Hazelcast.Examples
{
    /// <summary>
    /// Provides safe random numbers.
    /// </summary>
    internal static class RandomProvider
    {
        // Notes
        //
        // Random is *not* thread-safe
        // read
        //   https://stackoverflow.com/questions/3049467
        //   https://docs.microsoft.com/en-us/dotnet/api/system.random
        //   https://codeblog.jonskeet.uk/2009/11/04/revisiting-randomness/
        // for best-practices.

        private static readonly Random GlobalRandom = new Random();
        private static readonly object GlobalLock = new object();
        private static readonly ThreadLocal<Random> ThreadRandom = new ThreadLocal<Random>(NewRandom);

        /// <summary>
        /// Creates a new random for a thread.
        /// </summary>
        /// <returns>A new random for a thread.</returns>
        private static Random NewRandom()
        {
            // use GlobalRandom to get a random seed, using GlobalLock
            // because the Random class is not thread safe
            lock (GlobalLock) return new Random(GlobalRandom.Next());
        }

        /// <summary>
        /// Gets a thread-safe <see cref="Random"/> instance (do *not* cache this instance).
        /// </summary>
        /// <remarks>
        /// <para>The instance is thread-safe because it is local to the thread. Do *not*
        /// store the instance in a variable as that may break thread safety. Instead,
        /// retrieve it each time it is required.</para>
        /// </remarks>
        public static Random Random => ThreadRandom.Value;
    }
}


text:
"use strict";

var levels = require("../data/levels");
var prefabs = require("../data/prefabs");
var random = require("../random");

function clone(obj) {
	return JSON.parse(JSON.stringify(obj)); // gross
}

function makePrefab(name, entities) {
	var prefab = prefabs[name];
	var id = entities.create();
	Object.keys(prefab).forEach(function(key) {
		if (key === "id") {
			return;
		}
		entities.set(id, key, clone(prefab[key]));
	});
	return id;
}

function spawnFlowers(entities, prefab, position, size) {
	var flower = makePrefab(prefab, entities);
	entities.set(flower, "pods", Math.floor(random.inRange(2,6)) );
	var entitySize = entities.get(flower, "size");
	var tilesWide = Math.floor(size.width  / entitySize.width);
	var tilesTall = Math.floor(size.height / entitySize.height);
	var newX = random.inRange(0, tilesWide);
	var newY = random.inRange(0, tilesTall);
	entities.set(flower, "position", {
		"x": position.x + (newX * entitySize.width),
		"y": position.y + (newY * entitySize.height)
	});
}

var decorations = [
	"decoration1",
	"decoration2",
	"decoration3",
	"decoration4",
	"decoration5",
	"decoration6",
	"decoration7"
];

function spawnPrefabsInRect(entities, prefab, position, size) {
	var newPrefab = makePrefab(prefab, entities);
	var entitySize = entities.get(newPrefab, "size");
	var tilesWide = Math.floor(size.width  / entitySize.width);
	var tilesTall = Math.floor(size.height / entitySize.height);
	var newX = random.inRange(0, tilesWide);
	var newY = random.inRange(0, tilesTall);
	entities.set(newPrefab, "position", {
		"x": position.x + (newX * entitySize.width),
		"y": position.y + (newY * entitySize.height)
	});
}

module.exports = function(data) { // eslint-disable-line no-unused-vars
	var currentLevel = levels[0];

	for(var i =0; i < 210; i++){
		spawnPrefabsInRect(data.entities, random.from(decorations), { "x": -1000, "y": -1000 }, { "width": 4000, "height": 2500 });
	}

	for(var j =0; j < currentLevel.flowers; j++){
		spawnFlowers(data.entities, "flower", data.entities.get(2, "position"), data.entities.get(2, "size"));
	}

	var totalPods = data.entities.find("pods").reduce( function(total, currentId) {
		return total + data.entities.get(currentId, "pods");
	}, 0);

	data.entities.set(2, "totalPods", totalPods);
	data.entities.find("animated-decoration").forEach(function(id){
		var entityAnimation = data.entities.get(id, "animation");
		var animation = data.animations[entityAnimation.name];
		entityAnimation.frame = Math.floor(random.inRange(0, animation.length));
	});

	data.sounds.play("151830__gezortenplotz__swamp-01", true);

};


text:
require "great_pretender/config"
require "great_pretender/controller"
require "great_pretender/version"

module GreatPretender
end

require "great_pretender/engine" if defined? Rails


text:
package com.macasaet.fernet.jersey;

import static org.glassfish.jersey.server.spi.internal.ValueParamProvider.Priority.NORMAL;

import java.util.function.Function;

import javax.inject.Singleton;
import javax.ws.rs.NotAuthorizedException;

import org.glassfish.jersey.server.ContainerRequest;
import org.glassfish.jersey.server.model.Parameter;
import org.glassfish.jersey.server.spi.internal.ValueParamProvider;

import com.macasaet.fernet.Token;
import com.macasaet.fernet.jaxrs.FernetToken;

/**
 * {@link ValueParamProvider} that generates a Fernet {@link Token} from a REST request's auth header.
 *
 *
Copyright © 2018 Carlos Macasaet.

 *
 * @see https://stackoverflow.com/a/50980611/914887
 * @author Carlos Macasaet
 */
@Singleton
class FernetTokenValueParamProvider implements ValueParamProvider {

    private final TokenHeaderUtility tokenHeaderUtility;

    public FernetTokenValueParamProvider() {
        this(new TokenHeaderUtility());
    }

    protected FernetTokenValueParamProvider(final TokenHeaderUtility tokenHeaderUtility) {
        if (tokenHeaderUtility == null) {
            throw new IllegalArgumentException("tokenHeaderUtility cannot be null");
        }
        this.tokenHeaderUtility = tokenHeaderUtility;
    }

    public Function<ContainerRequest, Token> getValueProvider(final Parameter parameter) {
        return request -> {
            if (parameter.getRawType().equals(Token.class) && parameter.isAnnotationPresent(FernetToken.class)) {
                final Token xAuthorizationToken = getTokenHeaderUtility().getXAuthorizationToken(request);
                if (xAuthorizationToken != null) {
                    return xAuthorizationToken;
                }
                final Token authorizationToken = getTokenHeaderUtility().getAuthorizationToken(request);
                if (authorizationToken != null) {
                    return authorizationToken;
                }
                throw new NotAuthorizedException("Bearer error=\"invalid_token\", error_description=\"no token found in Authorization or X-Authorization header\"");
            }
            throw new IllegalStateException("misconfigured annotation");
        };
    }

    public PriorityType getPriority() {
        return NORMAL;
    }

    protected TokenHeaderUtility getTokenHeaderUtility() {
        return tokenHeaderUtility;
    }

}


text:
package org.openfact.testsuite.providers;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;

import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.openfact.models.ModelDuplicateException;
import org.openfact.models.OrganizationModel;
import org.openfact.models.OrganizationProvider;
import org.openfact.models.ubl.CreditNoteModel;
import org.openfact.models.ubl.provider.CreditNoteProvider;

public class CreditNoteProviderTest extends AbstractProviderTest {

    protected OrganizationModel organization;

    public void createOrganization() {
        OrganizationProvider provider = session.organizations();
        organization = provider.createOrganization("SISTCOOP");
        commit();
    }

    @Test
    public void createWithSeriesAndNumber() throws Exception {
        createOrganization();

        CreditNoteModel creditNote = session.creditNotes().addCreditNote(organization, "C002-0003");
        commit();

        assertThat(creditNote, is(notNullValue()));
        assertThat(creditNote.getId(), is(notNullValue()));
        assertThat(creditNote.getID(), is("C002-0003"));
    }

    @Test
    public void SeriesAndNumberCollision() {
        OrganizationModel sistcoop1 = session.organizations().createOrganization("SISTCOOP1");
        OrganizationModel sistcoop2 = session.organizations().createOrganization("SISTCOOP2");
        commit();

        session.creditNotes().addCreditNote(sistcoop1, "C01-001");
        session.creditNotes().addCreditNote(sistcoop2, "C01-001");
        commit();

        // Try to create creditNote with duplicate series and number
        try {
            sistcoop1 = session.organizations().getOrganizationByName("SISTCOOP1");
            session.creditNotes().addCreditNote(sistcoop1, "C01-001");
            commit();
            Assert.fail("Expected exception");
        } catch (ModelDuplicateException e) {
        }
        commit(true);

        // Ty to rename creditNote to duplicate series and number
        sistcoop1 = session.organizations().getOrganizationByName("SISTCOOP1");
        session.creditNotes().addCreditNote(sistcoop1, "C01-002");
        commit();
        try {
            sistcoop1 = session.organizations().getOrganizationByName("SISTCOOP1");
            session.creditNotes().getCreditNoteByID(sistcoop1, "C01-002").setID("C01-001");
            commit();
            Assert.fail("Expected exception");
        } catch (ModelDuplicateException e) {
        }

        resetSession();
    }

    @Test
    public void findById() throws Exception {
        createOrganization();
        CreditNoteModel creditNote1 = session.creditNotes().addCreditNote(organization, "C01-001");
        commit();

        CreditNoteModel creditNote2 = session.creditNotes().getCreditNoteById(organization, creditNote1.getId());
        assertThat(creditNote2, is(notNullValue()));
        assertThat(creditNote2.getId(), is(notNullValue()));
        assertThat(creditNote2.getId(), is(equalTo(creditNote1.getId())));
        assertThat(creditNote2.getID(), is(equalTo(creditNote1.getID())));
    }

    @Test
    public void findBySeriesAndNumber() throws Exception {
        createOrganization();
        CreditNoteProvider provider = session.creditNotes();
        CreditNoteModel creditNote1 = provider.addCreditNote(organization, "C001-0001");
        commit();

        CreditNoteModel creditNote2 = session.creditNotes().getCreditNoteByID(organization, "C001-0001");
        assertThat(creditNote2, is(notNullValue()));
        assertThat(creditNote2.getId(), is(notNullValue()));
        assertThat(creditNote2.getId(), is(equalTo(creditNote1.getId())));
        assertThat(creditNote2.getID(), is(equalTo(creditNote1.getID())));
    }

    @Test
    public void remove() throws Exception {
        createOrganization();

        CreditNoteProvider provider = session.creditNotes();
        provider.addCreditNote(organization, "C001-0001");
        commit();

        CreditNoteModel creditNote = session.creditNotes().getCreditNoteByID(organization, "C001-0001");
        assertThat(session.creditNotes().removeCreditNote(organization, creditNote), is(true));
        assertThat(session.creditNotes().removeCreditNote(organization, creditNote), is(false));
        assertThat(session.creditNotes().getCreditNoteByID(organization, "C001-0001"), is(nullValue()));
    }

    /**
     * Get creditNotes
     */
    @Test
    public void getCreditNotesByOrganization() throws Exception {
        OrganizationModel sistcoop1 = session.organizations().createOrganization("SISTCOOP1");
        OrganizationModel sistcoop2 = session.organizations().createOrganization("SISTCOOP2");
        commit();

        session.creditNotes().addCreditNote(sistcoop1, "C01-001");
        session.creditNotes().addCreditNote(sistcoop1, "C01-002");
        session.creditNotes().addCreditNote(sistcoop1, "C01-003");
        session.creditNotes().addCreditNote(sistcoop2, "C01-004");
        session.creditNotes().addCreditNote(sistcoop2, "C01-005");
        session.creditNotes().addCreditNote(sistcoop2, "C01-006");
        commit();

        List<CreditNoteModel> creditNotes1 = session.creditNotes().getCreditNotes(sistcoop1);
        List<CreditNoteModel> creditNotes2 = session.creditNotes().getCreditNotes(sistcoop2);

        List<CreditNoteModel> creditNotes3 = session.creditNotes().getCreditNotes(sistcoop1, 0, 1);

        assertThat(creditNotes1.size(), is(3));
        assertThat(creditNotes2.size(), is(3));
        assertThat(creditNotes3.size(), is(1));
    }

}


text:
module EnomAPI
  module Operations
    module Information
      # Get the domain information for a domain
      #
      # The information returned includes the following
      # - (Time) +:expires+ -- Expiration date
      # - (String) +:status+ -- Status
      # - (Array) +:nameservers+ -- Nameserver names
      #
      # @param [String] domain Domain name
      # @return [Hash] information for the domain
      def get_domain_info(domain)
        xml = send_recv(:GetDomainInfo, split_domain(domain))
        xml = xml.GetDomainInfo

        nameservers = []
        xml.services.entry do |entry,_|
          next unless entry['name'] == 'dnsserver'
          entry.configuration.dns do |dns,_|
            name = dns.to_s
            nameservers << dns.to_s unless name == ""
          end
        end

        expires = nil

        ["%m/%d/%Y %H:%M:%S %p", "%m/%d/%Y"].each do |format|
          begin
            expires = Time.strptime(xml.status.expiration.strip, format)
            break
          rescue
            next
          end
        end

        { :expires => expires,
          :status => xml.status.registrationstatus.strip,
          :nameservers => nameservers }
      end

      # Get the registration status of a domain. Used for TLDs which
      # do not register in real time.
      #
      # The hash returned includes the following information:
      # - (String) +:order_id+ -- Order ID
      # - (Integer) +:in_account+ -- In Account, one of 0, 1, 2
      # - (String) +:description+ -- Description of In Account
      # - (Time) +:expires+ -- Expiration Date
      #
      # The +:in_account+ field will have one of the following numeric values and meanings
      # - 0: Domain is not in the eNom database
      # - 1: Domain is in the eNom database and the recievers account
      # - 2: Domain is in the eNom database but not the receivers account
      #
      # The +:description+ field contains a textual representation of the +:in_account+
      # value, it will not necessarily match those given above. The meanings however
      # should be correct.
      #
      # @overload get_domain_status(domain)
      #   @param [String] domain Name of the domain to get status for
      # @overload get_domain_status(domain, order_id, order_type = :purchase)
      #   @param [String] domain Name of the domain to get status for
      #   @param [String] order_id Order ID to get information for
      #   @param [Symbol] order_type Type of order information to obtain, +:purchase+, +:transfer+, or +:extend+
      # @return [Hash] Hash of registration information
      def get_domain_status(domain, order_id = nil, order_type = :purchase)
        order_opts = order_id.nil? ? {} : { :OrderID => order_id, :OrderType => order_type }
        xml = send_recv(:GetDomainStatus, split_domain(domain).merge(order_opts))

        { :orderid => xml.OrderID,
          :in_account => xml.InAccount.to_i,
          :description => xml.StatusDesc,
          :expires => Time.parse(xml.ExpDate.strip) }
      end

      # Get the registration status of a domain.
      #
      # The returned hash has the following keys
      # - (BOOL) +:hold+ --           Registrar hold set
      # - (String) +:registration+ -- Registration status of the domain
      # - (String) +:purchase+ --     Purchase status of the domain
      #
      # Registration status will be one of
      # 1. Processing
      # 2. Registered
      # 3. Hosted
      # 4. Null
      #
      # Purchase status will be one of
      # 1. Processing
      # 2. Paid
      # 3. Null
      #
      # @param [String] domain Domain name to get registration status of
      # @return [Hash] :hold and :status
      def get_registration_status(domain)
        xml = send_recv(:GetRegistrationStatus, split_domain(domain))
        { :hold => xml.RegistrarHold?, :registration => xml.RegistrationStatus, :purchase => xml.PurchaseStatus }
      end

      # Gets information about a domain
      #
      # The returned hash contains the following keys
      # - (BOOL) +:known+ -- Whether the domain is known to eNom
      # - (BOOL) +:in_account+ -- Whether the domain belongs to the account
      # - (String) +:last_order_id+ -- Last Order ID for the domain if domain belongs to the account
      #
      # @param [String] domain Domain to check the status of
      # @param [String] type Order Type to query with, one of 'Purchase', 'Transfer' or 'Extend'
      # @return [Hash] of information about the domain
      def status_domain(domain, type = 'Purchase')
        raise ArgumentError, "type must be Purchase, Transfer or Extend" unless %w(purchase transfer extend).include?(type.downcase)
        begin
          xml = send_recv(:StatusDomain, split_domain(domain).merge(:OrderType => type))

          xml.DomainStatus do
            return { :known => (xml.Known == 'Known'),
              :in_account => xml.InAccount?,  # It'll be either 0 or 1 here, case 2 raises an exception
              :last_order_id => xml.OrderID }
          end
        rescue ResponseError => e
          if e.messages.include?("The domain does not belong to this account")
            # It returns an error if the domain is known to eNom but in another account
            return { :known => true, :in_account => false }
          end
        end
      end
    end
  end
end


text: ©  Chuck Bergeron — chuck@chuckbergeron.io