text:
package org.codehaus.mojo.versions.api;

import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.Restriction;
import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.mojo.versions.ordering.VersionComparator;

import static org.apache.commons.lang3.StringUtils.compare;

/**
 * Holds the results of a search for versions of an artifact.
 *
 * @author Stephen Connolly
 * @since 1.0-alpha-3
 */
public class ArtifactVersions
    extends AbstractVersionDetails implements Comparable<ArtifactVersions>
{
    /**
     * The artifact that who's versions we hold details of.
     *
     * @since 1.0-alpha-3
     */
    private final Artifact artifact;

    /**
     * The available versions.
     *
     * @since 1.0-alpha-3
     */
    private final SortedSet<ArtifactVersion> versions;

    /**
     * The version comparison rule that is used for this artifact.
     *
     * @since 1.0-alpha-3
     */
    private final VersionComparator versionComparator;

    /**
     * Creates a new {@link ArtifactVersions} instance.
     *
     * @param artifact The artifact.
     * @param versions The versions.
     * @param versionComparator The version comparison rule.
     * @since 1.0-alpha-3
     */
    public ArtifactVersions( Artifact artifact, List<ArtifactVersion> versions, VersionComparator versionComparator )
    {
        this.artifact = artifact;
        this.versionComparator = versionComparator;
        this.versions = new TreeSet<>( versionComparator );
        this.versions.addAll( versions );
        if ( artifact.getVersion() != null )
        {
            setCurrentVersion( artifact.getVersion() );
        }
    }

    /**
     * Creates a new {@link ArtifactVersions} instance as shallow copy of the other
     *
     * @param other other object to be linked to
     * @since 2.13.0
     */
    public ArtifactVersions( ArtifactVersions other )
    {
        artifact = other.artifact;
        versionComparator = other.versionComparator;
        versions = other.versions;
        setCurrentVersion( other.getCurrentVersion() );
        setIncludeSnapshots( other.isIncludeSnapshots() );
    }

    @SuppressWarnings( "checkstyle:InnerAssignment" )
    public int compareTo( ArtifactVersions that )
    {
        int rv;
        return this == that
                ? 0
                : that == null || getClass() != that.getClass()
                    ? 1
                    : ( rv = compare( getGroupId(), that.getGroupId() ) ) != 0
                        ? rv
                        : ( rv = compare( getArtifactId(), that.getArtifactId() ) ) != 0
                            ? rv
                            : compare( getVersion(), that.getVersion() );
    }

    @Override
    public boolean equals( Object o )
    {
        if ( this == o )
        {
            return true;
        }

        if ( !( o instanceof ArtifactVersions ) )
        {
            return false;
        }

        ArtifactVersions that = (ArtifactVersions) o;

        return new EqualsBuilder()
                .append( getArtifact(), that.getArtifact() )
                .append( getVersions(), that.getVersions() )
                .append( getVersionComparator(), that.getVersionComparator() )
                .isEquals();
    }

    @Override
    public int hashCode()
    {
        return new HashCodeBuilder( 17, 37 )
                .append( getArtifact() )
                .append( getVersions() )
                .append( getVersionComparator() )
                .toHashCode();
    }

    /**
     * Checks if the version is in the range (and ensures that the range respects the -! syntax to rule out
     * any qualifiers from range boundaries).
     *
     * @param version the version to check.
     * @param range the range to check.
     * @return true if and only if the version is in the range.
     * @since 1.3
     */
    public static boolean isVersionInRange( ArtifactVersion version, VersionRange range )
    {
        if ( !range.containsVersion( version ) )
        {
            return false;
        }

        for ( Restriction r : range.getRestrictions() )
        {
            if ( r.containsVersion( version ) )
            {
                // check for the -! syntax
                if ( !r.isLowerBoundInclusive() && r.getLowerBound() != null )
                {
                    String s = r.getLowerBound().toString();
                    if ( s.endsWith( "-!" ) && version.toString().startsWith( s.substring( 0, s.length() - 2 ) ) )
                    {
                        return false;
                    }
                }
                if ( !r.isUpperBoundInclusive() && r.getUpperBound() != null )
                {
                    String s = r.getUpperBound().toString();
                    if ( s.endsWith( "-!" ) && version.toString().startsWith( s.substring( 0, s.length() - 2 ) ) )
                    {
                        return false;
                    }
                }
            }
        }
        return true;
    }

    /**
     * Returns the artifact who's version information we are holding.
     *
     * @return the artifact who's version information we are holding.
     * @since 1.0-alpha-3
     */
    public Artifact getArtifact()
    {
        return artifact;
    }

    /**
     * Returns the groupId of the artifact which versions we are holding.
     *
     * @return the groupId.
     * @since 1.0-alpha-3
     */
    public String getGroupId()
    {
        return getArtifact().getGroupId();
    }

    /**
     * Returns the artifactId of the artifact which versions we are holding.
     *
     * @return the artifactId.
     * @since 1.0-alpha-3
     */
    public String getArtifactId()
    {
        return getArtifact().getArtifactId();
    }

    /**
     * Returns the artifactId of the artifact which versions we are holding.
     *
     * @return current version
     * @since 2.13.0
     */
    public String getVersion()
    {
        return getArtifact().getVersion();
    }

    public ArtifactVersion[] getVersions( boolean includeSnapshots )
    {
        return includeSnapshots
                ? versions.toArray( new ArtifactVersion[0] )
                : versions.stream().filter( v -> !ArtifactUtils.isSnapshot( v.toString() ) )
                .toArray( ArtifactVersion[]::new );
    }

    public VersionComparator getVersionComparator()
    {
        return versionComparator;
    }

    /**
     * {@inheritDoc}
     */
    public String toString()
    {
        return "ArtifactVersions" + "{artifact=" + artifact + ", versions=" + versions + ", versionComparator="
            + versionComparator + '}';
    }

}


text:
package com.brettonw.bag.expr;

import com.brettonw.bag.Bag;
import com.brettonw.bag.BagObject;

public class Not extends BooleanExpr {
    public static final String NOT = "not";

    private BooleanExpr left;

    public Not (BagObject expr) {
        left = (BooleanExpr) Exprs.get (expr.getObject (LEFT));
    }

    @Override
    Object evaluate (Bag bag) {
        return ! left.evaluateIsTrue (bag);
    }

    public static BagObject bag (BagObject left) {
        return bag (NOT, left);
    }
}

redpajama_set_name: RedPajamaGithub


text:
#pragma once
#include <aws/inspector/Inspector_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/inspector/model/Scope.h>
#include <aws/inspector/model/Attribute.h>
#include <utility>

namespace Aws
{
namespace Utils
{
namespace Json
{
  class JsonValue;
  class JsonView;
} // namespace Json
} // namespace Utils
namespace Inspector
{
namespace Model
{

  /**
   *
Contains information about what was excluded from an assessment
   * run.

See Also:
   AWS
   * API Reference

   */
  class AWS_INSPECTOR_API Exclusion
  {
  public:
    Exclusion();
    Exclusion(Aws::Utils::Json::JsonView jsonValue);
    Exclusion& operator=(Aws::Utils::Json::JsonView jsonValue);
    Aws::Utils::Json::JsonValue Jsonize() const;

    /**
     *
The ARN that specifies the exclusion.

     */
    inline const Aws::String& GetArn() const{ return m_arn; }

    /**
     *
The ARN that specifies the exclusion.

     */
    inline bool ArnHasBeenSet() const { return m_arnHasBeenSet; }

    /**
     *
The ARN that specifies the exclusion.

     */
    inline void SetArn(const Aws::String& value) { m_arnHasBeenSet = true; m_arn = value; }

    /**
     *
The ARN that specifies the exclusion.

     */
    inline void SetArn(Aws::String&& value) { m_arnHasBeenSet = true; m_arn = std::move(value); }

    /**
     *
The ARN that specifies the exclusion.

     */
    inline void SetArn(const char* value) { m_arnHasBeenSet = true; m_arn.assign(value); }

    /**
     *
The ARN that specifies the exclusion.

     */
    inline Exclusion& WithArn(const Aws::String& value) { SetArn(value); return *this;}

    /**
     *
The ARN that specifies the exclusion.

     */
    inline Exclusion& WithArn(Aws::String&& value) { SetArn(std::move(value)); return *this;}

    /**
     *
The ARN that specifies the exclusion.

     */
    inline Exclusion& WithArn(const char* value) { SetArn(value); return *this;}

    /**
     *
The name of the exclusion.

     */
    inline const Aws::String& GetTitle() const{ return m_title; }

    /**
     *
The name of the exclusion.

     */
    inline bool TitleHasBeenSet() const { return m_titleHasBeenSet; }

    /**
     *
The name of the exclusion.

     */
    inline void SetTitle(const Aws::String& value) { m_titleHasBeenSet = true; m_title = value; }

    /**
     *
The name of the exclusion.

     */
    inline void SetTitle(Aws::String&& value) { m_titleHasBeenSet = true; m_title = std::move(value); }

    /**
     *
The name of the exclusion.

     */
    inline void SetTitle(const char* value) { m_titleHasBeenSet = true; m_title.assign(value); }

    /**
     *
The name of the exclusion.

     */
    inline Exclusion& WithTitle(const Aws::String& value) { SetTitle(value); return *this;}

    /**
     *
The name of the exclusion.

     */
    inline Exclusion& WithTitle(Aws::String&& value) { SetTitle(std::move(value)); return *this;}

    /**
     *
The name of the exclusion.

     */
    inline Exclusion& WithTitle(const char* value) { SetTitle(value); return *this;}

    /**
     *
The description of the exclusion.

     */
    inline const Aws::String& GetDescription() const{ return m_description; }

    /**
     *
The description of the exclusion.

     */
    inline bool DescriptionHasBeenSet() const { return m_descriptionHasBeenSet; }

    /**
     *
The description of the exclusion.

     */
    inline void SetDescription(const Aws::String& value) { m_descriptionHasBeenSet = true; m_description = value; }

