text:
namespace IdiomMatcher {

    // to slim down json files, the default aren't serialized by default
    extern bool serializeDefaultValues; // default = false

    class EA {
	public:
	typedef uintmax_t EAValue_t;
	EA(const EAValue_t value) : _value(value){};

        EAValue_t getValue() const { return _value; };

        std::string description() const;

        bool operator==(const EA &other) const;
		bool operator<(const EA &other) const;
        bool operator<=(const EA &other) const;

    private:
        EAValue_t _value;
    };

    const EA InvalidEA(UINTMAX_MAX);

    class Operand {
    public:
        Operand(const std::string &text, const std::vector<std::string> &registers = std::vector<std::string>(), const std::string &extractAs = "", const std::string &regex = "", const bool nameIsTemplate = false, const bool used = true, const bool modified = false,const uintmax_t address = 0)
                : _text(text), _registers(registers), _extractAs(extractAs), _regex(regex), _nameIsTemplate(nameIsTemplate), _used(used), _modified(modified), _address(address) { }
        Operand(const std::string &text, const std::vector<std::string> &registers, const bool used, const bool modified, const uintmax_t address)
                : _text(text), _registers(registers), _extractAs(""), _regex(""), _nameIsTemplate(false), _used(used), _modified(modified), _address(address) { }

        std::string getText() const { return _text; };
        std::string getExtractAs() const { return _extractAs; };
        std::string getRegex() const { return _regex; }
		std::vector<std::string> getRegisters() const { return _registers; }

        const bool getNameIsTemplate() const { return _nameIsTemplate; }
        const bool getUsed() const { return _used; }
        const bool getModified() const { return _modified; }
	const uintmax_t getAddress() const { return _address; }

        const bool isWildcard() const { return _text.empty(); }
        std::string description() const;

    private:
        const std::string _text;
	const std::vector<std::string> _registers;
	const std::string _extractAs;
        const std::string _regex;
	const bool _nameIsTemplate;
        const bool _used;
        const bool _modified;
	const uintmax_t  _address;
    };
    typedef std::shared_ptr<Operand> Operand_Ref;
    typedef std::vector<Operand_Ref> Operands;

	class XRef {
		EA _target;
		bool _isData; // code or data reference?
		bool _isUnordinaryFlow; // is unordinary flow ( not to next instruction by linear execution) only valid if isData == false
	public:
		XRef(const EA &target, const bool isData = false, const bool isUnordinaryFlow = false) : _target(target), _isData(isData), _isUnordinaryFlow(isUnordinaryFlow) { }

		const EA getTarget() const { return _target; }
		const bool isData() const { return _isData; }
		const bool isUnordinaryFlow() const { return _isUnordinaryFlow; }
	};
	typedef std::shared_ptr<XRef> XRef_Ref;
	typedef std::vector<XRef_Ref> XRefs;

    class Instruction {
    public:
        Instruction(const std::string &mnemonic, const Operands &operands, const XRefs &xrefs, const uint16_t size = 0, const EA &ea = InvalidEA, const bool isRegex = false) : _mnemonic(mnemonic), _operands(operands), _xrefs(xrefs), _size(size), _ea(ea), _isRegex(isRegex) {};

        const Operands &getOperands() const { return _operands; }
		const XRefs &getXrefs() const { return _xrefs; }
        const std::string &getMnemonic() const { return _mnemonic; }
        const uint16_t getSize() const { return _size; }
		const EA &getEA() const { return  _ea; }
		const bool getIsRegex() const { return _isRegex; }
		std::string description() const;

    private:
        std::string _mnemonic;
        Operands _operands;
		XRefs _xrefs;
        uint16_t _size = 0;
		EA _ea;
		bool _isRegex;
    };
    typedef std::shared_ptr<Instruction> Instruction_ref;
    typedef std::vector<Instruction_ref > Instructions;

    const Instruction InvalidInstruction("invalid",Operands(),XRefs(),-1);
	const Instruction_ref InvalidInstruction_ref = std::make_shared<Instruction>(InvalidInstruction);

    class Action {
    public:
        Action(const std::string &script) : _script(script) {};

        std::string description() const;

        const std::string getScript() const { return _script; };

    private:
        const std::string _script;
    };
    typedef std::shared_ptr<Action> Action_Ref;
    typedef std::vector<Action_Ref> Actions;

    class Pattern {
    public:
		Pattern(const std::string &name, const Instructions &instructions, const std::string &architecture = "", const Actions &actions = Actions(), const bool anchorTop = false)
                : _name(name), _instructions(instructions), _actions(actions), _anchorTop(anchorTop), _architecture(architecture) { };

        Pattern(const Pattern &p) : _name(p._name), _instructions(p._instructions), _actions(p._actions), _anchorTop(p._anchorTop),_architecture(p._architecture) { };

		const std::string &getName() const { return _name; };
		const Instructions &getInstructions() const { return _instructions; };
		const Actions &getActions() const { return _actions; };
        const bool getAnchorTop() const { return _anchorTop; };
		const std::string &getArchitecture() const { return _architecture; };

    private:
        const std::string _name;
		const Instructions _instructions;
		const Actions _actions;
        const bool _anchorTop;
		const std::string _architecture;
    };
    typedef std::shared_ptr<Pattern> Pattern_ref;
    typedef std::vector<Pattern_ref > Patterns;

}
#endif //IDIOMMATCHER_PATTERN_H