    /**
     *
The description of the exclusion.

     */
    inline void SetDescription(Aws::String&& value) { m_descriptionHasBeenSet = true; m_description = std::move(value); }

    /**
     *
The description of the exclusion.

     */
    inline void SetDescription(const char* value) { m_descriptionHasBeenSet = true; m_description.assign(value); }

    /**
     *
The description of the exclusion.

     */
    inline Exclusion& WithDescription(const Aws::String& value) { SetDescription(value); return *this;}

    /**
     *
The description of the exclusion.

     */
    inline Exclusion& WithDescription(Aws::String&& value) { SetDescription(std::move(value)); return *this;}

    /**
     *
The description of the exclusion.

     */
    inline Exclusion& WithDescription(const char* value) { SetDescription(value); return *this;}

    /**
     *
The recommendation for the exclusion.

     */
    inline const Aws::String& GetRecommendation() const{ return m_recommendation; }

    /**
     *
The recommendation for the exclusion.

     */
    inline bool RecommendationHasBeenSet() const { return m_recommendationHasBeenSet; }

    /**
     *
The recommendation for the exclusion.

     */
    inline void SetRecommendation(const Aws::String& value) { m_recommendationHasBeenSet = true; m_recommendation = value; }

    /**
     *
The recommendation for the exclusion.

     */
    inline void SetRecommendation(Aws::String&& value) { m_recommendationHasBeenSet = true; m_recommendation = std::move(value); }

    /**
     *
The recommendation for the exclusion.

     */
    inline void SetRecommendation(const char* value) { m_recommendationHasBeenSet = true; m_recommendation.assign(value); }

    /**
     *
The recommendation for the exclusion.

     */
    inline Exclusion& WithRecommendation(const Aws::String& value) { SetRecommendation(value); return *this;}

    /**
     *
The recommendation for the exclusion.

     */
    inline Exclusion& WithRecommendation(Aws::String&& value) { SetRecommendation(std::move(value)); return *this;}

    /**
     *
The recommendation for the exclusion.

     */
    inline Exclusion& WithRecommendation(const char* value) { SetRecommendation(value); return *this;}

    /**
     *
The AWS resources for which the exclusion pertains.

     */
    inline const Aws::Vector<Scope>& GetScopes() const{ return m_scopes; }

    /**
     *
The AWS resources for which the exclusion pertains.

     */
    inline bool ScopesHasBeenSet() const { return m_scopesHasBeenSet; }

    /**
     *
The AWS resources for which the exclusion pertains.

     */
    inline void SetScopes(const Aws::Vector<Scope>& value) { m_scopesHasBeenSet = true; m_scopes = value; }

    /**
     *
The AWS resources for which the exclusion pertains.

     */
    inline void SetScopes(Aws::Vector<Scope>&& value) { m_scopesHasBeenSet = true; m_scopes = std::move(value); }

    /**
     *
The AWS resources for which the exclusion pertains.

     */
    inline Exclusion& WithScopes(const Aws::Vector<Scope>& value) { SetScopes(value); return *this;}

    /**
     *
The AWS resources for which the exclusion pertains.

     */
    inline Exclusion& WithScopes(Aws::Vector<Scope>&& value) { SetScopes(std::move(value)); return *this;}

    /**
     *
The AWS resources for which the exclusion pertains.

     */
    inline Exclusion& AddScopes(const Scope& value) { m_scopesHasBeenSet = true; m_scopes.push_back(value); return *this; }

    /**
     *
The AWS resources for which the exclusion pertains.

     */
    inline Exclusion& AddScopes(Scope&& value) { m_scopesHasBeenSet = true; m_scopes.push_back(std::move(value)); return *this; }

    /**
     *
The system-defined attributes for the exclusion.

     */
    inline const Aws::Vector<Attribute>& GetAttributes() const{ return m_attributes; }

    /**
     *
The system-defined attributes for the exclusion.

     */
    inline bool AttributesHasBeenSet() const { return m_attributesHasBeenSet; }

    /**
     *
The system-defined attributes for the exclusion.

     */
    inline void SetAttributes(const Aws::Vector<Attribute>& value) { m_attributesHasBeenSet = true; m_attributes = value; }

    /**
     *
The system-defined attributes for the exclusion.

     */
    inline void SetAttributes(Aws::Vector<Attribute>&& value) { m_attributesHasBeenSet = true; m_attributes = std::move(value); }

    /**
     *
The system-defined attributes for the exclusion.

     */
    inline Exclusion& WithAttributes(const Aws::Vector<Attribute>& value) { SetAttributes(value); return *this;}

    /**
     *
The system-defined attributes for the exclusion.

     */
    inline Exclusion& WithAttributes(Aws::Vector<Attribute>&& value) { SetAttributes(std::move(value)); return *this;}

    /**
     *
The system-defined attributes for the exclusion.

     */
    inline Exclusion& AddAttributes(const Attribute& value) { m_attributesHasBeenSet = true; m_attributes.push_back(value); return *this; }

    /**
     *
The system-defined attributes for the exclusion.

     */
    inline Exclusion& AddAttributes(Attribute&& value) { m_attributesHasBeenSet = true; m_attributes.push_back(std::move(value)); return *this; }

  private:

    Aws::String m_arn;
    bool m_arnHasBeenSet = false;

    Aws::String m_title;
    bool m_titleHasBeenSet = false;

    Aws::String m_description;
    bool m_descriptionHasBeenSet = false;

    Aws::String m_recommendation;
    bool m_recommendationHasBeenSet = false;

    Aws::Vector<Scope> m_scopes;
    bool m_scopesHasBeenSet = false;

    Aws::Vector<Attribute> m_attributes;
    bool m_attributesHasBeenSet = false;
  };

} // namespace Model
} // namespace Inspector
} // namespace Aws


text:
import json
import collections
from ConfigParser import SafeConfigParser
import sys, os
import glob
from datetime import datetime
import csv

def convert(input):
    if isinstance(input, dict):
        return {convert(key): convert(value) for key, value in input.iteritems()}
    elif isinstance(input, list):
        return [convert(element) for element in input]
    elif isinstance(input, unicode):
        return input.encode('utf-8')
    else:
        return input

def to_ilan_csv(folder):
	# write the column headers
	csv_writer = csv.writer(out_file, quoting=csv.QUOTE_ALL)
	headers = ["tweet_id", "handle", "username", "tweet_text", "has_image", "image_url", "created_at", "retweets", "hashtags", "mentions", "isRT", "isMT"]
	csv_writer.writerow(headers)

	# open the JSON files we stored and parse them into the CSV file we're working on
	try:
		json_files = glob.glob(folder)
		print("Parsing %s files." % len(json_files))
		for file in json_files:
			try:
				f = open(file, 'r')
			except:
				print("Couldn't open JSON file for parsing.")
			try:
				for line in f:
					# hack to avoid the trailing \n at the end of the file - sitcking point LH 4/7/16
					if len(line) > 3:
						i = 0
						tweets = convert(json.loads(line))
						for tweet in tweets:
							has_media = False
							is_RT = False
							is_MT = False
							hashtags_list = []
							mentions_list = []
							media_list = []

							entities = tweet["entities"]
							# old tweets don't have key "media" so need a workaround
							if entities.has_key("media"):
								has_media = True
								for item in entities["media"]:
									media_list.append(item["media_url"])

							for hashtag in entities["hashtags"] :
								hashtags_list.append(hashtag["text"])

							for user in entities["user_mentions"]:
								mentions_list.append(user["screen_name"])

							if tweet["text"][:2] == "RT":
								is_RT = True

							if tweet["text"][:2] == "MT":
								is_MT = True

							values = [
								tweet["id_str"],
								tweet["user"]["id_str"],
								tweet["user"]["screen_name"],
								tweet["text"],
								has_media,
								','.join(media_list) if len(media_list) > 0 else "",
								datetime.strptime(tweet["created_at"], '%a %b %d %H:%M:%S +0000 %Y').strftime('%Y-%m-%d %H:%M:%S'),
								tweet["retweet_count"],
								','.join(hashtags_list) if len(hashtags_list) > 0 else "",
								','.join(mentions_list) if len(mentions_list) > 0 else "",
								is_RT,
								is_MT
							]
							csv_writer.writerow(values)
					else:
						continue
			except ValueError as err:
				print("%s in %s" % (err, file))
				continue
			f.close()

	except:
		print("Something went wrong. Quitting.")
		for i in sys.exc_info():
			print(i)

if __name__ == '__main__' :

	config = SafeConfigParser()
	script_dir = os.path.dirname(os.path.abspath(__file__))
	config_file = os.path.join(script_dir, '../settings.cfg')
	config.read(config_file)
	outfolder = config.get('files','outfolder')
	out_filename = config.get('files', 'parsed_file')

	glob_search = outfolder + "*.json"

	try: # try to open the file for writing
		out_file = open(out_filename, 'wb')
	except:
		print("Couldn't open output file for saving parsed data. Quitting.")
		sys.exit()

	to_ilan_csv(glob_search)

	out_file.close
	print("Done parsing. See your data in %s." % out_filename)

sys.exit()


text:
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper' ))

module IntegrationTests
  class BlogCommentTest < ActionController::IntegrationTest
    def setup
      super
      @site = use_site! 'site with blog'
      @site.update_attributes! :permissions => { 'create comment' => 'anonymous' }
      @published_article = Article.find_by_title 'a blog article'
    end

    # FIXME test edit/delete comment
    # http://artweb-design.lighthouseapp.com/projects/13992/tickets/215
    test "An anonymous user posts a comment to a blog article" do
      post_a_blog_comment_as_anonymous
      view_submitted_comment
      go_back_to_article
    end

    test "A registered user posts a comment to a blog article" do
      login_as_user
      post_a_blog_comment_as_user
      view_submitted_comment
      go_back_to_article
    end

    def post_a_blog_comment_as_anonymous
      visit '/2008/1/1/a-blog-article'
      fill_in "user_name", :with => "John Doe"
      fill_in "user_email", :with => "john@example.com"
      fill_in "comment_body", :with => "What a nice article!"
      click_button "Submit comment"
    end

    def post_a_blog_comment_as_user
      visit '/2008/1/1/a-blog-article'
      fill_in "comment_body", :with => "What a nice article!"
      click_button "Submit comment"
    end

    def view_submitted_comment
      request.url.should =~ %r(#{@site.host}/comments/\d+)
      has_tag ".comment", /What a nice article!/
    end

    def go_back_to_article
      click_link 'a blog article'
      request.url.should == "http://#{@site.host}/2008/1/1/a-blog-article"
    end
  end
end


text:
using System;
using Stratis.Bitcoin.Utilities;

namespace Stratis.Bitcoin.Features.Wallet
{
    public class WalletAccountReference
    {
        public WalletAccountReference()
        {
        }

        public WalletAccountReference(string walletName, string accountName)
        {
            Guard.NotEmpty(walletName, nameof(walletName));
            Guard.NotEmpty(accountName, nameof(accountName));

            this.WalletName = walletName;
            this.AccountName = accountName;
        }

        public string WalletName { get; set; }

        public string AccountName { get; set; }

        public override bool Equals(object obj)
        {
            var item = obj as WalletAccountReference;
            if (item == null)
                return false;
            return this.GetId().Equals(item.GetId());
        }

        public static bool operator ==(WalletAccountReference a, WalletAccountReference b)
        {
            if (ReferenceEquals(a, b))
                return true;
            if (((object)a == null) || ((object)b == null))
                return false;
            return a.GetId().Equals(b.GetId());
        }

        public static bool operator !=(WalletAccountReference a, WalletAccountReference b)
        {
            return !(a == b);
        }

        public override int GetHashCode()
        {
            return this.GetId().GetHashCode();
        }

        internal Tuple<string, string> GetId()
        {
            return Tuple.Create(this.WalletName, this.AccountName);
        }

        public override string ToString()
        {
            return $"{this.WalletName}:{this.AccountName}";
        }
    }
}


text: <button type="button" class="close js__close" aria-hidden="true">×</button>


text:
public class PlayerInfo {
var textura : Texture2D;
var Largura = 0;
var Comprimento = 0;
}

var Info : PlayerInfo;

function OnGUI () {

	GUI.DrawTexture(Rect(10 , 10, 188, 85), Info.textura);

}
function Start () {

}

function Update () {

}


text:
{-# LANGUAGE FlexibleContexts   #-}
{-# LANGUAGE TupleSections      #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}

{-# OPTIONS_GHC -Wno-name-shadowing #-}

module Language.Haskell.Liquid.Types.Bounds (

    Bound(..),

    RBound, RRBound,

    RBEnv, RRBEnv,

    makeBound,

    ) where

import Prelude hiding (error)
import Text.PrettyPrint.HughesPJ
import GHC.Generics
import Data.List (partition)
import Data.Maybe
import Data.Hashable
import Data.Bifunctor
import Data.Data
import qualified Data.Binary         as B
import qualified Data.HashMap.Strict as M

import qualified Language.Fixpoint.Types as F
import qualified Language.Fixpoint.Misc  as Misc -- (mapFst, mapSnd)
import Language.Haskell.Liquid.Types.Types
import Language.Haskell.Liquid.Types.RefType

data Bound t e = Bound
  { bname   :: LocSymbol         -- ^ The name of the bound
  , tyvars  :: [t]               -- ^ Type variables that appear in the bounds
  , bparams :: [(LocSymbol, t)]  -- ^ These are abstract refinements, for now
  , bargs   :: [(LocSymbol, t)]  -- ^ These are value variables
  , bbody   :: e                 -- ^ The body of the bound
  } deriving (Data, Typeable, Generic)

instance (B.Binary t, B.Binary e) => B.Binary (Bound t e)

type RBound        = RRBound RSort
type RRBound tv    = Bound tv F.Expr
type RBEnv         = M.HashMap LocSymbol RBound
type RRBEnv tv     = M.HashMap LocSymbol (RRBound tv)

instance Hashable (Bound t e) where
  hashWithSalt i = hashWithSalt i . bname

instance Eq (Bound t e) where
  b1 == b2 = bname b1 == bname b2

instance (PPrint e, PPrint t) => (Show (Bound t e)) where
  show = showpp

instance (PPrint e, PPrint t) => (PPrint (Bound t e)) where
  pprintTidy k (Bound s vs ps xs e) = "bound" <+> pprintTidy k s <+>
                                      "forall" <+> pprintTidy k vs <+> "." <+>
                                      pprintTidy k (fst <$> ps) <+> "=" <+>
                                      ppBsyms k (fst <$> xs) <+> pprintTidy k e
    where
      ppBsyms _ [] = ""
      ppBsyms k xs = "\\" <+> pprintTidy k xs <+> "->"

instance Bifunctor Bound where
  first  f (Bound s vs ps xs e) = Bound s (f <$> vs) (Misc.mapSnd f <$> ps) (Misc.mapSnd f <$> xs) e
  second f (Bound s vs ps xs e) = Bound s vs ps xs (f e)

makeBound :: (PPrint r, UReftable r, SubsTy RTyVar (RType RTyCon RTyVar ()) r)
          => RRBound RSort -> [RRType r] -> [F.Symbol] -> RRType r -> RRType r
makeBound (Bound _  vs ps xs p) ts qs
         = RRTy cts mempty OCons
  where
    cts  = (\(x, t) -> (x, foldr subsTyVarMeet t su)) <$> cts'

    cts' = makeBoundType penv rs xs

    penv = zip (val . fst <$> ps) qs
    rs   = bkImp [] p

    bkImp acc (F.PImp p q) = bkImp (p:acc) q
    bkImp acc p          = p:acc

    su  = [(α, toRSort t, t) | (RVar α _, t) <-  zip vs ts ]

makeBoundType :: (PPrint r, UReftable r)
              => [(F.Symbol, F.Symbol)]
              -> [F.Expr]
              -> [(LocSymbol, RSort)]
              -> [(F.Symbol, RRType r)]
makeBoundType penv (q:qs) xts = go xts
  where
    -- NV TODO: Turn this into a proper error
    go [] = panic Nothing "Bound with empty symbols"

    go [(x, t)]      = [(F.dummySymbol, tp t x), (F.dummySymbol, tq t x)]
    go ((x, t):xtss) = (val x, mkt t x) : go xtss

    mkt t x = ofRSort t `strengthen` ofUReft (MkUReft (F.Reft (val x, mempty))
                                                (Pr $ M.lookupDefault [] (val x) ps))
    tp t x  = ofRSort t `strengthen` ofUReft (MkUReft (F.Reft (val x, F.pAnd rs))
                                                (Pr $ M.lookupDefault [] (val x) ps))
    tq t x  = ofRSort t `strengthen` makeRef penv x q

    (ps, rs) = partitionPs penv qs

-- NV TODO: Turn this into a proper error
makeBoundType _ _ _           = panic Nothing "Bound with empty predicates"

partitionPs :: [(F.Symbol, F.Symbol)] -> [F.Expr] -> (M.HashMap F.Symbol [UsedPVar], [F.Expr])
partitionPs penv qs = Misc.mapFst makeAR $ partition (isPApp penv) qs
  where
    makeAR ps       = M.fromListWith (++) $ map (toUsedPVars penv) ps

isPApp :: [(F.Symbol, a)] -> F.Expr -> Bool
isPApp penv (F.EApp (F.EVar p) _)  = isJust $ lookup p penv
isPApp penv (F.EApp e _)         = isPApp penv e
isPApp _    _                  = False

toUsedPVars :: [(F.Symbol, F.Symbol)] -> F.Expr -> (F.Symbol, [PVar ()])
toUsedPVars penv q@(F.EApp _ e) = (x, [toUsedPVar penv q])
  where
    -- NV : TODO make this a better error
    x = case {- unProp -} e of {F.EVar x -> x; e -> todo Nothing ("Bound fails in " ++ show e) }
toUsedPVars _ _ = impossible Nothing "This cannot happen"

toUsedPVar :: [(F.Symbol, F.Symbol)] -> F.Expr -> PVar ()
toUsedPVar penv ee@(F.EApp _ _)
  = PV q (PVProp ()) e (((), F.dummySymbol,) <$> es')
   where
     F.EVar e = {- unProp $ -} last es
     es'    = init es
     Just q = lookup p penv
     (F.EVar p, es) = F.splitEApp ee

toUsedPVar _ _ = impossible Nothing "This cannot happen"

-- `makeRef` is used to make the refinement of the last implication,
-- thus it can contain both concrete and abstract refinements

makeRef :: (UReftable r) => [(F.Symbol, F.Symbol)] -> LocSymbol -> F.Expr -> r
makeRef penv v (F.PAnd rs) = ofUReft (MkUReft (F.Reft (val v, F.pAnd rrs)) r)
  where
    r                    = Pr  (toUsedPVar penv <$> pps)
    (pps, rrs)           = partition (isPApp penv) rs

makeRef penv v rr
  | isPApp penv rr       = ofUReft (MkUReft (F.Reft(val v, mempty)) r)
  where
    r                    = Pr [toUsedPVar penv rr]

makeRef _    v p         = F.ofReft (F.Reft (val v, p))


text:
package cass.toolbox.xml;

import java.io.File;
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class XMLParser{

	private DocumentBuilder db;

	private Document doc;
	private Document originalDoc;
	private File file;

	public XMLParser(File file) throws Exception{
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		this.db = dbf.newDocumentBuilder();
		this.doc = db.parse(file);
		this.originalDoc=db.parse(file);
		this.file=file;
	}

	public XMLParser(InputStream in) throws Exception{
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		this.db = dbf.newDocumentBuilder();
		this.doc = db.parse(in);
		//this.originalDoc=db.parse(in);
		this.file=null;
	}

	@SuppressWarnings("unchecked")
	public <T> T select(String str) {
			Node node=this.getSelectedNode(str);
			if(null==node) return null;

			String lastPos=str.substring(str.lastIndexOf('.')+1).trim();
			if(lastPos.startsWith("list")
					||
					lastPos.startsWith("set")
					||
					lastPos.startsWith("map")
			){
				String[] lastParam;
				try{
					lastParam=lastPos.substring(lastPos.indexOf( '(' )+1,lastPos.indexOf( ')' )).split(",");
				}catch(IndexOutOfBoundsException e){
					lastParam=new String[0];
				}
				String config[][]=new String[lastParam.length][];
				try{
					for(int i=0;i<lastParam.length;++i){
						config[i]=lastParam[i].split("=");
						config[i][0]=config[i][0].trim();
						config[i][1]=config[i][1].trim();
					}
				}catch(NullPointerException e){
					e.printStackTrace();
					return null;
				}
				Map<String,String> additionalConfig=new HashMap<String,String>();
				for(String[] pair: config){
					additionalConfig.put(pair[0], pair[1]);
				}
				if(lastPos.startsWith("list")){
					return (T) this.parseList(node, additionalConfig);
				}else if(lastPos.startsWith("set")){
					return (T) this.parseSet(node, additionalConfig);
				}else if(lastPos.startsWith("map")){
					return (T) this.parseMap(node, additionalConfig);
				}else{
					return null;
				}
			}else{
				return (T) this.getValues(node);
			}
	}

	public List<Map<String, String>> childElementNames(String key){
		Node n=this.getSelectedNode(key);
		if(null==n) return null;
		List<Map<String, String>> ret=new LinkedList<Map<String, String>>();
		for(int i=0; i<n.getChildNodes().getLength(); ++i){
			if(n.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
				Node tmp=n.getChildNodes().item(i);
				Map<String, String> map=new HashMap<String,String>();
				map.put("#name", tmp.getNodeName());
				for(int j=0; j<tmp.getAttributes().getLength(); ++j){
					map.put(tmp.getAttributes().item(j).getNodeName(), tmp.getAttributes().item(j).getNodeValue());
				}
				ret.add(map);

			}
		}
		return ret;
	}

	public boolean insert(String key) {
		try{
			String nodePos=key.substring(0,key.lastIndexOf('.'));
			String elemName=key.substring(key.lastIndexOf('.')+1);

			String[][] attrs=null;
			if(elemName.contains("(")){
				String[] attrPair=null;
				String attrsString=elemName.substring(elemName.indexOf('(')+1, elemName.indexOf(')'));
				attrPair=attrsString.split(",");
				attrs=new String[attrPair.length][2];
				for(int i=0; i<attrPair.length ; ++i){
					String[] kv=attrPair[i].split("=");
					attrs[i][0]=kv[0].trim();
					attrs[i][1]=kv[1].trim();
				}

				elemName=elemName.substring(0,elemName.indexOf('('));
			}else{
				attrs=new String[0][];
			}
			Node n=this.getSelectedNode(nodePos);
			Element e=doc.createElement(elemName);
			for(String[] pair : attrs){
				e.setAttribute(pair[0], pair[1]);
			}

			n.appendChild(e);

			return true;
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
	}

	public boolean delete(String key) {
		Node n=this.getSelectedNode(key);
		if(null==n) return false;
		try{
			n.getParentNode().removeChild(n);
			return true;
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
	}

	public boolean commite(){
		try{
			Transformer tf=TransformerFactory.newInstance().newTransformer();
			StreamResult result = new StreamResult(file);
			DOMSource source = new DOMSource(doc);
			tf.transform(source, result);
			return true;
		}catch(Exception e){
			return false;
		}
	}

	public boolean rollback(){
		this.doc=this.originalDoc;
		try{
			this.originalDoc=db.parse(file);
		}catch(Exception e){
			return false;
		}
		return true;
	}

	private Node getSelectedNode(String str){
		//format path
		String[] positionRaw=str.split("\\.");
		String[] position;
		String[][][] param = new String[positionRaw.length][][];
		if(
				(positionRaw[positionRaw.length-1].startsWith("list(") && positionRaw[positionRaw.length-1].endsWith(")"))
				||
				(positionRaw[positionRaw.length-1].startsWith("map(") && positionRaw[positionRaw.length-1].endsWith(")"))
				||
				(positionRaw[positionRaw.length-1].startsWith("set(") && positionRaw[positionRaw.length-1].endsWith(")"))
				||
				positionRaw[positionRaw.length-1].equals("list")
				||
				positionRaw[positionRaw.length-1].equals("map")
				||
				positionRaw[positionRaw.length-1].equals("set")
				){
			position=new String[positionRaw.length-1];
			String last=positionRaw[positionRaw.length-1];
			String[][] parameterpair=new String[0][];
			if(last.contains("(")){
				last=last.substring(last.indexOf('(')+1,last.indexOf(')'));
				String[] parameterpairlink=last.split(",");
				parameterpair=new String[parameterpairlink.length][2];
				for(int i=0;i<parameterpair.length;++i){
					parameterpair[i]=parameterpairlink[i].split("=");
				}
			}
			param[param.length-1]=parameterpair;
		}else{
			position=new String[positionRaw.length];
		}
		for(int i=0; i< position.length; ++i){
			if(positionRaw[i].contains("(")){
				position[i]=positionRaw[i].substring(0, positionRaw[i].indexOf('('));
				String parameters;
				try{
					parameters=positionRaw[i].substring(positionRaw[i].indexOf('(')+1,positionRaw[i].indexOf(')'));
				}catch(IndexOutOfBoundsException e){
					e.printStackTrace();
					return null;
				}
				String[] parameterpair=parameters.split(",");
				param[i]=new String[parameterpair.length][2];
				for(int index=0;index<param[i].length;++index){
					String[] pair=parameterpair[i].split("=");
					try{
						param[i][index][0]=pair[0];
						param[i][index][1]=pair[1];
					}catch(IndexOutOfBoundsException e){
						e.printStackTrace();
						return null;
					}
				}
			}else{
				position[i]=positionRaw[i];
			}
		}

		//start searching
		Node ret=this.doc;
		for(int i=0;i<position.length;++i){
			Map<String,?> values=this.getValues(ret);
			try{
				for(String[] pair : param[i]){
					if(!values.get(pair[0]).toString().equals(pair[1])){
						ret=null;
						break;
					}
				}
			}catch(NullPointerException e){

			}
			if(null==ret) break;
			boolean found=false;
			for(int j=0;j<ret.getChildNodes().getLength();++j){
				if(ret.getChildNodes().item(j).getNodeName().equals(position[i])){
					ret=ret.getChildNodes().item(j);
					found=true;
					break;
				}
			}
			if(!found){
				return null;
			}
		}
		if(positionRaw.length!=position.length){
			//last position parameter is list/set/map
			if(positionRaw[positionRaw.length-1].startsWith("list")){
				for(int j=0;j<ret.getChildNodes().getLength();++j){
					if(ret.getChildNodes().item(j).getNodeName().equals("list")){
						Node jnode = ret.getChildNodes().item(j);
						boolean found0=true;
						try{
							for(int k=0;k<param[param.length-1].length;++k){
								boolean found1=false;
								for(int l=0;l<jnode.getAttributes().getLength();++l){
									if(jnode.getAttributes().item(l).getNodeName().equals(param[param.length-1][k][0])
											&&
											jnode.getAttributes().item(l).getNodeValue().equals(param[param.length-1][k][1])
											){
										found1=true;
										break;
									}
								}
								if(!found1){
									found0=false;
									break;
								}
							}
						}catch(NullPointerException e){}
						if(found0){
							ret=jnode;
							break;
						}
					}
				}
			}else if(positionRaw[positionRaw.length-1].startsWith("set")){
				for(int j=0;j<ret.getChildNodes().getLength();++j){
					if(ret.getChildNodes().item(j).getNodeName().equals("set")){
						Node jnode = ret.getChildNodes().item(j);
						boolean found0=true;
						try{
							for(int k=0;k<param[param.length-1].length;++k){
								boolean found1=false;
								for(int l=0;l<jnode.getAttributes().getLength();++l){
									if(jnode.getAttributes().item(l).getNodeName().equals(param[param.length-1][k][0])
											&&
											jnode.getAttributes().item(l).getNodeValue().equals(param[param.length-1][k][1])
											){
										found1=true;
										break;
									}
								}
								if(!found1){
									found0=false;
									break;
								}
							}
						}catch(NullPointerException e){}
						if(found0){
							ret=jnode;
							break;
						}
					}
				}
			}else if(positionRaw[positionRaw.length-1].startsWith("map")){
				for(int j=0;j<ret.getChildNodes().getLength();++j){
					if(ret.getChildNodes().item(j).getNodeName().equals("map")){
						Node jnode = ret.getChildNodes().item(j);
						boolean found0=true;
						try{
							for(int k=0;k<param[param.length-1].length;++k){
								boolean found1=false;
								for(int l=0;l<jnode.getAttributes().getLength();++l){
									if(jnode.getAttributes().item(l).getNodeName().equals(param[param.length-1][k][0])
											&&
											jnode.getAttributes().item(l).getNodeValue().equals(param[param.length-1][k][1])
											){
										found1=true;
										break;
									}
								}
								if(!found1){
									found0=false;
									break;
								}
							}
						}catch(NullPointerException e){}
						if(found0){
							ret=jnode;
							break;
						}
					}
				}
			}
		}
		return ret;
	}

	/**
	 *
	 * @param node
	 * @return comment : empty map.
	 *
comment : maps string "#comment" to comment text
	 *
text/cdata : maps string "#text" to List<text> in the node
	 *
map : maps string "#map" to Map
	 *
list: maps string "#list" to List
	 *
set: maps string "#set" to Set
	 *
element : maps element-attrs to their values, and
	 *
 if getValues( child node ) contains 2 entries (#name and another value)
	 *
 child node would also be considered as an attr with key=#name value=another value.
	 */
	@SuppressWarnings("unchecked")
	private Map<String,Object> getValues(Node node){
		Map<String,Object> map=new HashMap<String,Object>();

		//COMMENT
		if(node.getNodeType()==Node.COMMENT_NODE){
			if(node.getNodeValue().trim().equals("")){
				return map;
			}
			map.put("#name", "#comment");
			List<String> list=new LinkedList<String>();
			list.add(node.getNodeValue());
			map.put("#comment", list);
			return map;
		}

		//TEXT/CDATA
		if(node.getNodeType()==Node.TEXT_NODE
				||
				node.getNodeType()==Node.CDATA_SECTION_NODE
				){
			if(node.getNodeValue().trim().equals("")){
				return map;
			}
			map.put("#name", "#text");
			List<String> list=new LinkedList<String>();
			list.add(node.getNodeValue());
			map.put("#text", list);
			return map;
		}

		//<map> node
		if(node.getNodeName().equalsIgnoreCase("map")){
			map.put("#name", "map");
			map.put("#map", this.parseMap(node, null) );
			return map;
		}
		//<list> node
		if(node.getNodeName().equalsIgnoreCase("list")){
			map.put("#name", "list");
			map.put("#list", this.parseList(node, null));
			return map;
		}
		//<set> node
		if(node.getNodeName().equalsIgnoreCase("set")){
			map.put("#name", "set");
			map.put("#set", this.parseSet(node, null));
			return map;
		}
		//get (<node key="value">)
		map.put("#name", node.getNodeName());
		try{
			for(int i=0;i<node.getAttributes().getLength();++i){
				map.put(node.getAttributes().item(i).getNodeName(),
						this.stringToObject(node.getAttributes().item(i).getNodeValue())
						);
			}
		}catch(NullPointerException e){

		}
		//get
		//<node>
		//			<key>
		//				value
		//			</key>
		for(int i=0;i<node.getChildNodes().getLength();++i){
			Node n=node.getChildNodes().item(i);

				Map<String,Object> childmap=this.getValues(n);
				Set<String> keySet = childmap.keySet();
				int count=0;
				for(@SuppressWarnings("unused") String s:keySet){
					++count;
				}
				if(2==count){
					if(
							((String)childmap.get("#name")).contains("#comment")
					){
						//comment
						if(map.get("#comment")==null){
							map.put("#comment", new LinkedList<String>());
						}
						((List<String>)map.get("#comment")).addAll((List<String>)childmap.get("#comment"));
					}else	 if(
							((String)childmap.get("#name")).equals("#text")
					){
						//text
						if(map.get("#text")==null){
							map.put("#text", new LinkedList<String>());
						}
						((List<String>)map.get("#text")).addAll((List<String>)childmap.get("#text"));
					}else if(
							null!=childmap.get("#map")
					){
						//map
						int index=-1;
						for(int j=0;j<n.getAttributes().getLength();++j){
							if(n.getAttributes().item(j).getNodeName().equalsIgnoreCase("name")){
								index=j;
								break;
							}
						}
						if(-1==index){
							map.put("#map", childmap.get("#map"));
						}else{
							map.put(n.getAttributes().item(index).getNodeValue(), childmap.get("#map"));
						}
					}else if(
							null!=childmap.get("#set")
					){
						//set
						int index=-1;
						for(int j=0;j<n.getAttributes().getLength();++j){
							if(n.getAttributes().item(j).getNodeName().equalsIgnoreCase("name")){
								index=j;
								break;
							}
						}
						if(-1==index){
							map.put("#set", childmap.get("#set"));
						}else{
							map.put(n.getAttributes().item(index).getNodeValue(), childmap.get("#set"));
						}
					}else if(
							null!=childmap.get("#list")
					){
						//list
						int index=-1;
						for(int j=0;j<n.getAttributes().getLength();++j){
							if(n.getAttributes().item(j).getNodeName().equalsIgnoreCase("name")){
								index=j;
								break;
							}
						}
						if(-1==index){
							map.put("#list", childmap.get("#list"));
						}else{
							map.put(n.getAttributes().item(index).getNodeValue(), childmap.get("#list"));
						}
					}else{
						//other
						//find another attr
						String attr=null;
						for(String s : keySet){
							if(!s.equals("#name")){
								attr=s;
							}
						}
						map.put((String)childmap.get("#name"), childmap.get(attr));
					}
				}

		}

		return map;
	}

	@SuppressWarnings("unchecked")
	private Map<?,?> parseMap(Node node,Map<String,String> additionalConfig){
		if(!node.getNodeName().equalsIgnoreCase("map")){
			return null;
		}
		if(null==additionalConfig){
			additionalConfig=new HashMap<String,String>();
		}

		if(null==additionalConfig.get("value")){
			for(int i=0;i<node.getAttributes().getLength();++i){
				if(node.getAttributes().item(i).getNodeName().equals("value")){
					additionalConfig.put("value", node.getAttributes().item(i).getNodeValue());
				}
			}
		}
		if(null==additionalConfig.get("key")){

			for(int i=0;i<node.getAttributes().getLength();++i){
				if(node.getAttributes().item(i).getNodeName().equals("key")){
					additionalConfig.put("key", node.getAttributes().item(i).getNodeValue());
				}
			}
			if(null!=additionalConfig.get("key")){
				return this.parseMapWithKey(node, additionalConfig);
			}

			//infer key
			//get first element node
			Node firstElement=null;
			for(int i=0;i<node.getChildNodes().getLength();++i){
				if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
					firstElement=node.getChildNodes().item(i);
					break;
				}
			}
			if(null==firstElement){
				return new HashMap<Object,Object>();
			}
			//get values
			Map<String,Object> valuesOfFirstElement = this.getValues(firstElement);
			//check the following attr names
			// id name (#name)value key
			String attr=null;
			if(valuesOfFirstElement.containsKey("id")){
				attr="id";
				if(this.allChildNodesHaveAttrName(node, attr)){
					additionalConfig.put("key", attr);
				}
			}else if(valuesOfFirstElement.containsKey("name")){
				attr="name";
				if(this.allChildNodesHaveAttrName(node, attr)){
					additionalConfig.put("key", attr);
				}
			}else if(valuesOfFirstElement.containsKey(valuesOfFirstElement.get("#name"))){
				attr=(String)valuesOfFirstElement.get("#name");
				if(this.allChildNodesHaveAttrName(node, attr)){
					additionalConfig.put("key", attr);
				}
			}else if(valuesOfFirstElement.containsKey("key")){
				attr="key";
				if(this.allChildNodesHaveAttrName(node, attr)){
					additionalConfig.put("key", attr);
				}
			}else if(valuesOfFirstElement.get("#name").equals("key")
					&&
					valuesOfFirstElement.containsKey("value")
					){
				attr="value";
				if(this.allChildNodesHaveAttrName(node, attr)
						&&
						this.allChilNodesHaveNodeName(node, "key")
						){

					Map<Object,Object> map=new HashMap<Object,Object>();
					for(int i=0;i<node.getChildNodes().getLength();++i){
						if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
							Map<String,?>values=this.getValues(node.getChildNodes().item(i));
							map.put(((List<String>)values.get("#text")).get(0), values.get("value"));
						}
					}
					return map;

				}
			}else{
				Set<String> set=valuesOfFirstElement.keySet();
				for(String s:set){
					if(!s.startsWith("#")){
						additionalConfig.put("key", s);
						break;
					}
				}
			}

			return this.parseMapWithKey(node, additionalConfig);
		}else{
			return this.parseMapWithKey(node, additionalConfig);
		}
	}

	private Map<?,?> parseMapWithKey(Node node,Map<String,String> additionalConfig){
		if(null==additionalConfig.get("key")){
			return new HashMap<Object,Object>();
		}

		Map<Object,Object> map=new HashMap<Object,Object>();

		if(null==additionalConfig.get("value")
				||
				additionalConfig.get("value").equals("#node")

		){
			for(int i=0;i<node.getChildNodes().getLength();++i){
				if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
					Map<String,?>values=this.getValues(node.getChildNodes().item(i));
					map.put(
							this.stringToObject(
									values.get(additionalConfig.get("key")))
							, this.stringToObject(
									values));
				}
			}
		}else{
			for(int i=0;i<node.getChildNodes().getLength();++i){
				if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
					Map<String,?>values=this.getValues(node.getChildNodes().item(i));
					map.put(values.get(
							this.stringToObject(
									additionalConfig.get("key")))
							,this.stringToObject(
									values.get(additionalConfig.get("value"))));
				}
			}

		}

		return map;
	}

	private boolean allChildNodesHaveAttrName(Node node,String attr){
		for(int i=0;i<node.getChildNodes().getLength();++i){
			if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
				if(!this.getValues(node).containsKey(attr))
					return false;
			}else{
				continue;
			}
		}
		return true;
	}
	private boolean allChilNodesHaveNodeName(Node node,String name){
		for(int i=0;i<node.getChildNodes().getLength();++i){
			if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
				if(!node.getChildNodes().item(i).getNodeName().equals(name))
					return false;
			}else{
				continue;
			}
		}
		return true;
	}

	@SuppressWarnings("unchecked")
	private List<?> parseList(Node node,Map<String,String> additionalConfig){
		if(!node.getNodeName().equalsIgnoreCase("list")
				&&
				!node.getNodeName().equalsIgnoreCase("set")
				){
			return null;
		}
		if(null==additionalConfig){
			additionalConfig=new HashMap<String,String>();
		}
		if(null==additionalConfig.get("value")){
			for(int i=0;i<node.getAttributes().getLength();++i){
				if(node.getAttributes().item(i).getNodeName().equals("value")){
					additionalConfig.put("value", node.getAttributes().item(i).getNodeValue());
				}
			}
			if(null!=additionalConfig.get("value")){
				return this.parseListWithInferredValue(node, additionalConfig);
			}
			//infer value
			//get first element node
			Node firstElement=null;
			for(int i=0;i<node.getChildNodes().getLength();++i){
				if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
					firstElement=node.getChildNodes().item(i);
					break;
				}
			}
			if(null==firstElement){
				return new LinkedList<Object>();
			}
			//get values
			Map<String,Object> valuesOfFirstElement = this.getValues(firstElement);

			//check if it's the only attr
			Set<String> keySet=valuesOfFirstElement.keySet();
			int count=0;
			String found=null;
			for(String s:keySet){
				if(!s.startsWith("#")){
					++count;
					if(null==found){
						found=s;
					}else{
						found=null;
						break;
					}
				}
			}
			if(null!=found){
				if(this.allChildNodesHaveAndOnlyHaveAttr(node, found)){
					additionalConfig.put("value", found);
				}
			}else{
				if(0==count){
					if(this.allChilNodesHaveNodeName(node, (String)valuesOfFirstElement.get("#name"))){
						List<Object> list=new LinkedList<Object>();
						for(int i=0;i<node.getChildNodes().getLength();++i){
							if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
								Map<String,Object> values=this.getValues(node.getChildNodes().item(i));
								List<String> tmp=(List<String>)values.get("#text");
								try{
									for(String s:tmp){
										list.add(s);
									}
								}catch(NullPointerException e){
									if(1==this.childContainingElementCount(node.getChildNodes().item(i))){
										Node element=null;
										for(int j=0;j<node.getChildNodes().item(i).getChildNodes().getLength();++j){
											if(node.getChildNodes().item(i).getChildNodes().item(j).getNodeType()==Node.ELEMENT_NODE){
												element=node.getChildNodes().item(i).getChildNodes().item(j);
											}
										}
										list.add(this.getValues(element));
									}
								}
							}
						}
						return list;
					}
				}
			}

			return this.parseListWithInferredValue(node, additionalConfig);
		}else{
			return this.parseListWithInferredValue(node, additionalConfig);
		}

	}

	private int childContainingElementCount(Node node){
		int count=0;
		for(int i=0;i<node.getChildNodes().getLength();++i){
			if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
				++count;
			}
		}
		return count;
	}

	private List<?> parseListWithInferredValue(Node node,Map<String,String> additionalConfig){
		List<Object> list=new LinkedList<Object>();
		if(null==additionalConfig.get("value")
				||
				additionalConfig.get("value").equals("#node")
				){
			for(int i=0;i<node.getChildNodes().getLength();++i){
				if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
					Map<String,?>values=this.getValues(node.getChildNodes().item(i));
					list.add(values);
				}
			}
		}else{
			for(int i=0;i<node.getChildNodes().getLength();++i){
				if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
					Map<String,?>values=this.getValues(node.getChildNodes().item(i));
					list.add(
							this.stringToObject(values.get(additionalConfig.get("value")))
							);
				}
			}
		}

		return list;
	}
	private boolean allChildNodesHaveAndOnlyHaveAttr(Node node,String attr){
		for(int i=0;i<node.getChildNodes().getLength();++i){
			if(node.getChildNodes().item(i).getNodeType()==Node.ELEMENT_NODE){
				Map<String,Object> map=this.getValues(node.getChildNodes().item(i));
				if(!map.containsKey(attr))
					return false;
				else{
					Set<String> keySet=map.keySet();
					int count=0;
					for(String s:keySet){
						if(!s.startsWith("#")){
							if(0==count){
								count=1;
							}else{
								return false;
							}
						}
					}
				}
			}else{
				continue;
			}
		}
		return true;
	}

	private Set<?> parseSet(Node node,Map<String,String> additionalConfig){
		if(!node.getNodeName().equalsIgnoreCase("set")){
			return null;
		}
		List<?> list=this.parseList(node, additionalConfig);

		Set<Object> set=new HashSet<Object>();
		for(Object o : list){
			set.add(o);
		}

		return set;
	}

	private boolean isNumeric(String str){
		int dotCount=0;
		for (int i = str.length()-1;i>=0;--i){
			if(str.charAt(i)<'0' || str.charAt(i)>'9'){
				if(str.charAt(i)=='.'){
					if(1==dotCount) return false;
					else dotCount=1;
				}else{
					return false;
				}
			}
		}
		return true;
	}

	private Object stringToObject(Object o){
		if(null==o) return null;
		String eValue=null;
		try{
			eValue=(String)o;
		}catch(ClassCastException e){
			return o;
		}
		eValue=eValue.trim();
		if(eValue.equalsIgnoreCase("null")
				||
				eValue.equalsIgnoreCase("nullptr")
				||
				eValue.equals("")
				){
			return null;
		}else if(eValue.equalsIgnoreCase("true")){
			return true;
		}else if(eValue.equalsIgnoreCase("false")){
			return false;
		}else if(this.isNumeric(eValue)){
			if(eValue.contains(".")){
				return Double.parseDouble(eValue);
			}else{
				return Integer.parseInt(eValue);
			}
		}else{
			return eValue;
		}
	}

}