text:
  * **Features**:
    * Upgraded to Wix 3.7 - [@thcristo](https://github.com/thcristo).
  * **Bugs**:
    * Bug: `TcpIp_ListAddresses` fails for computer names with exactly 15 characters (max length) - [@dblock](https://github.com/dblock).
  * **Dev**:
    * Project requires Visual Studio 2010 to build - [@thcristo](https://github.com/thcristo).
    * Upgraded Boost, CryptLib and CppUnit - [@thcristo](https://github.com/thcristo).

###  1.3.529.0 (5/29/2012)

  * **Features**:
    * First release off Github.
    * Upgraded to Wix 3.5.
    * Added `Xml_DeleteNodes`.
    * Added User Privileges `GetAccountSid`.
    * Added User Privileges `TranslateNameFormatted`.
  * **Bugs**:
    * Bug: `ODBCExecuteBinary` fails to load the binary record when the binary ID contains a . (dot) or - (dash).
    * Bug: ODBC custom actions, extensions and ODBQ miss the last character of the script output when its length equals the internal buffer size.
    * Bug: ODBC custom actions, extensions and ODBQ get confused by SQL diag messages that contain brackets.

###  1.2 (11/09/2010)

  * **Features**:
    * Added `Type` option to `ODBCExecute` and `ODBCExecuteFile` Wix extensions. Specify `SqlServer` or `Oracle` to invoke a database-specific SQL parser.
    * Added support for SQL commands (SQL server `:On Error`, `:r`, Oracle `@@`, etc.) to `ODBCExecute` and `ODBCExecuteFile` Wix extensions and `ODBC_Execute` immediate custom action.
    * Added `BasePath` option and support for SQL file inclusions (`:r`) to `ODBCExecute` and `ODBCExecuteFile` Wix extensions.
    * Added `ODBC_SQL_DELIMITER` and `ODBC_SQL_TYPE` to input parameters of `ODBC_Execute` immediate custom action.
    * Added `ODBC_Execute_Binary` immediate custom action.
    * Added `ODBC_SQL_MESSAGES` containing out-of-band SQL status messages to output parameters of `ODBC_Execute` and `ODBC_Execute_Binary` immediate custom actions.
    * Added `--flattenonly` to `ODBQ.exe`, process input without executing.
    * Added `--rawoutput` to `ODBQ.exe`, output results in 'raw' format.
    * Added `--database` to `ODBQ.exe`, default database name.
    * Added short versions of `-f (--file)` and `-o (--outputfile)` to `ODBQ.exe`.
    * Added `XsltFilename` to `ODBCExecute`, `ODBCExecuteFile` and `ODBCExecuteBinary` that specifies an optional XSLT transform for the data.
    * Added `GenerateRandomString` custom action to Cryptography.dll.
    * Added `Win32_GenerateGuidString` and `Win32_IsValidGuid` custom actions to SystemTools.dll.
    * Added `Win32_ReadFile` and `Win32_WriteFile` custom actions to SystemTools.dll with UTF-8 support.
    * Added `Service_Exists` custom action to SystemTools.dll.
    * Added `String_LTrim` and `String_RTrim` to StringTools.dll.
    * Added UTF-8 encoded file support for ODBC custom actions, Wix extensions and ODBQ.exe.
    * Added UTF-8 encoded file support to `SystemTools::TemplateFile` Wix extension.
    * Added `Win32_GetSpecialFolderPath` custom action to SystemTols.dll.
    * `DESEDE3_Encrypt` and `DESEDE3_Decrypt` now support binary data.
    * Added `Base64EncodeA`, `Base64EncodeW`, `Base64DecodeA` and `Base64DecodeW` to Cryptography.dll.
    * Added support for `sqlvariant` in ODBC custom actions, Wix extensions and ODBQ.exe.
  * **Breaking Changes**:
    * `DESEDE3_Encrypt` and `DESEDE3_Decrypt` custom actions now return empty results for empty inputs and use PKCS7 padding for encrypted values. Use a previous MSI Extensions 1.1 to decrypt and upgrade existing values.
    * `DESEDE3_Encrypt` and `DESEDE3_Decrypt` custom actions will fail if passed a key larger than 24 bytes. Previous versions silently truncated the key.
    * ODBC custom actions, extensions and ODBQ will no longer fail processing empty files. A warning will be produced instead.
  * **Misc**:
    * Build and unit tests run on Windows 7, `MSIShim` adds a dummy `Property` table with a value for `ProductCode`.
    * Connection strings in custom action data passed between immediate and deferred ODBC custom actions is now encrypted so that credentials are not logged in clear in MSI logs.
  * **Bugs**:
    * Bug: `XmlTools_XslTransform` broken for output of type text.
    * Bug: `CreateDatabases_SQLServer_Deferred` and `CreateDatabases_Access_Deferred` attempt to make a database connection even if there's nothing to do.
    * Bug: error detail lost in custom actions that rely on functions returning Win32 DWORD error codes.
    * Bug: SystemTools extensions incorrectly impersonate for file copy, move, delete, template processing and registry operations.
    * Bug: ODBC custom actions, extensions and ODBQ may fail to execute a statement at `SQLDescribeParam`.
    * Bug: ODBC custom actions, extensions and ODBQ don't work on SQL Server 2000.
    * Bug: `Win32_DirectoryCreate` works inconsistently when paths contain forward slashes depending on whether a path exists or not.
    * Bug: ODBC messages are truncated at 208 characters.
    * Bug: `SelectDbDlg` dialog mail fail when `DATABASE_SERVER` is re-defined with a custom action with "Error 2878: On the dialog SelectDbDlg the control Server has a possible value: [1]. This is an invalid or duplicate value."

###  1.1 (11/20/2009)

  * First open-source public release.

redpajama_set_name: RedPajamaGithub


text:
.class public Lcom/android/internal/app/ChooserShareActivity;
.super Lcom/android/internal/app/ResolverShareActivity;
.source "ChooserShareActivity.java"

# instance fields
.field private isLocked:Z

.field private isUnReg:Z

.field mDockReceiver:Landroid/content/BroadcastReceiver;

.field private mHandler:Landroid/os/Handler;

.field private mKeyguardManager:Landroid/app/KeyguardManager;

# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 32
    invoke-direct {p0}, Lcom/android/internal/app/ResolverShareActivity;-><init>()V

    .line 36
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/android/internal/app/ChooserShareActivity;->isUnReg:Z

    .line 76
    new-instance v0, Lcom/android/internal/app/ChooserShareActivity$1;

    invoke-direct {v0, p0}, Lcom/android/internal/app/ChooserShareActivity$1;-><init>(Lcom/android/internal/app/ChooserShareActivity;)V

    iput-object v0, p0, Lcom/android/internal/app/ChooserShareActivity;->mDockReceiver:Landroid/content/BroadcastReceiver;

    return-void
.end method

# virtual methods
.method public finish()V
    .locals 1

    .prologue
    .line 92
    iget-boolean v0, p0, Lcom/android/internal/app/ChooserShareActivity;->isUnReg:Z

    if-nez v0, :cond_0

    .line 93
    iget-object v0, p0, Lcom/android/internal/app/ChooserShareActivity;->mDockReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {p0, v0}, Lcom/android/internal/app/ChooserShareActivity;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V

    .line 94
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/android/internal/app/ChooserShareActivity;->isUnReg:Z

    .line 96
    :cond_0
    invoke-super {p0}, Lcom/android/internal/app/ResolverShareActivity;->finish()V

    .line 97
    return-void
.end method

.method protected onCreate(Landroid/os/Bundle;)V
    .locals 13
    .param p1, "savedInstanceState"    # Landroid/os/Bundle;

    .prologue
    const/4 v6, 0x0

    .line 39
    const-string v0, "power"

    invoke-virtual {p0, v0}, Lcom/android/internal/app/ChooserShareActivity;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v11

    check-cast v11, Landroid/os/PowerManager;

    .line 40
    .local v11, "pm":Landroid/os/PowerManager;
    const-string v0, "keyguard"

    invoke-virtual {p0, v0}, Lcom/android/internal/app/ChooserShareActivity;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/app/KeyguardManager;

    iput-object v0, p0, Lcom/android/internal/app/ChooserShareActivity;->mKeyguardManager:Landroid/app/KeyguardManager;

    .line 42
    invoke-virtual {p0}, Lcom/android/internal/app/ChooserShareActivity;->getIntent()Landroid/content/Intent;

    move-result-object v9

    .line 43
    .local v9, "intent":Landroid/content/Intent;
    const-string v0, "android.intent.extra.INTENT"

    invoke-virtual {v9, v0}, Landroid/content/Intent;->getParcelableExtra(Ljava/lang/String;)Landroid/os/Parcelable;

    move-result-object v12

    .line 44
    .local v12, "targetParcelable":Landroid/os/Parcelable;
    instance-of v0, v12, Landroid/content/Intent;

    if-nez v0, :cond_0

    .line 45
    const-string v0, "ChooserShareActivity"

    new-instance v1, Ljava/lang/StringBuilder;

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

    const-string v5, "Target is not an intent: "

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

    move-result-object v1

    invoke-virtual {v1, v12}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v1

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

    move-result-object v1

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

    .line 46
    invoke-virtual {p0}, Lcom/android/internal/app/ChooserShareActivity;->finish()V

    .line 74
    :goto_0
    return-void

    :cond_0
    move-object v2, v12

    .line 49
    check-cast v2, Landroid/content/Intent;

    .line 50
    .local v2, "target":Landroid/content/Intent;
    const-string v0, "android.intent.extra.TITLE"

    invoke-virtual {v9, v0}, Landroid/content/Intent;->getCharSequenceExtra(Ljava/lang/String;)Ljava/lang/CharSequence;

    move-result-object v3

    .line 51
    .local v3, "title":Ljava/lang/CharSequence;
    if-nez v3, :cond_1

    .line 52
    invoke-virtual {p0}, Lcom/android/internal/app/ChooserShareActivity;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const v1, 0x1040482

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

    move-result-object v3

    .line 54
    :cond_1
    const-string v0, "android.intent.extra.INITIAL_INTENTS"

    invoke-virtual {v9, v0}, Landroid/content/Intent;->getParcelableArrayExtra(Ljava/lang/String;)[Landroid/os/Parcelable;

    move-result-object v10

    .line 55
    .local v10, "pa":[Landroid/os/Parcelable;
    const/4 v4, 0x0

    .line 56
    .local v4, "initialIntents":[Landroid/content/Intent;
    if-eqz v10, :cond_3

    .line 57
    array-length v0, v10

    new-array v4, v0, [Landroid/content/Intent;

    .line 58
    const/4 v8, 0x0

    .local v8, "i":I
    :goto_1
    array-length v0, v10

    if-ge v8, v0, :cond_3

    .line 59
    aget-object v0, v10, v8

    instance-of v0, v0, Landroid/content/Intent;

    if-nez v0, :cond_2

    .line 60
    const-string v0, "ChooserShareActivity"

    new-instance v1, Ljava/lang/StringBuilder;

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

    const-string v5, "Initial intent #"

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

    move-result-object v1

    invoke-virtual {v1, v8}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v5, " not an Intent: "

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

    move-result-object v1

    aget-object v5, v10, v8

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

    move-result-object v1

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

    move-result-object v1

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

    .line 62
    invoke-virtual {p0}, Lcom/android/internal/app/ChooserShareActivity;->finish()V

    goto :goto_0

    .line 65
    :cond_2
    aget-object v0, v10, v8

    check-cast v0, Landroid/content/Intent;

    aput-object v0, v4, v8

    .line 58
    add-int/lit8 v8, v8, 0x1

    goto :goto_1

    .line 68
    .end local v8    # "i":I
    :cond_3
    const/4 v5, 0x0

    move-object v0, p0

    move-object v1, p1

    invoke-super/range {v0 .. v6}, Lcom/android/internal/app/ResolverShareActivity;->onCreate(Landroid/os/Bundle;Landroid/content/Intent;Ljava/lang/CharSequence;[Landroid/content/Intent;Ljava/util/List;Z)V

    .line 70
    new-instance v7, Landroid/content/IntentFilter;

    invoke-direct {v7}, Landroid/content/IntentFilter;-><init>()V

    .line 71
    .local v7, "filter":Landroid/content/IntentFilter;
    const-string v0, "android.intent.action.CAMERA_STOP_TO_CHOOSER"

    invoke-virtual {v7, v0}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    .line 72
    iget-object v0, p0, Lcom/android/internal/app/ChooserShareActivity;->mDockReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {p0, v0, v7}, Lcom/android/internal/app/ChooserShareActivity;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 73
    iput-boolean v6, p0, Lcom/android/internal/app/ChooserShareActivity;->isUnReg:Z

    goto :goto_0
.end method

.method protected onStop()V
    .locals 0

    .prologue
    .line 86
    invoke-super {p0}, Lcom/android/internal/app/ResolverShareActivity;->onStop()V

    .line 87
    invoke-virtual {p0}, Lcom/android/internal/app/ChooserShareActivity;->finish()V

    .line 88
    return-void
.end method


text:
package app.color.paint;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import app.color.R;
import app.color.view.CellPhoneView;

public class BackgroundScreenLayer implements CellPhoneView.ScreenLayer {
  static final float ACTION_BAR_FACTOR = .085f;
  static final float ICON_FACTOR = .7f;

  final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
  final Paint mTitlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
  final RectF mActionBar = new RectF();
  final RectF mIcon = new RectF();
  final RectF mImage = new RectF();
  final RectF mOverflow = new RectF();
  final RectF mLabel = new RectF();
  final RectF mSubLabel = new RectF();
  final Path mTitlePath = new Path();
  final int mActionBarColor;
  final int mItemColor;
  final int mSubLabelColor;

  public BackgroundScreenLayer(Context context) {
    Resources res = context.getResources();
    mActionBarColor = res.getColor(R.color.cartoon_action_bar);
    mItemColor = res.getColor(R.color.cartoon_items);
    mSubLabelColor = res.getColor(R.color.cartoon_sublabel);

    mTitlePaint.setColor(mItemColor);
    mTitlePaint.setStyle(Paint.Style.STROKE);
    mTitlePaint.setStrokeWidth(res.getDimension(R.dimen.check_mark_stroke) / 2);
    mTitlePaint.setStrokeCap(Paint.Cap.ROUND);
    mTitlePaint.setStrokeJoin(Paint.Join.ROUND);
  }

  @Override
  public void draw(Canvas canvas, float width, float height) {
    // draw action bar
    mPaint.setColor(mActionBarColor);
    canvas.drawRect(mActionBar, mPaint);

    // draw icon
    mPaint.setColor(mItemColor);
    canvas.drawRect(mIcon, mPaint);

    // draw title
    canvas.drawPath(mTitlePath, mTitlePaint);

    // draw overflow
    int overflowCount = canvas.save();

    mPaint.setColor(mItemColor);

    float overflowHeight = mOverflow.height();
    int overflowSpacing = (int) ((mActionBar.height() - overflowHeight * 3) / 4);

    float overflowMargin = overflowHeight / 2;
    canvas.translate(0, overflowSpacing + overflowHeight);
    for (int i = 0; i < 3; i++) {
      canvas.drawRect(mOverflow, mPaint);
      canvas.translate(0, overflowMargin + overflowHeight);
    }
    canvas.restoreToCount(overflowCount);

    // draw images
    int imagesCount = canvas.save();
    float radius = mImage.height() / 5;
    for (int i = 0; i < 10; i++) {
      mPaint.setColor(mItemColor);
      canvas.drawRoundRect(mImage, radius, radius, mPaint);
      canvas.drawRect(mLabel, mPaint);

      mPaint.setColor(mSubLabelColor);
      canvas.drawRect(mSubLabel, mPaint);
      canvas.translate(0, mImage.left + mImage.height());
    }

    canvas.restoreToCount(imagesCount);
  }

  @Override
  public void invalidate(float screenWidth, float screenHeight) {
    mActionBar.set(0, 0, screenWidth, screenHeight * ACTION_BAR_FACTOR);

    float actionBarHeight = mActionBar.height();
    float iconSize = actionBarHeight * ICON_FACTOR;
    float iconPadding = (actionBarHeight - iconSize) / 2;
    mIcon.set(iconPadding, iconPadding, iconPadding + iconSize, iconPadding + iconSize);

    float pathInitialY = mIcon.bottom - iconPadding;
    mTitlePath.moveTo(mIcon.right + iconPadding, pathInitialY);
    float writtingSize = iconSize / 3;
    float x = mIcon.right + iconPadding + writtingSize;
    for (int i = 0; i < 10; i++, x += writtingSize) {
      float newY = i % 2 == 0 ? pathInitialY - writtingSize : pathInitialY;
      mTitlePath.lineTo(x, newY);
    }

    float overflowSize = actionBarHeight / 8;
    float overflowLeft = screenWidth - iconSize / 2 - iconPadding - overflowSize / 2;
    mOverflow.set(overflowLeft, 0, overflowLeft + overflowSize, overflowSize);

    float imagePadding = iconPadding * 2;
    float imageSize = iconSize * 2;
    float imageTop = imagePadding + actionBarHeight;
    mImage.set(imagePadding, imageTop, imagePadding + imageSize, imageTop + imageSize);

    float labelLeft = mImage.right + imagePadding;
    float labelHeight = mImage.height() / 5;
    float labelTop = imageTop + labelHeight;
    mLabel.set(labelLeft, labelTop, screenWidth - imagePadding, labelTop + labelHeight);

    float sublabelTop = mLabel.bottom + labelHeight;
    mSubLabel.set(labelLeft, sublabelTop, labelLeft + mLabel.width() / 2, sublabelTop + labelHeight);
  }
}


text:
package com.evolveum.midpoint.model.impl.lens.projector;

import com.evolveum.midpoint.model.api.PolicyViolationException;
import com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision;
import com.evolveum.midpoint.model.common.expression.ItemDeltaItem;
import com.evolveum.midpoint.model.common.expression.Source;
import com.evolveum.midpoint.model.common.mapping.Mapping;
import com.evolveum.midpoint.model.impl.lens.LensContext;
import com.evolveum.midpoint.model.impl.lens.LensFocusContext;
import com.evolveum.midpoint.model.impl.lens.LensProjectionContext;
import com.evolveum.midpoint.model.impl.lens.LensUtil;
import com.evolveum.midpoint.model.impl.lens.SynchronizationIntent;
import com.evolveum.midpoint.prism.OriginType;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismObjectDefinition;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.PrismPropertyValue;
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple;
import com.evolveum.midpoint.prism.delta.PropertyDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.constants.ExpressionConstants;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceActivationDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceBidirectionalMappingType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationValidityCapabilityType;

import org.apache.commons.lang.mutable.MutableBoolean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

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

/**
 * The processor that takes care of user activation mapping to an account (outbound direction).
 *
 * @author Radovan Semancik
 */
@Component
public class ActivationProcessor {

    private static final Trace LOGGER = TraceManager.getTrace(ActivationProcessor.class);

	private static final QName SHADOW_EXISTS_PROPERTY_NAME = new QName(SchemaConstants.NS_C, "shadowExists");
	private static final QName LEGAL_PROPERTY_NAME = new QName(SchemaConstants.NS_C, "legal");
	private static final QName FOCUS_EXISTS_PROPERTY_NAME = new QName(SchemaConstants.NS_C, "focusExists");

	private PrismObjectDefinition<UserType> userDefinition;
	private PrismContainerDefinition<ActivationType> activationDefinition;

    @Autowired(required = true)
    private PrismContext prismContext;

    @Autowired(required = true)
    private MappingEvaluationHelper mappingHelper;

    public <O extends ObjectType, F extends FocusType> void processActivation(LensContext<O> context,
    		LensProjectionContext projectionContext, XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException {

    	LensFocusContext<O> focusContext = context.getFocusContext();
    	if (focusContext != null && !FocusType.class.isAssignableFrom(focusContext.getObjectTypeClass())) {
    		// We can do this only for user.
//    		processActivationMetadata(context, projectionContext, now, result);
    		return;
    	}

    	processActivationFocal((LensContext<F>)context, projectionContext, now, task, result);
    }

    private <F extends FocusType> void processActivationFocal(LensContext<F> context,
    		LensProjectionContext projectionContext, XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException {
    	LensFocusContext<F> focusContext = context.getFocusContext();
    	if (focusContext == null) {
    		processActivationMetadata(context, projectionContext, now, result);
    		return;
    	}
    	processActivationUserCurrent(context, projectionContext, now, task, result);
    	processActivationMetadata(context, projectionContext, now, result);
    	processActivationUserFuture(context, projectionContext, now, task, result);
    }

    public <F extends FocusType> void processActivationUserCurrent(LensContext<F> context, LensProjectionContext accCtx,
    		XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException {

    	String accCtxDesc = accCtx.toHumanReadableString();
    	SynchronizationPolicyDecision decision = accCtx.getSynchronizationPolicyDecision();
    	SynchronizationIntent synchronizationIntent = accCtx.getSynchronizationIntent();

    	if (decision == SynchronizationPolicyDecision.BROKEN) {
    		LOGGER.trace("Broken projection {}, skipping further activation processing", accCtxDesc);
    		return;
    	}
    	if (decision != null) {
    		throw new IllegalStateException("Decision "+decision+" already present for projection "+accCtxDesc);
    	}

    	if (accCtx.isThombstone() || synchronizationIntent == SynchronizationIntent.UNLINK) {
    		accCtx.setSynchronizationPolicyDecision(SynchronizationPolicyDecision.UNLINK);
    		LOGGER.trace("Evaluated decision for {} to {}, skipping further activation processing", accCtxDesc, SynchronizationPolicyDecision.UNLINK);
    		return;
    	}

    	if (synchronizationIntent == SynchronizationIntent.DELETE || accCtx.isDelete()) {
    		// TODO: is this OK?
    		accCtx.setSynchronizationPolicyDecision(SynchronizationPolicyDecision.DELETE);
    		LOGGER.trace("Evaluated decision for {} to {}, skipping further activation processing", accCtxDesc, SynchronizationPolicyDecision.DELETE);
    		return;
    	}

    	boolean shadowShouldExist = evaluateExistenceMapping(context, accCtx, now, true, task, result);

    	LOGGER.trace("Evaluated intended existence of projection {} to {}", accCtxDesc, shadowShouldExist);

    	// Let's reconcile the existence intent (shadowShouldExist) and the synchronization intent in the context

    	LensProjectionContext lowerOrderContext = LensUtil.findLowerOrderContext(context, accCtx);

    	if (synchronizationIntent == null || synchronizationIntent == SynchronizationIntent.SYNCHRONIZE) {
	    	if (shadowShouldExist) {
	    		accCtx.setActive(true);
	    		if (accCtx.isExists()) {
	    			if (lowerOrderContext != null && lowerOrderContext.isDelete()) {
    					// HACK HACK HACK
    					decision = SynchronizationPolicyDecision.DELETE;
    				} else {
    					decision = SynchronizationPolicyDecision.KEEP;
    				}
	    		} else {
	    			if (lowerOrderContext != null) {
	    				if (lowerOrderContext.isDelete()) {
	    					// HACK HACK HACK
	    					decision = SynchronizationPolicyDecision.DELETE;
	    				} else {
		    				// If there is a lower-order context then that one will be ADD
		    				// and this one is KEEP. When the execution comes to this context
		    				// then the projection already exists
		    				decision = SynchronizationPolicyDecision.KEEP;
	    				}
	    			} else {
	    				decision = SynchronizationPolicyDecision.ADD;
	    			}
	    		}
	    	} else {
	    		// Delete
	    		if (accCtx.isExists()) {
	    			decision = SynchronizationPolicyDecision.DELETE;
	    		} else {
	    			// we should delete the entire context, but then we will lost track of what
	    			// happened. So just ignore it.
	    			decision = SynchronizationPolicyDecision.IGNORE;
	    			// if there are any triggers then move them to focus. We may still need them.
	    			LensUtil.moveTriggers(accCtx, context.getFocusContext());
	    		}
	    	}

    	} else if (synchronizationIntent == SynchronizationIntent.ADD) {
    		if (shadowShouldExist) {
    			accCtx.setActive(true);
    			if (accCtx.isExists()) {
    				// Attempt to add something that is already there, but should be OK
	    			decision = SynchronizationPolicyDecision.KEEP;
	    		} else {
	    			decision = SynchronizationPolicyDecision.ADD;
	    		}
    		} else {
    			throw new PolicyViolationException("Request to add projection "+accCtxDesc+" but the activation policy decided that it should not exist");
    		}

    	} else if (synchronizationIntent == SynchronizationIntent.KEEP) {
	    	if (shadowShouldExist) {
	    		accCtx.setActive(true);
	    		if (accCtx.isExists()) {
	    			decision = SynchronizationPolicyDecision.KEEP;
	    		} else {
	    			decision = SynchronizationPolicyDecision.ADD;
	    		}
	    	} else {
	    		throw new PolicyViolationException("Request to keep projection "+accCtxDesc+" but the activation policy decided that it should not exist");
	    	}

    	} else {
    		throw new IllegalStateException("Unknown sync intent "+synchronizationIntent);
    	}

    	LOGGER.trace("Evaluated decision for projection {} to {}", accCtxDesc, decision);

    	accCtx.setSynchronizationPolicyDecision(decision);

        PrismObject<F> focusNew = context.getFocusContext().getObjectNew();
        if (focusNew == null) {
            // This must be a user delete or something similar. No point in proceeding
            LOGGER.trace("focusNew is null, skipping activation processing of {}", accCtxDesc);
            return;
        }

    	if (decision == SynchronizationPolicyDecision.UNLINK || decision == SynchronizationPolicyDecision.DELETE) {
    		LOGGER.trace("Decision is {}, skipping activation properties processing for {}", decision, accCtxDesc);
    		return;
    	}

    	ResourceObjectTypeDefinitionType resourceAccountDefType = accCtx.getResourceObjectTypeDefinitionType();
        if (resourceAccountDefType == null) {
            LOGGER.trace("No refined object definition, therefore also no activation outbound definition, skipping activation processing for account " + accCtxDesc);
            return;
        }
        ResourceActivationDefinitionType activationType = resourceAccountDefType.getActivation();
        if (activationType == null) {
            LOGGER.trace("No activation definition in projection {}, skipping activation properties processing", accCtxDesc);
            return;
        }

        ActivationCapabilityType capActivation = ResourceTypeUtil.getEffectiveCapability(accCtx.getResource(), ActivationCapabilityType.class);
        if (capActivation == null) {
        	LOGGER.trace("Skipping activation status and validity processing because {} has no activation capability", accCtx.getResource());
        	return;
        }

        ActivationStatusCapabilityType capStatus = capActivation.getStatus();
        ActivationValidityCapabilityType capValidFrom = capActivation.getValidFrom();
        ActivationValidityCapabilityType capValidTo = capActivation.getValidTo();

        if (capStatus != null) {
	    	evaluateActivationMapping(context, accCtx,
	    			activationType.getAdministrativeStatus(),
	    			SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS,
	    			capActivation, now, true, ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart(), task, result);
        } else {
        	LOGGER.trace("Skipping activation status processing because {} does not have activation status capability", accCtx.getResource());
        }

        if (capValidFrom != null) {
	    	evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
	    			SchemaConstants.PATH_ACTIVATION_VALID_FROM, SchemaConstants.PATH_ACTIVATION_VALID_FROM,
	    			null, now, true, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
        } else {
        	LOGGER.trace("Skipping activation validFrom processing because {} does not have activation validFrom capability", accCtx.getResource());
        }

        if (capValidTo != null) {
	    	evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
	    			SchemaConstants.PATH_ACTIVATION_VALID_TO, SchemaConstants.PATH_ACTIVATION_VALID_TO,
	    			null, now, true, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
	    } else {
	    	LOGGER.trace("Skipping activation validTo processing because {} does not have activation validTo capability", accCtx.getResource());
	    }

    }

    public <F extends FocusType> void processActivationMetadata(LensContext<F> context, LensProjectionContext accCtx,
    		XMLGregorianCalendar now, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException {
    	ObjectDelta<ShadowType> projDelta = accCtx.getDelta();
    	if (projDelta == null) {
    		return;
    	}

    	PropertyDelta<ActivationStatusType> statusDelta = projDelta.findPropertyDelta(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);

    	if (statusDelta != null && !statusDelta.isDelete()) {
    		// timestamps
    		PrismProperty<ActivationStatusType> statusPropNew = (PrismProperty<ActivationStatusType>) statusDelta.getItemNew();
    		ActivationStatusType statusNew = statusPropNew.getRealValue();
			PropertyDelta<XMLGregorianCalendar> timestampDelta = LensUtil.createActivationTimestampDelta(statusNew,
					now, getActivationDefinition(), OriginType.OUTBOUND);
    		accCtx.swallowToSecondaryDelta(timestampDelta);

    		// disableReason
    		if (statusNew == ActivationStatusType.DISABLED) {
    			PropertyDelta<String> disableReasonDelta = projDelta.findPropertyDelta(SchemaConstants.PATH_ACTIVATION_DISABLE_REASON);
    			if (disableReasonDelta == null) {
    				String disableReason = null;
    				ObjectDelta<ShadowType> projPrimaryDelta = accCtx.getPrimaryDelta();
    				ObjectDelta<ShadowType> projSecondaryDelta = accCtx.getSecondaryDelta();
    				if (projPrimaryDelta != null
    						&& projPrimaryDelta.findPropertyDelta(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS) != null
    						&& (projSecondaryDelta == null || projSecondaryDelta.findPropertyDelta(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS) == null)) {
    						disableReason = SchemaConstants.MODEL_DISABLE_REASON_EXPLICIT;
    				} else if (accCtx.isLegal()) {
						disableReason = SchemaConstants.MODEL_DISABLE_REASON_MAPPED;
					} else {
						disableReason = SchemaConstants.MODEL_DISABLE_REASON_DEPROVISION;
					}

    				PrismPropertyDefinition<String> disableReasonDef = activationDefinition.findPropertyDefinition(ActivationType.F_DISABLE_REASON);
    				disableReasonDelta = disableReasonDef.createEmptyDelta(new ItemPath(FocusType.F_ACTIVATION, ActivationType.F_DISABLE_REASON));
    				disableReasonDelta.setValueToReplace(new PrismPropertyValue<String>(disableReason, OriginType.OUTBOUND, null));
    				accCtx.swallowToSecondaryDelta(disableReasonDelta);
    			}
    		}
    	}

    }

    public <F extends FocusType> void processActivationUserFuture(LensContext<F> context, LensProjectionContext accCtx,
    		XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException {
    	String accCtxDesc = accCtx.toHumanReadableString();
    	SynchronizationPolicyDecision decision = accCtx.getSynchronizationPolicyDecision();
    	SynchronizationIntent synchronizationIntent = accCtx.getSynchronizationIntent();

    	if (accCtx.isThombstone() || decision == SynchronizationPolicyDecision.BROKEN
    			|| decision == SynchronizationPolicyDecision.IGNORE
    			|| decision == SynchronizationPolicyDecision.UNLINK || decision == SynchronizationPolicyDecision.DELETE) {
    		return;
    	}

    	accCtx.recompute();

    	evaluateExistenceMapping(context, accCtx, now, false, task, result);

        PrismObject<F> focusNew = context.getFocusContext().getObjectNew();
        if (focusNew == null) {
            // This must be a user delete or something similar. No point in proceeding
            LOGGER.trace("focusNew is null, skipping activation processing of {}", accCtxDesc);
            return;
        }

    	ResourceObjectTypeDefinitionType resourceAccountDefType = accCtx.getResourceObjectTypeDefinitionType();
        if (resourceAccountDefType == null) {
            return;
        }
        ResourceActivationDefinitionType activationType = resourceAccountDefType.getActivation();
        if (activationType == null) {
            return;
        }

        ActivationCapabilityType capActivation = ResourceTypeUtil.getEffectiveCapability(accCtx.getResource(), ActivationCapabilityType.class);
        if (capActivation == null) {
        	return;
        }

        ActivationStatusCapabilityType capStatus = capActivation.getStatus();
        ActivationValidityCapabilityType capValidFrom = capActivation.getValidFrom();
        ActivationValidityCapabilityType capValidTo = capActivation.getValidTo();

        if (capStatus != null) {

	    	evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
	    			SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS,
	    			capActivation, now, false, ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart(), task, result);
        }

        if (capValidFrom != null) {
	    	evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
	    			SchemaConstants.PATH_ACTIVATION_VALID_FROM, SchemaConstants.PATH_ACTIVATION_VALID_FROM,
	    			null, now, false, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
        }

        if (capValidTo != null) {
	    	evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
	    			SchemaConstants.PATH_ACTIVATION_VALID_TO, SchemaConstants.PATH_ACTIVATION_VALID_TO,
	    			null, now, false, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
	    }

    }

    private <F extends FocusType> boolean evaluateExistenceMapping(final LensContext<F> context,
    		final LensProjectionContext accCtx, final XMLGregorianCalendar now, final boolean current,
            Task task, final OperationResult result)
    				throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
    	String accCtxDesc = accCtx.toHumanReadableString();

    	Boolean legal = accCtx.isLegal();
    	if (legal == null) {
    		throw new IllegalStateException("Null 'legal' for "+accCtxDesc);
    	}

    	ResourceObjectTypeDefinitionType resourceAccountDefType = accCtx.getResourceObjectTypeDefinitionType();
        if (resourceAccountDefType == null) {
            return legal;
        }
        ResourceActivationDefinitionType activationType = resourceAccountDefType.getActivation();
        if (activationType == null) {
            return legal;
        }
        ResourceBidirectionalMappingType existenceType = activationType.getExistence();
        if (existenceType == null) {
            return legal;
        }
        List<MappingType> outbound = existenceType.getOutbound();
        if (outbound == null || outbound.isEmpty()) {
        	// "default mapping"
            return legal;
        }

        MappingInitializer<PrismPropertyValue<Boolean>> initializer = new MappingInitializer<PrismPropertyValue<Boolean>>() {
			@Override
			public void initialize(Mapping<PrismPropertyValue<Boolean>> existenceMapping) throws SchemaException {
		        // Target
		        PrismPropertyDefinition<Boolean> shadowExistsDef = new PrismPropertyDefinition<Boolean>(SHADOW_EXISTS_PROPERTY_NAME,
		        		DOMUtil.XSD_BOOLEAN, prismContext);
		        shadowExistsDef.setMinOccurs(1);
		        shadowExistsDef.setMaxOccurs(1);
				existenceMapping.setDefaultTargetDefinition(shadowExistsDef);

				// Source: legal
		        ItemDeltaItem<PrismPropertyValue<Boolean>> legalSourceIdi = getLegalIdi(accCtx);
		        Source<PrismPropertyValue<Boolean>> legalSource
		        	= new Source<PrismPropertyValue<Boolean>>(legalSourceIdi, ExpressionConstants.VAR_LEGAL);
				existenceMapping.setDefaultSource(legalSource);

				// Source: focusExists
		        ItemDeltaItem<PrismPropertyValue<Boolean>> focusExistsSourceIdi = getFocusExistsIdi(context.getFocusContext());
		        Source<PrismPropertyValue<Boolean>> focusExistsSource
		        	= new Source<PrismPropertyValue<Boolean>>(focusExistsSourceIdi, ExpressionConstants.VAR_FOCUS_EXISTS);
				existenceMapping.addSource(focusExistsSource);

				// Variable: focus
				existenceMapping.addVariableDefinition(ExpressionConstants.VAR_FOCUS, context.getFocusContext().getObjectDeltaObject());

		        // Variable: user (for convenience, same as "focus")
				existenceMapping.addVariableDefinition(ExpressionConstants.VAR_USER, context.getFocusContext().getObjectDeltaObject());

				// Variable: shadow
				existenceMapping.addVariableDefinition(ExpressionConstants.VAR_SHADOW, accCtx.getObjectDeltaObject());

				// Variable: resource
				existenceMapping.addVariableDefinition(ExpressionConstants.VAR_RESOURCE, accCtx.getResource());

		        existenceMapping.setOriginType(OriginType.OUTBOUND);
		        existenceMapping.setOriginObject(accCtx.getResource());
            }

        };

		PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = mappingHelper.evaluateMappingSetProjection(
				outbound, "outbound existence mapping in projection " + accCtxDesc,
        		now, initializer, null, null, accCtx.getObjectOld(), current, null, context, accCtx, task, result);

		if (outputTriple == null) {
			// The "default existence mapping"
			return legal;
		}

		Collection<PrismPropertyValue<Boolean>> nonNegativeValues = outputTriple.getNonNegativeValues();
        if (nonNegativeValues == null || nonNegativeValues.isEmpty()) {
        	throw new ExpressionEvaluationException("Activation existence expression resulted in null or empty value for projection " + accCtxDesc);
        }
        if (nonNegativeValues.size() > 1) {
        	throw new ExpressionEvaluationException("Activation existence expression resulted in too many values ("+nonNegativeValues.size()+") for projection " + accCtxDesc);
        }

        return nonNegativeValues.iterator().next().getValue();
    }

	private <T, F extends FocusType> PropertyDelta<T> evaluateActivationMapping(final LensContext<F> context,
			final LensProjectionContext accCtx, ResourceBidirectionalMappingType bidirectionalMappingType,
			final ItemPath focusPropertyPath, final ItemPath projectionPropertyPath,
   			final ActivationCapabilityType capActivation, XMLGregorianCalendar now, final boolean current,
   			String desc, final Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {

   		String accCtxDesc = accCtx.toHumanReadableString();

        if (bidirectionalMappingType == null) {
            LOGGER.trace("No '{}' definition in activation in projection {}, skipping", desc, accCtxDesc);
            return null;
        }
        List<MappingType> outbound = bidirectionalMappingType.getOutbound();
        if (outbound == null || outbound.isEmpty()) {
            LOGGER.trace("No outbound definition in '{}' definition in activation in projection {}, skipping", desc, accCtxDesc);
            return null;
        }

        ObjectDelta<ShadowType> projectionDelta = accCtx.getDelta();
        PropertyDelta<T> shadowPropertyDelta = LensUtil.findAPrioriDelta(context, accCtx, projectionPropertyPath);

        PrismObject<ShadowType> shadowNew = accCtx.getObjectNew();
        PrismProperty<T> shadowPropertyNew = null;
        if (shadowNew != null) {
        	shadowPropertyNew = shadowNew.findProperty(projectionPropertyPath);
        }

        MappingInitializer<PrismPropertyValue<T>> initializer = new MappingInitializer<PrismPropertyValue<T>>() {
			@Override
			public void initialize(Mapping<PrismPropertyValue<T>> mapping) throws SchemaException {
				// Source: administrativeStatus, validFrom or validTo
		        ItemDeltaItem<PrismPropertyValue<T>> sourceIdi = context.getFocusContext().getObjectDeltaObject().findIdi(focusPropertyPath);

		        if (capActivation != null) {
			        ActivationValidityCapabilityType capValidFrom = capActivation.getValidFrom();
			        ActivationValidityCapabilityType capValidTo = capActivation.getValidTo();

			        // Source: computedShadowStatus
			        ItemDeltaItem<PrismPropertyValue<ActivationStatusType>> computedIdi;
			        if (capValidFrom != null && capValidTo != null) {
			        	// "Native" validFrom and validTo, directly use administrativeStatus
			        	computedIdi = context.getFocusContext().getObjectDeltaObject().findIdi(focusPropertyPath);

			        } else {
			        	// Simulate validFrom and validTo using effectiveStatus
			        	computedIdi = context.getFocusContext().getObjectDeltaObject().findIdi(SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS);

			        }

			        Source<PrismPropertyValue<ActivationStatusType>> computedSource = new Source<PrismPropertyValue<ActivationStatusType>>(computedIdi, ExpressionConstants.VAR_INPUT);

			        mapping.setDefaultSource(computedSource);

			        Source<PrismPropertyValue<T>> source = new Source<PrismPropertyValue<T>>(sourceIdi, ExpressionConstants.VAR_ADMINISTRATIVE_STATUS);
			        mapping.addSource(source);

		        } else {
		        	Source<PrismPropertyValue<T>> source = new Source<PrismPropertyValue<T>>(sourceIdi, ExpressionConstants.VAR_INPUT);
		        	mapping.setDefaultSource(source);
		        }

				// Source: legal
		        ItemDeltaItem<PrismPropertyValue<Boolean>> legalIdi = getLegalIdi(accCtx);
		        Source<PrismPropertyValue<Boolean>> legalSource = new Source<PrismPropertyValue<Boolean>>(legalIdi, ExpressionConstants.VAR_LEGAL);
		        mapping.addSource(legalSource);

		        // Source: focusExists
		        ItemDeltaItem<PrismPropertyValue<Boolean>> focusExistsSourceIdi = getFocusExistsIdi(context.getFocusContext());
		        Source<PrismPropertyValue<Boolean>> focusExistsSource
		        	= new Source<PrismPropertyValue<Boolean>>(focusExistsSourceIdi, ExpressionConstants.VAR_FOCUS_EXISTS);
		        mapping.addSource(focusExistsSource);

		        // Variable: focus
		        mapping.addVariableDefinition(ExpressionConstants.VAR_FOCUS, context.getFocusContext().getObjectDeltaObject());

		        // Variable: user (for convenience, same as "focus")
		        mapping.addVariableDefinition(ExpressionConstants.VAR_USER, context.getFocusContext().getObjectDeltaObject());

		        mapping.addVariableDefinition(ExpressionConstants.VAR_RESOURCE, accCtx.getResource());

				// Target
		        PrismObjectDefinition<ShadowType> shadowDefinition =
		            	prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class);
                PrismPropertyDefinition<T> shadowPropertyDefinition =
		            	shadowDefinition.findPropertyDefinition(projectionPropertyPath);
		        mapping.setDefaultTargetDefinition(shadowPropertyDefinition);

		        mapping.setOriginType(OriginType.OUTBOUND);
		        mapping.setOriginObject(accCtx.getResource());
			}

		};

        MutableBoolean strongMappingWasUsed = new MutableBoolean();

		PrismValueDeltaSetTriple<PrismPropertyValue<T>> outputTriple = mappingHelper.evaluateMappingSetProjection(
				outbound, desc + " outbound activation mapping in projection " + accCtxDesc,
        		now, initializer, shadowPropertyNew, shadowPropertyDelta, shadowNew, current, strongMappingWasUsed,
        		context, accCtx, task, result);

        LOGGER.trace("evaluateActivationMapping for {} after evaluateMappingSetProjection: accCtx.isFullShadow = {}, accCtx.isFresh = {}, shadowPropertyDelta = {}, shadowPropertyNew = {}, outputTriple = {}, strongMappingWasUsed = {}",
                new Object[] { desc, accCtx.isFullShadow(), accCtx.isFresh(), shadowPropertyDelta, shadowPropertyNew, outputTriple, strongMappingWasUsed});

        if (outputTriple == null) {
    		LOGGER.trace("Activation '{}' expression resulted in null triple for projection {}, skipping", desc, accCtxDesc);
            return null;
    	}

        PropertyDelta<T> projectionPropertyDelta = PropertyDelta.createDelta(projectionPropertyPath, ShadowType.class, prismContext);

        if (accCtx.isAdd()) {

        	Collection<PrismPropertyValue<T>> nonNegativeValues = outputTriple.getNonNegativeValues();
	        if (nonNegativeValues == null || nonNegativeValues.isEmpty()) {
	            LOGGER.trace("Activation '{}' expression resulted in null or empty value for projection {}, skipping", desc, accCtxDesc);
	            return null;
	        }
	        projectionPropertyDelta.setValuesToReplace(PrismValue.cloneCollection(nonNegativeValues));

        } else {

            // if we have fresh information (full shadow) AND the mapping used to derive the information was strong,
            // we will consider all values (zero & plus sets) -- otherwise, we take only the "plus" (i.e. changed) set

            // the first case is necessary, because in some situations (e.g. when mapping is changed)
            // the evaluator sees no differences w.r.t. real state, even if there is a difference
            // - and we must have a way to push new information onto the resource

            Collection<PrismPropertyValue<T>> valuesToReplace;

            if (accCtx.isFullShadow() && strongMappingWasUsed.isTrue()) {
                valuesToReplace = outputTriple.getNonNegativeValues();
            } else {
                valuesToReplace = outputTriple.getPlusSet();
            }

        	if (valuesToReplace != null && !valuesToReplace.isEmpty()) {

                // if what we want to set is the same as is already in the shadow, we skip that
                // (we insist on having full shadow, to be sure we work with current data)

                if (accCtx.isFullShadow() && accCtx.isFresh() && shadowPropertyNew != null) {
                    Set<T> realValuesPresent = new HashSet<T>(shadowPropertyNew.getRealValues());
                    Set<T> realValuesComputed = PrismValue.getRealValuesOfCollection(valuesToReplace);
                    if (realValuesPresent.equals(realValuesComputed)) {
                        LOGGER.trace("Activation '{}' expression resulted in existing values for projection {}, skipping creation of a delta", desc, accCtxDesc);
                        return null;
                    }
                }
        		projectionPropertyDelta.setValuesToReplace(PrismValue.cloneCollection(valuesToReplace));
        	}

        }

        if (projectionPropertyDelta.isEmpty()) {
        	return null;
        }

        LOGGER.trace("Adding new '{}' delta for account {}: {}", new Object[]{desc, accCtxDesc, projectionPropertyDelta});
        accCtx.swallowToSecondaryDelta(projectionPropertyDelta);

        return projectionPropertyDelta;
    }

	private ItemDeltaItem<PrismPropertyValue<Boolean>> getLegalIdi(LensProjectionContext accCtx) throws SchemaException {
		Boolean legal = accCtx.isLegal();
		Boolean legalOld = accCtx.isLegalOld();

		PrismPropertyDefinition<Boolean> legalDef = new PrismPropertyDefinition<Boolean>(LEGAL_PROPERTY_NAME,
        		DOMUtil.XSD_BOOLEAN, prismContext);
		legalDef.setMinOccurs(1);
		legalDef.setMaxOccurs(1);
		PrismProperty<Boolean> legalProp = legalDef.instantiate();
		legalProp.add(new PrismPropertyValue<Boolean>(legal));

		if (legal == legalOld) {
			return new ItemDeltaItem<PrismPropertyValue<Boolean>>(legalProp);
		} else {
			PrismProperty<Boolean> legalPropOld = legalProp.clone();
			legalPropOld.setRealValue(legalOld);
			PropertyDelta<Boolean> legalDelta = legalPropOld.createDelta();
			legalDelta.setValuesToReplace(new PrismPropertyValue<Boolean>(legal));
			return new ItemDeltaItem<PrismPropertyValue<Boolean>>(legalPropOld, legalDelta, legalProp);
		}
	}

	private <F extends ObjectType> ItemDeltaItem<PrismPropertyValue<Boolean>> getFocusExistsIdi(
			LensFocusContext<F> lensFocusContext) throws SchemaException {
		Boolean existsOld = null;
		Boolean existsNew = null;

		if (lensFocusContext != null) {
			if (lensFocusContext.isDelete()) {
				existsOld = true;
				existsNew = false;
			} else if (lensFocusContext.isAdd()) {
				existsOld = false;
				existsNew = true;
			} else {
				existsOld = true;
				existsNew = true;
			}
		}

		PrismPropertyDefinition<Boolean> existsDef = new PrismPropertyDefinition<Boolean>(FOCUS_EXISTS_PROPERTY_NAME,
				DOMUtil.XSD_BOOLEAN, prismContext);
		existsDef.setMinOccurs(1);
		existsDef.setMaxOccurs(1);
		PrismProperty<Boolean> existsProp = existsDef.instantiate();

		existsProp.add(new PrismPropertyValue<Boolean>(existsNew));

		if (existsOld == existsNew) {
			return new ItemDeltaItem<PrismPropertyValue<Boolean>>(existsProp);
		} else {
			PrismProperty<Boolean> existsPropOld = existsProp.clone();
			existsPropOld.setRealValue(existsOld);
			PropertyDelta<Boolean> existsDelta = existsPropOld.createDelta();
			existsDelta.setValuesToReplace(new PrismPropertyValue<Boolean>(existsNew));
			return new ItemDeltaItem<PrismPropertyValue<Boolean>>(existsPropOld, existsDelta, existsProp);
		}
	}

	private PrismObjectDefinition<UserType> getUserDefinition() {
		if (userDefinition == null) {
			userDefinition = prismContext.getSchemaRegistry()
				.findObjectDefinitionByCompileTimeClass(UserType.class);
		}
		return userDefinition;
	}

	private PrismContainerDefinition<ActivationType> getActivationDefinition() {
		if (activationDefinition == null) {
			PrismObjectDefinition<UserType> userDefinition = getUserDefinition();
			activationDefinition = userDefinition.findContainerDefinition(UserType.F_ACTIVATION);
		}
		return activationDefinition;
	}
}


text:
//-----------------------------------------------------------------------
// <copyright file="SerializationOptions.cs" company="Marimer LLC">
//     Copyright (c) Marimer LLC. All rights reserved.
//     Website: https://cslanet.com
// </copyright>
// <summary>Use this type to configure the settings for serialization.</summary>
//-----------------------------------------------------------------------
using System;
using Csla.Serialization.Mobile;

namespace Csla.Configuration
{
  /// <summary>
  /// Use this type to configure the settings for serialization.
  /// </summary>
  public class SerializationOptions
  {
    /// <summary>
    /// Sets the serialization formatter type used by CSLA .NET
    /// for all explicit object serialization (such as cloning,
    /// n-level undo, etc). Default is MobileFormatter.
    /// </summary>
    /// <param name="formatterType">Serialization formatter type.</param>
    public SerializationOptions SerializationFormatter(Type formatterType)
    {
      ApplicationContext.SerializationFormatter = formatterType;
      return this;
    }

    /// <summary>
    /// Sets type of the writer that is used to write data to
    /// serialization stream in SerializationFormatterFactory.GetFormatter().
    /// </summary>
    public SerializationOptions MobileWriter<T>() where T : ICslaWriter
    {
      CslaReaderWriterFactory.WriterType = typeof(T);
      return this;
    }

    /// <summary>
    /// Sets type of the writer that is used to read data to
    /// serialization stream in SerializationFormatterFactory.GetFormatter().
    /// </summary>
    public SerializationOptions MobileReader<T>() where T : ICslaReader
    {
      CslaReaderWriterFactory.ReaderType = typeof(T);
      return this;
    }
  }
}


text:
FOUNDATION_EXPORT double RxSwiftValidatorVersionNumber;

//! Project version string for RxSwiftValidator.
FOUNDATION_EXPORT const unsigned char RxSwiftValidatorVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <RxSwiftValidator/PublicHeader.h>


text:
var BaseRecipeCategory = (function () {
    function BaseRecipeCategory(name, foodGroups) {
        this.foodGroups = [];
        this.name = name;
        this.foodGroups = foodGroups;
    }
    return BaseRecipeCategory;
}());
//# sourceMappingURL=baseRecipeCategory.js.map


text:
package com.emc.storageos.model.file;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * This Class represents a return type that returns the id, name and self link
 * for a list of schedule policies.
 *
 * @author prasaa9
 *
 */
@XmlRootElement(name = "file_schedule_policies")
public class FilePolicyList {

    // List of schedule policies
    private List<FilePolicyRestRep> filePolicies;

    @XmlElement(name = "file_policy")
    public List<FilePolicyRestRep> getFilePolicies() {
        return filePolicies;
    }

    public void setFilePolicies(List<FilePolicyRestRep> filePolicies) {
        this.filePolicies = filePolicies;
    }

}


text:
package com.foc.business.photoAlbum;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Date;

import com.foc.Globals;
import com.foc.admin.DocRightsGroup;
import com.foc.admin.DocRightsGroupUsers;
import com.foc.admin.DocRightsGroupUsersDesc;
import com.foc.admin.FocUser;
import com.foc.desc.FocConstructor;
import com.foc.desc.FocObject;
import com.foc.list.FocList;
import com.foc.util.ASCII;
import com.vaadin.server.DownloadStream;
import com.vaadin.server.FileResource;

@SuppressWarnings("serial")
public class PhotoAlbum extends FocObject{

	public PhotoAlbum(FocConstructor constr){
    super(constr);
    newFocProperties();
  }

	@Override
	public void dispose() {
		super.dispose();
	}

  /*public void setImage(InputStream inputStream){
  	Globals.getApp().getDataSource().focObject_addBlobFromInputStream(this, PhotoAlbumDesc.FLD_IMAGE, inputStream);
  }

  public InputStream getImage(){
  	return Globals.getApp().getDataSource().focObject_LoadInputStream(this, PhotoAlbumDesc.FLD_IMAGE);
  }*/

  public void setImageCloud(InputStream inputStream, String directoryName, boolean createDirIfNeeded, String fileName){
  	setPropertyCloudStorage(PhotoAlbumDesc.FLD_IMAGE, inputStream, directoryName, createDirIfNeeded, fileName);
  }

  public InputStream getImageCloud(){
  	return getPropertyCloudStorage(PhotoAlbumDesc.FLD_IMAGE);
  }

  public void setImageName(String imageName){
    setPropertyString(PhotoAlbumDesc.FLD_IMAGE_NAME, imageName);
  }

  public String getImageName(){
    return getPropertyString(PhotoAlbumDesc.FLD_IMAGE_NAME);
  }

  public void setTableName(String tableName){
    setPropertyString(PhotoAlbumDesc.FLD_TABLE_NAME, tableName);
  }

  public String getAllowedGroups(){
    return getPropertyString(PhotoAlbumDesc.FLD_ALLOWED_GROUPS);
  }

  public void setAllowedGroups(String allowedGroups){
    setPropertyString(PhotoAlbumDesc.FLD_ALLOWED_GROUPS, allowedGroups);
  }

  public String getURLKey(){
    return getPropertyString(PhotoAlbumDesc.FLD_URL_KEY);
  }

  public void setURLKey(String allowedGroups){
    setPropertyString(PhotoAlbumDesc.FLD_URL_KEY, allowedGroups);
  }

  public String getTableName(){
    return getPropertyString(PhotoAlbumDesc.FLD_TABLE_NAME);
  }

  public void setObjectRef(long objectRef){
    setPropertyLong(PhotoAlbumDesc.FLD_OBJECT_REF, objectRef);
  }

  public long getObjectRef(){
    return getPropertyLong(PhotoAlbumDesc.FLD_OBJECT_REF);
  }

  public void setUploadDate(Date uploadDate){
    setPropertyDate(PhotoAlbumDesc.FLD_UPLOAD_DATE, uploadDate);
  }

  public Date getUploadDate(){
    return getPropertyDate(PhotoAlbumDesc.FLD_UPLOAD_DATE);
  }

  public void setDescription(String description){
    setPropertyString(PhotoAlbumDesc.FLD_DESCRIPTION, description);
  }

  public String getDescription(){
    return getPropertyString(PhotoAlbumDesc.FLD_DESCRIPTION);
  }

  public FocList getPhotoAlbumAccessList(){
  	return getPropertyList(PhotoAlbumDesc.FLD_PHOTO_ALBUM_ACCESS_LIST);
  }

  public void setTransactionCode(String transactionCode){
    setPropertyString(PhotoAlbumDesc.FLD_TRANSACTION_CODE, transactionCode);
  }

  public String getTransactionCode(){
    return getPropertyString(PhotoAlbumDesc.FLD_TRANSACTION_CODE);
  }

  public FocUser getCreationUser(){
  	return (FocUser) getPropertyObject(PhotoAlbumDesc.FLD_CREATION_USER);
  }

	public void setCreationUser(FocUser user){
  	setPropertyObject(PhotoAlbumDesc.FLD_CREATION_USER, user);
  }

	public DocumentType getDocumentType(){
  	return (DocumentType) getPropertyObject(PhotoAlbumDesc.FLD_DOCUMENT_TYPE);
  }

	public void setDocumentType(DocumentType documentType){
  	setPropertyObject(PhotoAlbumDesc.FLD_DOCUMENT_TYPE, documentType);
  }

	public int getKeyWord(){
		return  getPropertyMultiChoice(PhotoAlbumDesc.FLD_KEYWORD);
	}

	public void setKeyWord(int keyWord){
		setPropertyMultiChoice(PhotoAlbumDesc.FLD_KEYWORD, keyWord);
	}

	public String getSection(){
		    return getPropertyString(PhotoAlbumDesc.FLD_SECTION);
	}

	public void setSection(String section){
		    setPropertyString(PhotoAlbumDesc.FLD_SECTION, section);
	}

	public Boolean isVersioned(){
	    return getPropertyBoolean(PhotoAlbumDesc.FLD_VERSIONED);
	}

	public void setVersioned(Boolean versioned){
		setPropertyBoolean(PhotoAlbumDesc.FLD_VERSIONED, versioned);
	}

	public void setVersionDate(Date versionDate){
	    setPropertyDate(PhotoAlbumDesc.FLD_VERSION_DATE_TIME, versionDate);
    }

    public Date getVersionDate(){
    	return getPropertyDate(PhotoAlbumDesc.FLD_VERSION_DATE_TIME);
    }

    public long getFileSize(){
  		return getPropertyLong(PhotoAlbumDesc.FLD_FILE_SIZE);
  	}

  	public void setFileSize(long fileSize){
  		setPropertyLong(PhotoAlbumDesc.FLD_FILE_SIZE, fileSize);
  	}

	public int hasAccess(){
		FocUser currentUser = Globals.getApp().getUser_ForThisSession();
		return hasAccess(currentUser);
	}

	public int hasAccess(FocUser currentUser){
		int include = PhotoAlbumAccessDesc.READ_ONLY;
		if(Globals.getApp() != null && currentUser != null){
			FocList photoAlbumAccessList = getPhotoAlbumAccessList();
			photoAlbumAccessList.loadIfNotLoadedFromDB();

			if(photoAlbumAccessList.size() == 0){
				include = PhotoAlbumAccessDesc.READ_WRITE;
			}else{
			  for(int t=0; t<photoAlbumAccessList.size() && (include == PhotoAlbumAccessDesc.READ_ONLY); t++){
			  	PhotoAlbumAccess access = (PhotoAlbumAccess) photoAlbumAccessList.getFocObject(t);
			  	DocRightsGroup group = access.getDocRightsGroup();
			  	if(group != null){
			  		FocList userList = group.getDocRightsGroupUsersList();
			  		DocRightsGroupUsers rightUser = (DocRightsGroupUsers) userList.searchByPropertyObjectReference(DocRightsGroupUsersDesc.FLD_USER, currentUser.getReferenceInt());
			  		include = rightUser != null ? PhotoAlbumAccessDesc.READ_WRITE : PhotoAlbumAccessDesc.READ_ONLY;
			  	}
			  }
			}

			if(include == PhotoAlbumAccessDesc.READ_WRITE && getDocumentType() != null){
				include = getDocumentType().hasAccess();
			}
		}
		return include;
	}

	public boolean isEditable(){
		boolean enabled = false;
		if(Globals.getApp() != null && Globals.getApp().getUser_ForThisSession() != null){
			if(getCreationUser() != null && getCreationUser().equalsRef(Globals.getApp().getUser_ForThisSession())){
				enabled = true;
			}else{
				enabled = hasAccess() == PhotoAlbumAccessDesc.READ_WRITE ? true : false;
			}
		}
		return enabled;
	}

//	public boolean hasAccess(){
//		FocUser currentUser = Globals.getApp().getUser_ForThisSession();
//		return hasAccess(currentUser);
//	}
//
//	public boolean hasAccess(FocUser currentUser){
//		boolean include = false;
//		if(Globals.getApp() != null && currentUser != null){
//			FocList photoAlbumAccessList = getPhotoAlbumAccessList();
//			photoAlbumAccessList.loadIfNotLoadedFromDB();
//
//			if(photoAlbumAccessList.size() == 0){
//				include = true;
//			}else{
//			  for(int t=0; t<photoAlbumAccessList.size() && !include; t++){
//			  	PhotoAlbumAccess access = (PhotoAlbumAccess) photoAlbumAccessList.getFocObject(t);
//			  	DocRightsGroup group = access.getDocRightsGroup();
//			  	if(group != null){
//			  		FocList userList = group.getDocRightsGroupUsersList();
//			  		DocRightsGroupUsers rightUser = (DocRightsGroupUsers) userList.searchByPropertyObjectReference(DocRightsGroupUsersDesc.FLD_USER, currentUser.getReferenceInt());
//			  		include = rightUser != null;
//			  	}
//			  }
//			}
//
//			if(include && getDocumentType() != null){
//				include = getDocumentType().hasAccess();
//			}
//		}
//		return include;
//	}

	public class PhotoAlbumFileResource extends FileResource{

    private ByteArrayInputStream bais   = null;
    private PhotoAlbum           album  = null;

    public PhotoAlbumFileResource(File sourceFile, PhotoAlbum album){
    	super(sourceFile);
    	this.album = album;
    }

    public void dispose(){
    	if(bais != null){
    		try{
					bais.close();
				}catch (IOException e){
					Globals.logException(e);
				}
    		bais =  null;
    	}
    }

    @Override
    public DownloadStream getStream() {
      DownloadStream downloadStream = null;
      if(album.getImageCloud() instanceof FileInputStream){
      	InputStream inputStream = album.getImageCloud();
	      try{
		      ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		      int byt = 0;
		      while((byt = inputStream.read()) != -1){
		      	byteArrayOutputStream.write(byt);
		      }
		      inputStream.close();
		      bais = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
	      }catch(Exception ex){
	      	ex.printStackTrace();
	      }
      }else{
      	bais = (ByteArrayInputStream) album.getImageCloud();
      }
      if(bais != null){
      	String fileName = album.getImageName();
        downloadStream = new DownloadStream(bais, "application/x-unknown", fileName);
        downloadStream.setParameter("Content-Disposition", "attachment; filename=" + fileName);
        downloadStream.setCacheTime(0);
      }
      return downloadStream;
    }
  }

	public void fillURLKey(){
  	String randomKeyStringForURL = ASCII.generateRandomString(6, true, true).trim();
  	setURLKey(randomKeyStringForURL);
	}
}


text:
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<script type="text/javascript">
//    基类 人
var Person = function(name, age){
	this.name = name;
	this.age = age;
}
Person.prototype = {
	say : function(){
		console.log('Hello Everyone!');
	}
}

//儿子 学生类  继承自人
var Student = function(name, age, lesson){
	Person.call(this, name, age);
	this.lesson = lesson;
}
Student.prototype = new Person();
Student.prototype.getTeacher = function(){
	console.log("Mr Zhang");
}

//儿子 教师类  继承自人
var Teacher = function(name, age, subject){
	Person.call(this, name, age);
	this.subject = subject;
}
Teacher.prototype = new Person();
Teacher.prototype.getCollage = function(){
	console.log('网页平面')
}

//使用
var xiaoWang = new Student('wang', 20, 'javascript');
var xiaoLi = new Student('li', 30, 'javascript');
console.log(xiaoWang.name);
console.log(xiaoWang.age);
console.log(xiaoWang.lesson);
console.log(xiaoLi.name);
xiaoWang.say();
xiaoLi.say();
console.log(xiaoWang.say === xiaoLi.say);
console.log(xiaoWang.getTeacher === xiaoLi.getTeacher);

var xiaoMing = new Teacher('zhang', 25, 'javascript');
console.log(xiaoMing.name);
console.log(xiaoMing.age);
console.log(xiaoMing.subject);
xiaoMing.say();
console.log(xiaoMing.say === xiaoWang.say);
</script>
</body>
</html>


text:
using Microsoft.Xaml.Interactivity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;

namespace Okazuki.Interactivity
{
    public abstract class TargetedTriggerAction : TriggerAction
    {
        public static readonly DependencyProperty TargetObjectProperty =
            DependencyProperty.Register(
                "TargetObject",
                typeof(object),
                typeof(TargetedTriggerAction),
                new PropertyMetadata(null));

        public Type TargetType { get; private set; }

        public object TargetObject
        {
            get { return (object)GetValue(TargetObjectProperty); }
            set { SetValue(TargetObjectProperty, value); }
        }

        protected object Target
        {
            get
            {
                return this.TargetObject ?? this.AssociatedObject;
            }
        }

        public TargetedTriggerAction(Type targetType) : base(typeof(DependencyObject))
        {
            this.TargetType = targetType;
        }

    }
}


text:
A pure JavaScript implemetation of MODBUS-RTU (and TCP) for NodeJS

[![npm](https://img.shields.io/npm/v/npm.svg)](https://www.npmjs.com/package/modbus-serial)

This class makes ModbusRTU (and TCP) calls fun and easy.

Modbus is a serial communications protocol, first used in 1979.
Modbus is simple and robust, openly published, royalty-free and
easy to deploy and maintain.

----

- [Install](#install)
- [What can I do with this module ?](#what-can-i-do-with-this-module-)
- [Compatibility](#compatibility)
- [Examples](#examples)
- [Methods](#methods)
      - [API Promises](#api-promises)
      - [API Callbacks](#api-callbacks)
      - [API connection shorthand](#api-connection-shorthand)

----

#### Install

```
npm install modbus-serial
```

For use over serial port (ModbusRTU), also install node-serialport:
```
npm install serialport
```

#### What can I do with this module ?

This class makes it fun and easy to communicate with electronic
devices such as irrigation controllers, protocol droids and robots.
It talks with devices that use a serial line (e.g. RS485, RS232).
Many industrial electronic devices implement modbus.
Arduino can also talk modbus and you can control your projects and robots
using modbus.

Arduino libraries for modbus slave:
* https://github.com/yaacov/arduino-modbus-slave
* https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino

Arduino sketch for irrigation timer with modbus support:
* https://github.com/yaacov/arduino-irrigation-timer

Node Modbus-WebSocket bridge:
* https://github.com/yaacov/node-modbus-ws

#### Compatibility

###### This class implements:

* FC1 "Read Coil Status"
* FC2 "Read Input Status"
* FC3 "Read Holding Registers"
* FC4 "Read Input Registers"
* FC5 "Force Single Coil"
* FC6 "Preset Single Register"
* FC15 "Force Multiple Coil"
* FC16 "Preset Multiple Registers"

###### Connects types:

* modbus-RTU (modbus-rtu): Over serial line [require node serialport].
* modbus-ASCII (modbus-ascii): Over serial line [require node serialport].
* modbus-TCP (modbus-tcp): Over TCP/IP line.
* modbus-RTU (telnet): Over Telnet server, TCP/IP serial bridge.
* modbus-RTU (buffered): Over buffered serial line [require node serialport].
* modbus-RTU (C701): Over C701 server, commercial UDP to serial bridge.

#### Examples
----
###### Logger
``` javascript
// create an empty modbus client
var ModbusRTU = require("modbus-serial");
var client = new ModbusRTU();

// open connection to a tcp line
client.connectTCP("192.168.1.42", run);

// read the values of 10 registers starting at address 0
// on device number 1. and log the values to the console.
function run() {
    client.setID(1);

    client.readInputRegisters(0, 10)
        .then(console.log)
        .then(run);
}
```

----
###### Read and Write
``` javascript
// create an empty modbus client
var ModbusRTU = require("modbus-serial");
var client = new ModbusRTU();

// open connection to a serial port
client.connectRTU("/dev/ttyUSB0", {baudrate: 9600}, write);

function write() {
    client.setID(1);

    // write the values 0, 0xffff to registers starting at address 5
    // on device number 1.
    client.writeRegisters(5, [0 , 0xffff])
        .then(read);
}

function read() {
    // read the 2 registers starting at address 5
    // on device number 1.
    client.readHoldingRegisters(5, 2)
        .then(console.log);
}
```
----
###### Logger
``` javascript
// create an empty modbus client
var ModbusRTU = require("modbus-serial");
var client = new ModbusRTU();

// open connection to a serial port
client.connectRTU("/dev/ttyUSB0", {baudrate: 9600});
client.setID(1);

// read the values of 10 registers starting at address 0
// on device number 1. and log the values to the console.
setInterval(function() {
    client.readHoldingRegisters(0, 10, function(err, data) {
        console.log(data.data);
    });
}, 1000);
```
----
###### Logger-TCP
``` javascript
// create an empty modbus client
var ModbusRTU = require("modbus-serial");
var client = new ModbusRTU();

// open connection to a tcp line
client.connectTCP("192.168.1.42");
client.setID(1);

// read the values of 10 registers starting at address 0
// on device number 1. and log the values to the console.
setInterval(function() {
    client.readHoldingRegisters(0, 10, function(err, data) {
        console.log(data.data);
    });
}, 1000);
```
----
###### Read raw buffer
``` javascript
// create an empty modbus client
var ModbusRTU = require("modbus-serial");
var client = new ModbusRTU();

// open connection to a serial port
client.connectRTU("/dev/ttyUSB0", {baudrate: 9600}, run);

function run() {
    client.setID(1);

    // read 2 16bit-registers to get one 32bit number
    client.readInputRegisters(5, 2, function(err, data) {
        var int32 = data.buffer.readUInt32BE();
        console.log(int32);
    });
}
```

#### Methods

----
###### API promises
----

This communication functions use a pre-set unit-id and can return a promise,
Using callbacks is optional.

```javascript
// set the client's unit id
client.setID(1);

// read 8 discrete inputs starting at input 10
// (function use the unit id 1, we set earlier)
client.readDiscreteInputs(10, 8)
    .then(function(data) {
        console.log(data);
    });
```

----
##### .setID(id)
      Sets the unit id

*id {number}:*
The new client id

----
##### .readCoils (address, length)
      Writes "Read Coils" (FC=1) request to serial port.

*address {number}:*
The Data Address of the first register.

*length {number}:*
The total number of registers requested.

----
##### .readDiscreteInputs (address, length)
      Writes "Read Discrete Inputs" (FC=2) request to serial port.

*address {number}:*
The Data Address of the first register.

*length {number}:*
The total number of registers requested.

----
##### .readHoldingRegisters (address, length)
      Writes "Read Holding Registers" (FC=3) request to serial port.

*address {number}:*
The Data Address of the first register.

*length {number}:*
The total number of registers requested.

----
##### .readInputRegisters (address, length)
      Writes "Read Input Registers" (FC=4) request to serial port.

*address {number}:*
The Data Address of the first register.

*length {number}:*
The total number of registers requested.

----
##### .writeCoil(address, state)
      Writes "Force Coil Status" (FC=5) request to serial port.

*address {number}:*
The Data Address of the first register.

*state {boolean}:*
The state to force into coil.

----
##### .writeCoils(address, array)
      Writes "Force Multiple Coils" (FC=15) request to serial port.

*address {number}:*
The Data Address of the first register.

*array {array}:*
The array of states to force into the coils.

----
##### .writeRegisters (address, array)
      Writes "Preset Multiple Registers" (FC=16) request to serial port.

*address {number}:*
The Data Address of the first register.

*array {array}:*
The array of values to set into the registers.

----

----
##### .writeRegister (address, value)
      Writes "Preset Single Register" (FC=6) request to serial port.

*address {number}:*
The Data Address of the first register.

*value {number}:*
The value to set into the register.

----
###### API Callbacks
----

This communication functions use callbacks.

```javascript

// read 8 holding registers starting at register 10
// (function use the unit id 1)
client.writeFC3(1, 10, 8, function(err, data) {
      if (err) {
            console.log(err);
      } else {
            console.log(data);
      });
```

----
##### .open(callback)
      Opens a modbus connection using the given serial port.

*callback {function}:* (optional)
Called when a connection has been opened.

----
##### .writeFC1 (unit, address, length, callback)
      Writes "Read coil status" (FC=01) request to serial port.

*unit {number}:*
The slave unit address.

*address {number}:*
The Data Address of the first register.

*length {number}:*
The total number of registers requested.

*callback {function}:* (optional)
Called once the unit returns an answer. The callback should be a function
that looks like: function (error, data) { ... }
```
error - null on success, error string o/w
data - an object with two fildes:
    data.data: array of boolean coils (in multiples of 8 = one byte).
    data.buffer: raw baffer of bytes returned by slave.
```

----
##### .writeFC2 (unit, address, length, callback)
      Writes "Read input status" (FC=02) request to serial port.

*unit {number}:*
The slave unit address.

*address {number}:*
The Data Address of the first register.

*length {number}:*
The total number of registers requested.

*callback {function}:* (optional)
Called once the unit returns an answer. The callback should be a function
that looks like: function (error, data) { ... }
```
error - null on success, error string o/w
data - an object with two fildes:
    data.data: array of boolean digital inputs (in multiples of 8 = one byte).
    data.buffer: raw baffer of bytes returned by slave.
```

----
##### .writeFC3 (unit, address, length, callback)
      Writes "Read Holding Registers" (FC=03) request to serial port.

*unit {number}:*
The slave unit address.

*address {number}:*
The Data Address of the first register.

*length {number}:*
The total number of registers requested.

*callback {function}:* (optional)
Called once the unit returns an answer. The callback should be a function
that looks like: function (error, data) { ... }
```
error - null on success, error string o/w
data - an object with two fildes:
    data.data: array of unsinged 16 bit registers.
    data.buffer: raw baffer of bytes returned by slave.
```

----
##### .writeFC4 (unit, address, length, callback)
      Writes "Read Input Registers" (FC=04) request to serial port.

*unit {number}:*
The slave unit address.

*address {number}:*
The Data Address of the first register.

*length {number}:*
The total number of registers requested.

*callback {function}:* (optional)
Called once the unit returns an answer. The callback should be a function
that looks like: function (error, data) { ... }
```
error - null on success, error string o/w
data - an object with two fildes:
    data.data: array of unsinged 16 bit registers.
    data.buffer: raw baffer of bytes returned by slave.
```

----
##### .writeFC5 (unit, address, state, callback)
      Writes "Force Single Coil" (FC=05) request to serial port.

*unit {number}:*
The slave unit address.

*address {number}:*
The Data Address of the first register.

*state {boolean}:*
The coil state.

*callback {function}:* (optional)
Called once the unit returns an answer. The callback should be a function
that looks like: function (error, data) { ... }

----
##### .writeFC15 (unit, address, array, callback)
      Writes "Force Multiple Coils" (FC=15) request to serial port.

*unit {number}:*
The slave unit address.

*address {number}:*
The Data Address of the first register.

*array {array}:*
The array of states to send to unit.

*callback {function}:* (optional)
Called once the unit returns an answer. The callback should be a function
that looks like: function (error, data) { ... }

----
##### .writeFC6 (unit, address, value, callback)
      Writes "Preset Single Register" (FC=6) request to serial port.

*unit {number}:*
The slave unit address.

*address {number}:*
The Data Address of the first register.

*value {number}:*
The value to sent to unit.

*callback {function}:* (optional)
Called once the unit returns an answer. The callback should be a function
that looks like: function (error, data) { ... }

----
##### .writeFC16 (unit, address, array, callback)
      Writes "Preset Multiple Registers" (FC=16) request to serial port.

*unit {number}:*
The slave unit address.

*address {number}:*
The Data Address of the first register.

*array {array}:*
The array of values to sent to unit.

*callback {function}:* (optional)
Called once the unit returns an answer. The callback should be a function
that looks like: function (error, data) { ... }

----
###### API connection shorthand
----

The shorthand connection functions creates a port and open it.

Long way, without shorthand:
``` javascript
// open a serial port
var SerialPort = require("serialport").SerialPort;
var serialPort = new SerialPort("/dev/ttyUSB0", {baudrate: 9600});

// create a modbus client using the serial port
var ModbusRTU = require("modbus-serial");
var client = new ModbusRTU(serialPort);

// open connection to a serial port
client.open();

// tell your coffee machine to do something ...
```

Using shorthand:
``` javascript
// create an empty modbus client
var ModbusRTU = require("modbus-serial");
var client = new ModbusRTU();

// open connection to a serial port
client.connectRTU("/dev/ttyUSB0", {baudrate: 9600});

// tell your robot to do something ...
```

Using shorthand (TCP):
``` javascript
// create an empty modbus client
var ModbusRTU = require("modbus-serial");
var client = new ModbusRTU();

// open connection to a tcp line
client.connectTCP("192.168.1.42");

// tell your robot to do something ...
```
----
##### .connectRTU (path, options, callback)
      Connect using serial port.

*path {string}:*
The port path (e.g. "/dev/ttyS0")

*options {object}:* (optional)
The options for this connection.

*callback {function}:* (optional)
Called once the client is connected.

----
##### .connectRTUBuffered (path, options, callback)
      Connect using buffered serial port.
      Use when serial port has long delays inside packets.

*path {string}:*
The port path (e.g. "/dev/ttyS0")

*options {object}:* (optional)
The options for this connection.

*callback {function}:* (optional)
Called once the client is connected.

----
##### .connectTCP (ip, options, callback)
      Connect using tcp/ip.

*ip {string}:*
The port ip (e.g. "24.230.1.42")

*options {object}:* (optional)
The options for this connection.

*callback {function}:* (optional)
Called once the client is connected.

----
##### .connectTelnet (ip, options, callback)
      Connect using a telnet server

*ip {string}:*
The port ip (e.g. "24.230.1.42")

*options {object}:* (optional)
The options for this connection.

*callback {function}:* (optional)
Called once the client is connected.

----
##### .connectAsciiSerial (path, options, callback)
      Connect using serial port with ASCII encoding.

*path {string}:*
The port path (e.g. "/dev/ttyS0")

*options {object}:* (optional)
The options for this connection.

*callback {function}:* (optional)
Called once the client is connected.