text:
std::map<std::string, int> Hamster::ToFile::_messageID;
std::map<std::string, std::string> Hamster::ToFile::_typeDef;

Hamster::ToFile::ToFile()
{
	_bodyCount = 0;
	_packageName = "";
	_packagePath = "";
}

Hamster::ToFile::~ToFile()
{
}

std::string Hamster::ToFile::toFile(ASTNode * node)
{
    std::string code = "";
	const ASTType nodeType = node->type;  // typeid(*node).name();
    if (IS_EQUAL(AST::ASTType::AST_TYPE_BODY, nodeType))
    {
        ASTBody * body = dynamic_cast<ASTBody*>(node);
        IS_NULL(body);
        code += toBody(body);
    }
	else if (IS_EQUAL(AST::ASTType::AST_TYPE_PACKAGE, nodeType))
    {
        ASTPackage * package = dynamic_cast<ASTPackage*>(node);
        IS_NULL(package);
        code = toPackage(package);
    }
	else if (IS_EQUAL(AST::ASTType::AST_TYPE_IMPORT, nodeType))
    {
        ASTImport * import = dynamic_cast<ASTImport*>(node);
        IS_NULL(import);
        code = toImport(import);
    }
	else if (IS_EQUAL(AST::ASTType::AST_TYPE_GUIDANCE, nodeType))
    {
        ASTGuidance * packageName = dynamic_cast<ASTGuidance*>(node);
        IS_NULL(packageName);
        code = toPackageName(packageName);
    }
	else if (IS_EQUAL(AST::ASTType::AST_TYPE_DEF, nodeType))
    {
        ASTDef * def = dynamic_cast<ASTDef*>(node);
        IS_NULL(def);
        code = toDef(def);
    }
	else if (IS_EQUAL(AST::ASTType::AST_TYPE_ENUM, nodeType))
    {
        ASTEnum * astEnum = dynamic_cast<ASTEnum*>(node);
        IS_NULL(astEnum);
        code = toEnum(astEnum);
    }
	else if (IS_EQUAL(AST::ASTType::AST_TYPE_VALUE, nodeType))
    {
        ASTValue * value = dynamic_cast<ASTValue*>(node);
        IS_NULL(value);
        code = toValue(value);
    }
	else if (IS_EQUAL(AST::ASTType::AST_TYPE_CLASS, nodeType))
    {
        ASTClass * astClass = dynamic_cast<ASTClass*>(node);
        IS_NULL(astClass);
        code = toClass(astClass);
    }
    return code;
}

std::string Hamster::ToFile::getSpace()
{
    std::string space = "";
    for (int i = 0; i < _bodyCount; i++)
        space += "    ";
	return space;
}

std::string Hamster::ToFile::getSpace(int count)
{
	std::string space = "";
	for (int i = 0; i < count; i++)
		space += "    ";
	return space;
}

std::string Hamster::ToFile::toBody(ASTBody * body)
{
    std::string space = getSpace();
    std::string code = space + "{\n";
    for (int i = 0; i < body->getStatementCount(); i++)
    {
        std::string temp = toFile(body->getStatement(i));
        code += temp;
        code += "\n";
    }
    code = code + space + "}\n";
    return code;
}

std::string Hamster::ToFile::toPackage(ASTPackage * package)
{
	std::string code = getSpace() + "package ";

    IS_NULL(package->getPackageName());
    std::string packageName = toPackageName(package->getPackageName());

    IS_NULL(package->getBody());
    std::string packageBody = toBody(package->getBody());

    code += packageName;
    code += "\n";
    code += packageBody;

    return code;
}

std::string Hamster::ToFile::toImport(ASTImport * import)
{
    std::string code = getSpace() + "using ";

    IS_NULL(import->getPackageName());
    std::string packageName = toPackageName(import->getPackageName());

    code += packageName;
    code += ";\n";

    return code;
}

std::string Hamster::ToFile::toPackageName(ASTGuidance * packageName)
{
    if (packageName->getCount() <= 0)
        return "";
    std::string code = getSpace() + packageName->getNext(0);
    for (int i = 1; i < packageName->getCount(); i++)
    {
        code += ".";
        code += getSpace() + packageName->getNext(i);
    }
    code += ";";
    return code;
}

std::string Hamster::ToFile::toDef(ASTDef * def)
{
    std::string code = def->getType();
    code += " = ";
    code += def->getName();
    return code;
}

std::string Hamster::ToFile::toEnum(ASTEnum * astEnum)
{
    std::string code = getSpace() + astEnum->getName();
    IS_NULL(astEnum->getBody());
    code += toBody(astEnum->getBody());
    return code;
}

std::string Hamster::ToFile::toValue(ASTValue * value)
{
    std::string code = getSpace() + value->getValue().String + ",\n";
    return std::string();
}

std::string Hamster::ToFile::toClass(ASTClass * astClass)
{
    std::string code = getSpace() + astClass->getName() + "\n";
    std::string body = toBody(astClass->getBody());
    code += body;
    return code;
}

std::string Hamster::ToFile::toDefBody(ASTDef * def)
{
	return std::string();
}

std::string Hamster::ToFile::getMeta(vector<ASTDef*> body, int space)
{
	return std::string();
}

std::string Hamster::ToFile::getMeta(ASTNode *other)
{
	return std::string();
}

void Hamster::ToFile::initMessageID()
{
	// ¶ÁÈ¡ÏûÏ¢°üIDµÄ¼Ç¼Îļþ
	ifstream infile("Config\\Py\\init.ini");
	if (!infile.is_open())   //Èôʧ°Ü,ÔòÊä³ö´íÎóÏûÏ¢,²¢ÖÕÖ¹³ÌÐòÔËÐÐ
	{
		LOG_ERROR("Error: Unable to read from the configuration file");
		system("pause");
		exit(-1);
	}

	char buffer[1024] = "";
	while (!infile.eof())
	{
		infile.getline(buffer, 1024);
		string s(buffer);
		int separate = s.find(':');
		string key = s.substr(0, separate);
		string value = s.substr(separate + 1, s.size());
		int mid = MC::toInt(value);
		ToFile::_messageID[key] = mid;
	}
	infile.close();

	// ¶ÁÈ¡ÀàÐÍÎļþ
	infile.open("Config\\Py\\typeDef.ini");
	if (!infile.is_open())   //Èôʧ°Ü,ÔòÊä³ö´íÎóÏûÏ¢,²¢ÖÕÖ¹³ÌÐòÔËÐÐ
	{
		LOG_ERROR("Error: Unable to read from the configuration file");
		system("pause");
		exit(-1);
	}
	while (!infile.eof())
	{
		infile.getline(buffer, 1024);
		string s(buffer);
		int separate = s.find(':');
		string key = s.substr(0, separate);
		string value = s.substr(separate + 1, s.size());
		ToFile::_typeDef[key] = value;
	}
	infile.close();
}

void Hamster::ToFile::saveMessageID()
{
	ofstream  infile("Config\\Py\\init.ini");
	if (!infile.is_open())
	{
		LOG_ERROR("Error: Unable to save from the configuration file");
		system("pause");
		exit(-1);
	}
	for each (auto var in ToFile::_messageID)
	{
		string key = var.first;
		int value = var.second;
		infile << key;
		infile << ":";
		infile << value;
		infile << "\n";
	}
	infile.close();
}

bool Hamster::ToFile::addMessageID(std::string messageName, int ID)
{
	auto result = ToFile::_messageID.find(messageName);
	if (result != ToFile::_messageID.end())
		return false;
	ToFile::_messageID[messageName] = ID;
	return true;
}

int Hamster::ToFile::getMaxMessageID()
{
	int max = 0;
	for each (auto var in ToFile::_messageID)
	{
		int value = var.second;
		if (max < value)
			max = value;
	}
	return max + 1;
}

bool Hamster::ToFile::isMessage(std::string className)
{
	return className == MESSAGE_CLASS_NAME;
}

string Hamster::ToFile::getType(std::string type)
{
	auto result = ToFile::_typeDef.find(type);
	if (result == ToFile::_typeDef.end())
		return "BinaryTypeDef.STRUCT";
	return result->second;
}


text:
.class Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;
.super Landroid/os/Handler;
.source "IccPhoneBookInterfaceManager.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation

# instance fields
.field final synthetic this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

# direct methods
.method constructor <init>(Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;)V
    .locals 0

    .prologue
    .line 106
    iput-object p1, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    invoke-direct {p0}, Landroid/os/Handler;-><init>()V

    return-void
.end method

.method private notifyPending(Landroid/os/AsyncResult;)V
    .locals 2
    .param p1, "ar"    # Landroid/os/AsyncResult;

    .prologue
    .line 247
    iget-object v1, p1, Landroid/os/AsyncResult;->userObj:Ljava/lang/Object;

    if-eqz v1, :cond_0

    .line 248
    iget-object v0, p1, Landroid/os/AsyncResult;->userObj:Ljava/lang/Object;

    check-cast v0, Ljava/util/concurrent/atomic/AtomicBoolean;

    .line 249
    .local v0, "status":Ljava/util/concurrent/atomic/AtomicBoolean;
    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicBoolean;->set(Z)V

    .line 251
    .end local v0    # "status":Ljava/util/concurrent/atomic/AtomicBoolean;
    :cond_0
    iget-object v1, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v1, v1, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mLock:Ljava/lang/Object;

    invoke-virtual {v1}, Ljava/lang/Object;->notifyAll()V

    .line 252
    return-void
.end method

# virtual methods
.method public handleMessage(Landroid/os/Message;)V
    .locals 9
    .param p1, "msg"    # Landroid/os/Message;

    .prologue
    const/4 v4, 0x1

    const/4 v5, 0x0

    .line 111
    iget v6, p1, Landroid/os/Message;->what:I

    packed-switch v6, :pswitch_data_0

    .line 244
    :goto_0
    :pswitch_0
    return-void

    .line 113
    :pswitch_1
    iget-object v1, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v1, Landroid/os/AsyncResult;

    .line 114
    .local v1, "ar":Landroid/os/AsyncResult;
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v5, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mLock:Ljava/lang/Object;

    monitor-enter v5

    .line 115
    :try_start_0
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    if-nez v4, :cond_0

    .line 116
    iget-object v6, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v4, v1, Landroid/os/AsyncResult;->result:Ljava/lang/Object;

    check-cast v4, [I

    check-cast v4, [I

    iput-object v4, v6, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mRecordSize:[I

    .line 120
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    new-instance v6, Ljava/lang/StringBuilder;

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

    const-string v7, "GET_RECORD_SIZE Size "

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

    move-result-object v6

    iget-object v7, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v7, v7, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mRecordSize:[I

    const/4 v8, 0x0

    aget v7, v7, v8

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

    move-result-object v6

    const-string v7, " total "

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

    move-result-object v6

    iget-object v7, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v7, v7, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mRecordSize:[I

    const/4 v8, 0x1

    aget v7, v7, v8

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

    move-result-object v6

    const-string v7, " #record "

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

    move-result-object v6

    iget-object v7, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v7, v7, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mRecordSize:[I

    const/4 v8, 0x2

    aget v7, v7, v8

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

    move-result-object v6

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

    move-result-object v6

    invoke-virtual {v4, v6}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->logd(Ljava/lang/String;)V

    .line 132
    :goto_1
    invoke-direct {p0, v1}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->notifyPending(Landroid/os/AsyncResult;)V

    .line 133
    monitor-exit v5

    goto :goto_0

    :catchall_0
    move-exception v4

    monitor-exit v5
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v4

    .line 126
    :cond_0
    :try_start_1
    const-string v4, "IccPhoneBookInterfaceManager"

    const-string v6, "handle message: EVENT_GET_SIZE_DONE"

    iget-object v7, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    invoke-static {v4, v6, v7}, Landroid/telephony/Rlog;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    .line 129
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    # getter for: Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->FAKE_ADN_SIZE_RESULT:[I
    invoke-static {}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->access$000()[I

    move-result-object v6

    iput-object v6, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mRecordSize:[I
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_1

    .line 136
    .end local v1    # "ar":Landroid/os/AsyncResult;
    :pswitch_2
    iget-object v1, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v1, Landroid/os/AsyncResult;

    .line 137
    .restart local v1    # "ar":Landroid/os/AsyncResult;
    iget-object v6, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v6, v6, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mLock:Ljava/lang/Object;

    monitor-enter v6

    .line 138
    :try_start_2
    iget-object v7, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v8, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    if-nez v8, :cond_1

    :goto_2
    iput-boolean v4, v7, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mSuccess:Z

    .line 139
    invoke-direct {p0, v1}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->notifyPending(Landroid/os/AsyncResult;)V

    .line 140
    monitor-exit v6

    goto/16 :goto_0

    :catchall_1
    move-exception v4

    monitor-exit v6
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1

    throw v4

    :cond_1
    move v4, v5

    .line 138
    goto :goto_2

    .line 143
    .end local v1    # "ar":Landroid/os/AsyncResult;
    :pswitch_3
    iget-object v1, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v1, Landroid/os/AsyncResult;

    .line 144
    .restart local v1    # "ar":Landroid/os/AsyncResult;
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v5, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mLock:Ljava/lang/Object;

    monitor-enter v5

    .line 145
    :try_start_3
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    if-nez v4, :cond_3

    .line 146
    iget-object v6, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v4, v1, Landroid/os/AsyncResult;->result:Ljava/lang/Object;

    check-cast v4, Ljava/util/List;

    iput-object v4, v6, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mRecords:Ljava/util/List;

    .line 153
    :cond_2
    :goto_3
    invoke-direct {p0, v1}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->notifyPending(Landroid/os/AsyncResult;)V

    .line 154
    monitor-exit v5

    goto/16 :goto_0

    :catchall_2
    move-exception v4

    monitor-exit v5
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_2

    throw v4

    .line 148
    :cond_3
    :try_start_4
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    const-string v6, "Cannot load ADN records"

    invoke-virtual {v4, v6}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->logd(Ljava/lang/String;)V

    .line 149
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v4, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mRecords:Ljava/util/List;

    if-eqz v4, :cond_2

    .line 150
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v4, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mRecords:Ljava/util/List;

    invoke-interface {v4}, Ljava/util/List;->clear()V
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_2

    goto :goto_3

    .line 159
    .end local v1    # "ar":Landroid/os/AsyncResult;
    :pswitch_4
    iget-object v1, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v1, Landroid/os/AsyncResult;

    .line 160
    .restart local v1    # "ar":Landroid/os/AsyncResult;
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v5, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mQueryHtcPbk:Ljava/lang/Object;

    monitor-enter v5

    .line 161
    :try_start_5
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    if-nez v4, :cond_5

    .line 162
    iget-object v6, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v4, v1, Landroid/os/AsyncResult;->result:Ljava/lang/Object;

    check-cast v4, Ljava/util/ArrayList;

    # setter for: Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->phoneBookEntries:Ljava/util/List;
    invoke-static {v6, v4}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->access$102(Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;Ljava/util/List;)Ljava/util/List;

    .line 164
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    const-string v6, "load ADN records success!!"

    # invokes: Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->log(Ljava/lang/String;)V
    invoke-static {v4, v6}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->access$200(Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;Ljava/lang/String;)V

    .line 170
    :cond_4
    :goto_4
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v4, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mQueryHtcPbk:Ljava/lang/Object;

    invoke-virtual {v4}, Ljava/lang/Object;->notifyAll()V

    .line 171
    monitor-exit v5

    goto/16 :goto_0

    :catchall_3
    move-exception v4

    monitor-exit v5
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_3

    throw v4

    .line 166
    :cond_5
    :try_start_6
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    # getter for: Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->phoneBookEntries:Ljava/util/List;
    invoke-static {v4}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->access$100(Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;)Ljava/util/List;

    move-result-object v4

    if-eqz v4, :cond_4

    .line 167
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    # getter for: Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->phoneBookEntries:Ljava/util/List;
    invoke-static {v4}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->access$100(Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;)Ljava/util/List;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/List;->clear()V
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_3

    goto :goto_4

    .line 177
    .end local v1    # "ar":Landroid/os/AsyncResult;
    :pswitch_5
    iget-object v1, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v1, Landroid/os/AsyncResult;

    .line 179
    .restart local v1    # "ar":Landroid/os/AsyncResult;
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v5, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mLockHtcPbk:Ljava/lang/Object;

    monitor-enter v5

    .line 180
    if-eqz v1, :cond_6

    :try_start_7
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    if-eqz v4, :cond_6

    .line 182
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    const-string v6, "Cannot add PBK entry"

    # invokes: Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->log(Ljava/lang/String;)V
    invoke-static {v4, v6}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->access$200(Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;Ljava/lang/String;)V

    .line 184
    iget-object v0, v1, Landroid/os/AsyncResult;->userObj:Ljava/lang/Object;

    check-cast v0, Lcom/android/internal/telephony/ADNErrorType;

    .line 185
    .local v0, "adnErrorType":Lcom/android/internal/telephony/ADNErrorType;
    const/4 v4, 0x0

    iput-boolean v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mSuccess:Z

    .line 186
    const-string v3, "MemoryFull:"

    .line 187
    .local v3, "error_prefix":Ljava/lang/String;
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    invoke-virtual {v4}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v4

    const-string v6, "AdnFull"

    invoke-virtual {v4, v6}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v4

    if-eqz v4, :cond_7

    .line 188
    const/4 v4, 0x1

    iput v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mError:I

    .line 198
    .end local v0    # "adnErrorType":Lcom/android/internal/telephony/ADNErrorType;
    .end local v3    # "error_prefix":Ljava/lang/String;
    :cond_6
    :goto_5
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v4, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mLockHtcPbk:Ljava/lang/Object;

    invoke-virtual {v4}, Ljava/lang/Object;->notifyAll()V

    .line 199
    monitor-exit v5

    goto/16 :goto_0

    :catchall_4
    move-exception v4

    monitor-exit v5
    :try_end_7
    .catchall {:try_start_7 .. :try_end_7} :catchall_4

    throw v4

    .line 189
    .restart local v0    # "adnErrorType":Lcom/android/internal/telephony/ADNErrorType;
    .restart local v3    # "error_prefix":Ljava/lang/String;
    :cond_7
    :try_start_8
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    invoke-virtual {v4}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v4, v3}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v4

    if-eqz v4, :cond_8

    .line 190
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    invoke-virtual {v4}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v2

    .line 191
    .local v2, "error_message":Ljava/lang/String;
    const/4 v4, 0x4

    iput v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mError:I

    .line 192
    invoke-virtual {v3}, Ljava/lang/String;->length()I

    move-result v4

    invoke-virtual {v2, v4}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v4

    invoke-static {v4}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I

    move-result v4

    iput v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mError_type:I

    goto :goto_5

    .line 194
    .end local v2    # "error_message":Ljava/lang/String;
    :cond_8
    const/4 v4, 0x3

    iput v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mError:I
    :try_end_8
    .catchall {:try_start_8 .. :try_end_8} :catchall_4

    goto :goto_5

    .line 203
    .end local v0    # "adnErrorType":Lcom/android/internal/telephony/ADNErrorType;
    .end local v1    # "ar":Landroid/os/AsyncResult;
    .end local v3    # "error_prefix":Ljava/lang/String;
    :pswitch_6
    iget-object v1, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v1, Landroid/os/AsyncResult;

    .line 205
    .restart local v1    # "ar":Landroid/os/AsyncResult;
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v5, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mLockHtcPbk:Ljava/lang/Object;

    monitor-enter v5

    .line 206
    if-eqz v1, :cond_9

    :try_start_9
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    if-eqz v4, :cond_9

    .line 208
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    const-string v6, "Cannot update PBK entry"

    # invokes: Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->log(Ljava/lang/String;)V
    invoke-static {v4, v6}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->access$200(Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;Ljava/lang/String;)V

    .line 210
    iget-object v0, v1, Landroid/os/AsyncResult;->userObj:Ljava/lang/Object;

    check-cast v0, Lcom/android/internal/telephony/ADNErrorType;

    .line 211
    .restart local v0    # "adnErrorType":Lcom/android/internal/telephony/ADNErrorType;
    const/4 v4, 0x0

    iput-boolean v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mSuccess:Z

    .line 212
    const-string v3, "MemoryFull:"

    .line 213
    .restart local v3    # "error_prefix":Ljava/lang/String;
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    invoke-virtual {v4}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v4, v3}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v4

    if-eqz v4, :cond_a

    .line 214
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    invoke-virtual {v4}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v2

    .line 215
    .restart local v2    # "error_message":Ljava/lang/String;
    const/4 v4, 0x4

    iput v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mError:I

    .line 216
    invoke-virtual {v3}, Ljava/lang/String;->length()I

    move-result v4

    invoke-virtual {v2, v4}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v4

    invoke-static {v4}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I

    move-result v4

    iput v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mError_type:I

    .line 223
    .end local v0    # "adnErrorType":Lcom/android/internal/telephony/ADNErrorType;
    .end local v2    # "error_message":Ljava/lang/String;
    .end local v3    # "error_prefix":Ljava/lang/String;
    :cond_9
    :goto_6
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v4, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mLockHtcPbk:Ljava/lang/Object;

    invoke-virtual {v4}, Ljava/lang/Object;->notifyAll()V

    .line 224
    monitor-exit v5

    goto/16 :goto_0

    :catchall_5
    move-exception v4

    monitor-exit v5
    :try_end_9
    .catchall {:try_start_9 .. :try_end_9} :catchall_5

    throw v4

    .line 218
    .restart local v0    # "adnErrorType":Lcom/android/internal/telephony/ADNErrorType;
    .restart local v3    # "error_prefix":Ljava/lang/String;
    :cond_a
    const/4 v4, 0x3

    :try_start_a
    iput v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mError:I
    :try_end_a
    .catchall {:try_start_a .. :try_end_a} :catchall_5

    goto :goto_6

    .line 228
    .end local v0    # "adnErrorType":Lcom/android/internal/telephony/ADNErrorType;
    .end local v1    # "ar":Landroid/os/AsyncResult;
    .end local v3    # "error_prefix":Ljava/lang/String;
    :pswitch_7
    iget-object v1, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v1, Landroid/os/AsyncResult;

    .line 230
    .restart local v1    # "ar":Landroid/os/AsyncResult;
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v5, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mLockHtcPbk:Ljava/lang/Object;

    monitor-enter v5

    .line 231
    if-eqz v1, :cond_b

    :try_start_b
    iget-object v4, v1, Landroid/os/AsyncResult;->exception:Ljava/lang/Throwable;

    if-eqz v4, :cond_b

    .line 233
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    const-string v6, "Cannot delete PBK entry"

    # invokes: Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->log(Ljava/lang/String;)V
    invoke-static {v4, v6}, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->access$200(Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;Ljava/lang/String;)V

    .line 235
    iget-object v0, v1, Landroid/os/AsyncResult;->userObj:Ljava/lang/Object;

    check-cast v0, Lcom/android/internal/telephony/ADNErrorType;

    .line 236
    .restart local v0    # "adnErrorType":Lcom/android/internal/telephony/ADNErrorType;
    const/4 v4, 0x0

    iput-boolean v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mSuccess:Z

    .line 237
    const/4 v4, 0x3

    iput v4, v0, Lcom/android/internal/telephony/ADNErrorType;->mError:I

    .line 239
    .end local v0    # "adnErrorType":Lcom/android/internal/telephony/ADNErrorType;
    :cond_b
    iget-object v4, p0, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager$1;->this$0:Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;

    iget-object v4, v4, Lcom/android/internal/telephony/IccPhoneBookInterfaceManager;->mLockHtcPbk:Ljava/lang/Object;

    invoke-virtual {v4}, Ljava/lang/Object;->notifyAll()V

    .line 240
    monitor-exit v5

    goto/16 :goto_0

    :catchall_6
    move-exception v4

    monitor-exit v5
    :try_end_b
    .catchall {:try_start_b .. :try_end_b} :catchall_6

    throw v4

    .line 111
    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_1
        :pswitch_3
        :pswitch_2
        :pswitch_0
        :pswitch_0
        :pswitch_4
        :pswitch_5
        :pswitch_7
        :pswitch_6
    .end packed-switch
.end method


text:
export * from './decorators';
export * from './generator';
export * from './model';
export * from './rfp';
export * from './serialiserParser';
export * from './specVisitor';