text:
package org.vafer.jdeb.utils;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.tools.ant.filters.FixCrLfFilter;
import org.apache.tools.ant.util.ReaderInputStream;

/**
 * Simple utils functions.
 *
 * ATTENTION: don't use outside of jdeb
 */
public final class Utils {
    private static final Pattern BETA_PATTERN = Pattern.compile("^(?:(?:(.*?)([.\\-_]))|(.*[^a-z]))(alpha|a|beta|b|milestone|m|cr|rc)([^a-z].*)?$", Pattern.CASE_INSENSITIVE);

    private static final Pattern SNAPSHOT_PATTERN = Pattern.compile("(.*)[\\-+]SNAPSHOT");

    public static int copy( final InputStream pInput, final OutputStream pOutput ) throws IOException {
        final byte[] buffer = new byte[2048];
        int count = 0;
        int n;
        while (-1 != (n = pInput.read(buffer))) {
            pOutput.write(buffer, 0, n);
            count += n;
        }
        return count;
    }

    public static String toHex( final byte[] bytes ) {
        final StringBuilder sb = new StringBuilder();

        for (byte b : bytes) {
            sb.append(Integer.toHexString((b >> 4) & 0x0f));
            sb.append(Integer.toHexString(b & 0x0f));
        }

        return sb.toString();
    }

    public static String stripPath( final int p, final String s ) {

        if (p <= 0) {
            return s;
        }

        int x = 0;
        for (int i = 0; i < p; i++) {
            x = s.indexOf('/', x + 1);
            if (x < 0) {
                return s;
            }
        }

        return s.substring(x + 1);
    }

    private static String joinPath(char sep, String ...paths) {
        final StringBuilder sb = new StringBuilder();
        for (String p : paths) {
            if (p == null) continue;
            if (!p.startsWith("/") && sb.length() > 0) {
                sb.append(sep);
            }
            sb.append(p);
        }
        return sb.toString();
    }

    public static String joinUnixPath(String ...paths) {
        return joinPath('/', paths);
    }

    public static String joinLocalPath(String ...paths) {
        return joinPath(File.separatorChar, paths);
    }

    public static String stripLeadingSlash( final String s ) {
        if (s == null) {
            return s;
        }
        if (s.length() == 0) {
            return s;
        }
        if (s.charAt(0) == '/' || s.charAt(0) == '\\') {
            return s.substring(1);
        }
        return s;
    }

    /**
     * Substitute the variables in the given expression with the
     * values from the resolver
     *
     * @param pResolver
     * @param pExpression
     */
    public static String replaceVariables( final VariableResolver pResolver, final String pExpression, final String pOpen, final String pClose ) {
        final char[] open = pOpen.toCharArray();
        final char[] close = pClose.toCharArray();

        final StringBuilder out = new StringBuilder();
        StringBuilder sb = new StringBuilder();
        char[] last = null;
        int wo = 0;
        int wc = 0;
        int level = 0;
        for (char c : pExpression.toCharArray()) {
            if (c == open[wo]) {
                if (wc > 0) {
                    sb.append(close, 0, wc);
                }
                wc = 0;
                wo++;
                if (open.length == wo) {
                    // found open
                    if (last == open) {
                        out.append(open);
                    }
                    level++;
                    out.append(sb);
                    sb = new StringBuilder();
                    wo = 0;
                    last = open;
                }
            } else if (c == close[wc]) {
                if (wo > 0) {
                    sb.append(open, 0, wo);
                }
                wo = 0;
                wc++;
                if (close.length == wc) {
                    // found close
                    if (last == open) {
                        final String variable = pResolver.get(sb.toString());
                        if (variable != null) {
                            out.append(variable);
                        } else {
                            out.append(open);
                            out.append(sb);
                            out.append(close);
                        }
                    } else {
                        out.append(sb);
                        out.append(close);
                    }
                    sb = new StringBuilder();
                    level--;
                    wc = 0;
                    last = close;
                }
            } else {

                if (wo > 0) {
                    sb.append(open, 0, wo);
                }

                if (wc > 0) {
                    sb.append(close, 0, wc);
                }

                sb.append(c);

                wo = wc = 0;
            }
        }

        if (wo > 0) {
            sb.append(open, 0, wo);
        }

        if (wc > 0) {
            sb.append(close, 0, wc);
        }

        if (level > 0) {
            out.append(open);
        }
        out.append(sb);

        return out.toString();
    }

    /**
     * Replaces new line delimiters in the input stream with the Unix line feed.
     *
     * @param input
     */
    public static byte[] toUnixLineEndings( InputStream input ) throws IOException {
        String encoding = "ISO-8859-1";
        FixCrLfFilter filter = new FixCrLfFilter(new InputStreamReader(input, encoding));
        filter.setEol(FixCrLfFilter.CrLf.newInstance("unix"));

        ByteArrayOutputStream filteredFile = new ByteArrayOutputStream();
        Utils.copy(new ReaderInputStream(filter, encoding), filteredFile);

        return filteredFile.toByteArray();
    }

    private static String formatSnapshotTemplate( String template, Date timestamp ) {
        int startBracket = template.indexOf('[');
        int endBracket = template.indexOf(']');
        if(startBracket == -1 || endBracket == -1) {
            return template;
        } else {
            // prefix[yyMMdd]suffix
            final String date = new SimpleDateFormat(template.substring(startBracket + 1, endBracket)).format(timestamp);
            String datePrefix = startBracket == 0 ? "" : template.substring(0, startBracket);
            String dateSuffix = endBracket == template.length() ? "" : template.substring(endBracket + 1);
            return datePrefix + date + dateSuffix;
        }
    }

    /**
     * Convert the project version to a version suitable for a Debian package.
     * -SNAPSHOT suffixes are replaced with a timestamp (~yyyyMMddHHmmss).
     * The separator before a rc, alpha or beta version is replaced with '~'
     * such that the version is always ordered before the final or GA release.
     *
     * @param version the project version to convert to a Debian package version
     * @param template the template used to replace -SNAPSHOT, the timestamp format is in brackets,
     *        the rest of the string is preserved (prefix[yyMMdd]suffix -> prefix151230suffix)
     * @param timestamp the UTC date used as the timestamp to replace the SNAPSHOT suffix.
     */
    public static String convertToDebianVersion( String version, boolean apply, String envName, String template, Date timestamp ) {
        Matcher matcher = SNAPSHOT_PATTERN.matcher(version);
        if (matcher.matches()) {
            version = matcher.group(1) + "~";

            if (apply) {
                final String envValue = System.getenv(envName);
                if(template != null && template.length() > 0) {
                    version += formatSnapshotTemplate(template, timestamp);
                } else if (envValue != null && envValue.length() > 0) {
                    version += envValue;
                } else {
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
                    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                    version += dateFormat.format(timestamp);
                }
            } else {
                version += "SNAPSHOT";
            }
        } else {
            matcher = BETA_PATTERN.matcher(version);
            if (matcher.matches()) {
                if (matcher.group(1) != null) {
                    version = matcher.group(1) + "~" + matcher.group(4) + matcher.group(5);
                } else {
                    version = matcher.group(3) + "~" + matcher.group(4) + matcher.group(5);
                }
            }
        }

        // safest upstream_version should only contain full stop, plus, tilde, and alphanumerics
        // https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
        version = version.replaceAll("[^.+~A-Za-z0-9]", "+").replaceAll("\\++", "+");

        return version;
    }

    /**
     * Construct new path by replacing file directory part. No
     * files are actually modified.
     * @param file path to move
     * @param target new path directory
     */
    public static String movePath( final String file,
                                   final String target ) {
        final String name = new File(file).getName();
        return target.endsWith("/") ? target + name : target + '/' + name;
    }

    /**
     * Extracts value from map if given value is null.
     * @param value current value
     * @param props properties to extract value from
     * @param key property name to extract
     * @return initial value or value extracted from map
     */
    public static String lookupIfEmpty( final String value,
                                        final Map<String, String> props,
                                        final String key ) {
        return value != null ? value : props.get(key);
    }

    /**
    * Get the known locations where the secure keyring can be located.
    * Looks through known locations of the GNU PG secure keyring.
    *
    * @return The location of the PGP secure keyring if it was found,
    *         null otherwise
    */
    public static Collection<String> getKnownPGPSecureRingLocations() {
        final LinkedHashSet<String> locations = new LinkedHashSet<>();

        final String os = System.getProperty("os.name");
        final boolean runOnWindows = os == null || os.toLowerCase().contains("win");

        if (runOnWindows) {
            // The user's roaming profile on Windows, via environment
            final String windowsRoaming = System.getenv("APPDATA");
            if (windowsRoaming != null) {
                locations.add(joinLocalPath(windowsRoaming, "gnupg", "secring.gpg"));
            }

            // The user's local profile on Windows, via environment
            final String windowsLocal = System.getenv("LOCALAPPDATA");
            if (windowsLocal != null) {
                locations.add(joinLocalPath(windowsLocal, "gnupg", "secring.gpg"));
            }

            // The Windows installation directory
            final String windir = System.getProperty("WINDIR");
            if (windir != null) {
                // Local Profile on Windows 98 and ME
                locations.add(joinLocalPath(windir, "Application Data", "gnupg", "secring.gpg"));
            }
        }

        final String home = System.getProperty("user.home");

        if (home != null && runOnWindows) {
            // These are for various flavours of Windows
            // if the environment variables above have failed

            // Roaming profile on Vista and later
            locations.add(joinLocalPath(home, "AppData", "Roaming", "gnupg", "secring.gpg"));
            // Local profile on Vista and later
            locations.add(joinLocalPath(home, "AppData", "Local", "gnupg", "secring.gpg"));
            // Roaming profile on 2000 and XP
            locations.add(joinLocalPath(home, "Application Data", "gnupg", "secring.gpg"));
            // Local profile on 2000 and XP
            locations.add(joinLocalPath(home, "Local Settings", "Application Data", "gnupg", "secring.gpg"));
        }

        // *nix, including OS X
        if (home != null) {
            locations.add(joinLocalPath(home, ".gnupg", "secring.gpg"));
        }

        return locations;
    }

    /**
     * Tries to guess location of the user secure keyring using various
     * heuristics.
     *
     * @return path to the keyring file
     * @throws FileNotFoundException if no keyring file found
     */
    public static File guessKeyRingFile() throws FileNotFoundException {
        final Collection<String> possibleLocations = getKnownPGPSecureRingLocations();
        for (final String location : possibleLocations) {
            final File candidate = new File(location);
            if (candidate.exists()) {
                return candidate;
            }
        }
        final StringBuilder message = new StringBuilder("Could not locate secure keyring, locations tried: ");
        final Iterator<String> it = possibleLocations.iterator();
        while (it.hasNext()) {
            message.append(it.next());
            if (it.hasNext()) {
                message.append(", ");
            }
        }
        throw new FileNotFoundException(message.toString());
    }

    /**
     * Returns true if string is null or empty.
     */
    public static boolean isNullOrEmpty(final String str) {
        return str == null || str.length() == 0;
    }

    /**
    * Return fallback if first string is null or empty
    */
    public static String defaultString(final String str, final String fallback) {
        return isNullOrEmpty(str) ? fallback : str;
    }

    /**
     * Check if a CharSequence is whitespace, empty ("") or null.
     *
     * <pre>
     * StringUtils.isBlank(null)      = true
     * StringUtils.isBlank("")        = true
     * StringUtils.isBlank(" ")       = true
     * StringUtils.isBlank("bob")     = false
     * StringUtils.isBlank("  bob  ") = false
     * </pre>
     *
     * @param cs
     *            the CharSequence to check, may be null
     * @return {@code true} if the CharSequence is null, empty or whitespace
     */
    public static boolean isBlank(final CharSequence cs) {
        int strLen;
        if (cs == null || (strLen = cs.length()) == 0) {
            return true;
        }
        for (int i = 0; i < strLen; i++) {
            if (!Character.isWhitespace(cs.charAt(i))) {
                return false;
            }
        }
        return true;
    }
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>inat_stats module — Nitro  documentation</title>

    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />

    <link rel="top" title="Nitro  documentation" href="index.html" />
    <link rel="up" title="network package" href="nssrc.com.citrix.netscaler.nitro.resource.stat.network.html" />
    <link rel="next" title="inatsession_stats module" href="nssrc.com.citrix.netscaler.nitro.resource.stat.network.inatsession_stats.html" />
    <link rel="prev" title="bridge_stats module" href="nssrc.com.citrix.netscaler.nitro.resource.stat.network.bridge_stats.html" />

Navigation

          index

          next |

          previous |

Nitro  documentation »

config package »

network package »

inat_stats module¶

class <tt class="descname">inat_stats</tt>¶

Bases: <tt class="xref py py-class docutils literal">nssrc.com.citrix.netscaler.nitro.resource.base.base_resource.base_resource</tt>

Statistics for inbound nat resource.

<tt class="descname">name</tt>¶

The INAT.<br/>Minimum length =  1.

<tt class="descname">clearstats</tt>¶

Clear the statsistics / counters.<br/>Possible values = basic, full.

<tt class="descname">nat46udp64rate</tt>¶

Rate (/s) counter for nat46totudp64.

<tt class="descname">nat46totdrop64</tt>¶

Total IPV6 packets dropped.

<tt class="descname">nat46totudp46</tt>¶

Total UDP packets translated (V4->v6).

<tt class="descname">nat46icmp64rate</tt>¶

Rate (/s) counter for nat46toticmp64.

<tt class="descname">inatnat46tcp46</tt>¶

TCP packets translated (V4->v6).

<tt class="descname">nat46totdrop46</tt>¶

Total IPV4 packets dropped.

<tt class="descname">inatnat46tcp64</tt>¶

TCP packets translated (V6->v4).

<tt class="descname">inatnat46drop46</tt>¶

IPV4 packets dropped.

<tt class="descname">inatnat46drop64</tt>¶

IPV6 packets dropped.

<tt class="descname">inatnat46udp46</tt>¶

UDP packets translated (V4->v6).

<tt class="descname">nat46tottcp64</tt>¶

Total TCP packets translated (V6->v4).

<tt class="descname">nat46drop46rate</tt>¶

Rate (/s) counter for nat46totdrop46.

<tt class="descname">inatnat46drop46rate</tt>¶

Rate (/s) counter for inatnat46drop46.

<tt class="descname">inatnat46tcp64rate</tt>¶

Rate (/s) counter for inatnat46tcp64.

<tt class="descname">inatnat46icmp64</tt>¶

ICMP packets translated (V6->v4).

<tt class="descname">nat46drop64rate</tt>¶

Rate (/s) counter for nat46totdrop64.

<tt class="descname">inatnat46tcp46rate</tt>¶

Rate (/s) counter for inatnat46tcp46.

<tt class="descname">nat46tottcp46</tt>¶

Total TCP packets translated (V4->v6).

<tt class="descname">nat46toticmp46</tt>¶

Total ICMP packets translated (V4->v6).

<tt class="descname">inatnat46icmp46rate</tt>¶

Rate (/s) counter for inatnat46icmp46.

<tt class="descname">inatnat46udp64</tt>¶

UDP packets translated (V6->v4).

<tt class="descname">nat46tcp46rate</tt>¶

Rate (/s) counter for nat46tottcp46.

<tt class="descname">inatnat46drop64rate</tt>¶

Rate (/s) counter for inatnat46drop64.

<tt class="descname">inatnat46udp64rate</tt>¶

Rate (/s) counter for inatnat46udp64.

<tt class="descname">nat46icmp46rate</tt>¶

Rate (/s) counter for nat46toticmp46.

<tt class="descname">inatnat46icmp46</tt>¶

ICMP packets translated (V4->v6).

<tt class="descname">inatnat46icmp64rate</tt>¶

Rate (/s) counter for inatnat46icmp64.

<tt class="descname">nat46tcp64rate</tt>¶

Rate (/s) counter for nat46tottcp64.

<tt class="descname">nat46totudp64</tt>¶

Total UDP packets translated (V6->v4).

<tt class="descname">nat46udp46rate</tt>¶

Rate (/s) counter for nat46totudp46.

<tt class="descname">nat46toticmp64</tt>¶

Total ICMP packets translated (V6->v4).

<tt class="descname">inatnat46udp46rate</tt>¶

Rate (/s) counter for inatnat46udp46.

classmethod <tt class="descname">get</tt><big>(</big>service, name='', option_=''<big>)</big>¶

Use this API to fetch the statistics of all inat_stats resources that are configured on netscaler.

class <tt class="descname">Clearstats</tt>¶

<tt class="descname">basic</tt> = 'basic'¶

<tt class="descname">full</tt> = 'full'¶

class <tt class="descname">inat_response</tt><big>(</big>length=1<big>)</big>¶

Bases: <tt class="xref py py-class docutils literal">nssrc.com.citrix.netscaler.nitro.resource.base.base_response.base_response</tt>

Nitro exception Package

Base Package

Service Package

Util Package

Config Package

Stat Package

aaa

appflow

appfw

appqoe

audit

authentication

authorization

autoscale

basic

ca

cache

cluster

cmp

cr

cs

dns

dos

feo

gslb

ha

ipsec

lb

lldp

network

Interface_stats

bridge_stats

inat_stats

inatsession_stats

nat64_stats

rnat_stats

rnatip_stats

tunnelip6_stats

tunnelip_stats

vlan_stats

vpath_stats

vxlan_stats

ns

pq

protocol

qos

responder

rewrite

sc

snmp

spillover

ssl

stream

system

tm

transform

vpn

Previous topic

bridge_stats module

Next topic

inatsession_stats module

This Page

Show Source

Quick search

    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>

    Enter search terms or a module, class or function name.

        © Copyright © 1999-2014 Citrix Systems, Inc. All Rights Reserved.
      Created using Sphinx 1.2.

redpajama_set_name: RedPajamaGithub


text:
This guide explains the elements of a JSON document representing a *request test definition*. A request test definition lists
test case inputs for all of the API requests defined in an OpenAPI v3 definition. You can generate the request test
definition for an OpenAPI definition by running Tcases for OpenAPI with [options for input
resolution](Running-Api-Test-Cases.md#generating-request-inputs).

The JSON schema for a request test definition document is located at
[http://www.cornutum.org/tcases/request-cases-schema.json](http://www.cornutum.org/tcases/request-cases-schema.json).

Note: Required fields are designated by the :registered: symbol. All other fields are optional.

## `RequestTestDef` ##

A request test definition is an array of [`RequestCase`](#requestcase) objects that lists the test cases for all API requests.

## `RequestCase` ##

A `RequestCase` object defines the inputs for a test case that invokes a specific API request.

| Field         | Type |                    | Description |
| ---           | ---  | ---                | ---         |
| id            | integer | :registered:    | An id number that uniquely identifies this test case among all tests for the given path and operation |
| path          | string | :registered:     | The request path |
| operation     | string | :registered:     | The HTTP operation for this request |
| api           | string | :registered:     | The title of the API that defines this request |
| name          | string |                  | A descriptive name for this test case |
| server        | string |                  | The API server URL |
| version       | string |                  | The version of the OpenAPI definition that defines this request |
| parameters    | \[[`ParamData`](#paramdata)\] |     | The parameter values for this request |
| body          | [`MessageData`](#messagedata) |   | The body value for this request |
| auth          |\[[`AuthDef`](#authDef)\] |   | The authentication inputs required to authorize this request |
| invalidInput  | string |                  | If defined, a failure response is expected for this request and this string describes the invalid input |
| authFailure   | boolean |                 | If true, an authorization failure is expected for this request |

## `ParamData` ##

A `ParamData` object specifies the name, value, and encoding of a request parameter. A `ParamData` object is the same as a `MessageData` object,
with the following additional fields.

| Field         | Type |                            | Description |
| ---           | ---  | ---                        | ---         |
| name          | string  | :registered:            | The name of this parameter |
| in            | string | :registered:             | The location of this parameter |
| style         | string | :registered:             | Defines how this parameter value will be serialized |
| explode       | boolean             |             | For parameters of type array or object, specifies if elements will be serialized in exploded form |

## `MessageData` ##

A `MessageData` object specifies the value and encoding of a request input data item.

| Field         | Type |                            | Description |
| ---           | ---  | ---                        | ---         |
| data          | [`DataValue`](#datavalue) | :registered:    | Defines the value of this data item |
| valid         | boolean | :registered:            | Defines if the value for this data item is valid or invalid (i.e. failure response expected) |
| mediaType     | string |                          | The media type used to represent the value of this data item |
| encodings     | [`Encodings`](#encodings) | | When `mediaType` is `application/x-www-form-urlencoded` or `multipart/form-data`, maps each `data` object property to its encoding settings |

## `DataValue` ##

A `DataValue` object specifies the type, format, and value of a request input data item.

| Field         | Type |                    | Description |
| ---           | ---  | ---                | ---         |
| type          | string  | :registered:    | The type of this data value |
| value         | JSON value | :registered: | The JSON representation of this data value |
| format        | string |                  | The format of this data value |

## `Encodings` ##

An `Encodings` object maps each `MessageData` object property to its encoding settings. Specified only for `MessageData` with
`application/x-www-form-urlencoded` or `multipart/form-data` media type.

| Field         | Type |                    | Description |
| ---           | ---  | ---                | ---         |
| *(propertyName)* | [`EncodingData`](#encodingdata) | | The encoding settings for this `MessageData` object property |

## `EncodingData` ##

An `EncodingData` object defines the encoding settings for a `MessageData` object property.

| Field         | Type |                    | Description |
| ---           | ---  | ---                | ---         |
| style | string | | For a property of an `application/x-www-form-urlencoded` object, defines how this property value will be serialized |
| explode | boolean | | For a property of an `application/x-www-form-urlencoded` object, specifies if this property value will be serialized in exploded form |
| contentType | string | | For a property of a `multipart/form-data` object, specifies the media type for this form part |
| headers | \[[`HeaderData`](#headerdata)\] | | For a property of a `multipart/form-data` object, specifies the headers for this form part |

## `HeaderData` ##

A `HeaderData` object specifies the name, value, and encoding of a request header. A `HeaderData` object is the same as a `MessageData` object,
with the following additional fields.

| Field         | Type |                            | Description |
| ---           | ---  | ---                        | ---         |
| name          | string  | :registered:            | The name of this header |
| explode       | boolean             |             | For headers of type array or object, specifies if elements will be serialized in exploded form |

## `AuthDef` ##

An `AuthDef` object describes a required authentication input: one of [`ApiKeyDef`](#apiKeyDef), [`HttpBasicDef`](#httpBasicDef), or [`HttpBearerDef`](#httpBearerDef).

## `ApiKeyDef` ##

An `ApiKeyDef` object specifies that an API key is required to authorize the request.

| Field         | Type |                            | Description |
| ---           | ---  | ---                        | ---         |
| type          | string  | :registered:            | "apiKey" |
| location      | string | :registered:             | The location of the key value |
| name          | string | :registered:             | The name of this key value |

## `HttpBasicDef` ##

An `HttpBasicDef` object specifies that an HTTP Basic authorization header is required.

| Field         | Type |                            | Description |
| ---           | ---  | ---                        | ---         |
| type          | string | :registered:             | "http" |
| scheme        | string | :registered:             | "basic" |

## `HttpBearerDef` ##

An `HttpBearerDef` object specifies that an HTTP Bearer authorization header is required.

| Field         | Type |                            | Description |
| ---           | ---  | ---                        | ---         |
| type          | string | :registered:             | "http" |
| scheme        | string | :registered:             | "bearer" |


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<parent>
		<groupId>com.bbva.kltt.apirest</groupId>
		<artifactId>parent</artifactId>
		<version>2.1.0</version>
		<relativePath>../parent/pom.xml</relativePath>
	</parent>
	<modelVersion>4.0.0</modelVersion>

	<artifactId>generator.server.jaxrs</artifactId>
	<name>generator.server.jaxrs</name>
	<version>2.0.3</version>

	<licenses>
		<license>
			<name>The Apache Software License, Version 2.0</name>
			<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
		</license>
	</licenses>

	<build>
		<resources>
			<resource>
				<directory>projectInfo</directory>
				<filtering>true</filtering>
			</resource>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
		</resources>
	</build>

	<dependencies>
		<dependency>
			<groupId>com.bbva.kltt.apirest</groupId>
			<artifactId>generator.java</artifactId>
			<version>2.1.2</version>
		</dependency>

		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>com.bbva.kltt.apirest</groupId>
			<artifactId>parser.swagger</artifactId>
			<version>2.0.2</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

</project>


text:
require 'bank_job/strategy'

module BankJob
  module Strategy
    class Yucho
      include BankJob::Strategy

      LOGIN_URL = 'https://direct.jp-bank.japanpost.jp/tp1web/U010101SCK.do'

      QUESTION_PATHS = %w(U330102SCR U330202SCR)
      PASSWORD_PATH  = 'U010902SCR'
      MENU_PATH      = 'U030105SCR'

      DETAIL_IGNORE_KEYWORDS = %w(通帳の現在高 通帳未記入金合計)
      DETAIL_TABLE_COLUMNS = [:date, :deposit, :draw, :subject, :balance].freeze

      def details
        cols = detail_page.root.
          xpath('//table[@class="infocell nbsp10 tablelayoutauto"]').
          first.css('tr')
        [].tap do |details|
          cols.each do |col|
            next if ignore_column?(col)
            details << detail(col)
          end
        end
      end

      def deposit
        details.last.balance
      end

      def deposits
        deposit
      end

      private

      def detail_page
        return @detail_page if @detail_page
        page = detail_menu_page
        form = page.form_with(name: 'submitData')
        form.radiobutton_with(value: '03', name: 'shoukaiTaishouSentaku').check
        @detail_page = submit_with(page, '次へ')
      end

      def detail_menu_page
        menu_page = login
        submit_with(menu_page, '入出金明細照会')
      end

      def login
        page = agent.get(LOGIN_URL)
        input_number(page)
        page = submit_with(page, '次へ')

        loop do
          case form_path(page)
          when *QUESTION_PATHS
            page = answer_question(page)
          when PASSWORD_PATH
            page = input_password(page)
          when MENU_PATH
            break
          else
            raise "Login failed"
          end
          sleep(0.3)
        end
        page
      end

      def form_path(page)
        page.uri.to_s.match(/tp1web\/([^\.]*)\.do/)[1]
      end

      def answer_question(page)
        asked_question = get_question(page)
        prepared_question = @questions.select { |secret_question|
          secret_question[:question] == asked_question
        }.first

        if prepared_question
          form = page.form_with(name: 'submitData')
          form['aikotoba'] = prepared_question[:answer]

          next_page = submit_with(page, '次へ')
          if QUESTION_PATHS.include?(form_path(next_page))
            next_question = get_question(next_page)
            if asked_question == next_question
              raise "Wrong answer for the question '#{asked_question}'"
            end
          end
        else
          raise "Unexpected question '#{asked_question}'"
        end
        next_page
      end

      def get_question(page)
        page.root.xpath('//*[@class="loginbox nbsp5"]//span[1]').first.text
      end

      def input_number(page)
        form = page.form_with(name: 'submitData')
        login_number = @number.tr('-', '')
        raise 'Invalid login number' if login_number.length < 13

        form['okyakusamaBangou1'] = login_number[0..3]
        form['okyakusamaBangou2'] = login_number[4..7]
        form['okyakusamaBangou3'] = login_number[8..12]
      end

      def input_password(page)
        form = page.form_with(name: 'submitData')
        form['loginPassword'] = @pin
        submit_with(page, 'ログイン').tap do |next_page|
          raise 'Wrong password' if form_path(next_page) == PASSWORD_PATH
        end
      end

      def submit_with(page, button_name)
        form = page.form_with(name: 'submitData')
        button_element = page.search("//input[contains(@value, '#{button_name}')]").first
        onclick = button_element.attr('onclick')

        form.action = onclick.match(/dcRequest\('[^']*','([^']*)'/)[1]
        form['event'] = onclick.match(/Array\('([^']*)'\),false/)[1]
        form.submit
      end

      def ignore_column?(col)
        return true if col.css('td').count < 5
        subject = col.css('td')[DETAIL_TABLE_COLUMNS.index(:subject)].text
        DETAIL_IGNORE_KEYWORDS.each do |ignore_keyword|
          return true if subject.include?(ignore_keyword)
        end
        false
      end

      def detail(col)
        tds = col.css('td')
        Hashie::Mash.new.tap do |detail|
          DETAIL_TABLE_COLUMNS.each_with_index do |name, column|
            detail[name] = tds[column].text
          end
        end
      end
    end
  end
end


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Subject_T
{
    class Program
    {
        static void Main(string[] args)
        {
            // observableの作成.
            var observable = new CustomObservable();    // CustomObservableオブジェクトobservableの作成.

            // オブザーバー登録.
            var subscriber1 = observable.Subscribe(str => Console.WriteLine("OnNext[1]:" + str), ex => Console.WriteLine("OnError[1]:" + ex.Message), () => Console.WriteLine("OnCompleted[1]"));  // strを出力するアクションを登録.
            var subscriber2 = observable.Subscribe(str => Console.WriteLine("OnNext[2]:" + str), ex => Console.WriteLine("OnError[2]:" + ex.Message), () => Console.WriteLine("OnCompleted[2]"));  // strを出力するアクションを登録.

            // 実行.
            observable.Execute("ABC");  // "ABC"を渡して実行.
        }
    }
}


text:
/**
 * @module ngeo location search namespace
 */
goog.provide('ngeo.search.createLocationSearchBloodhound');

goog.require('ol.obj');
goog.require('ol.proj');
/** @suppress {extraRequire} */
goog.require('ngeo.proj.EPSG21781');
goog.require('ol.geom.Point');
goog.require('ol.Feature');

/**
 * Provides a function that creates a Bloodhound engine
 * for the GeoAdmin Location Search API, which creates `ol.Feature` objects
 * as suggestions.
 *
 * See: http://api3.geo.admin.ch/services/sdiservices.html#search
 *
 * Example:
 *
 *     var bloodhound = ngeoCreateLocationSearchBloodhound({
 *       targetProjection: ol.proj.get('EPSG:3857'),
 *       limit: 10
 *     });
 *     bloodhound.initialize();
 *
 * @typedef {function(ngeox.search.LocationSearchOptions=):Bloodhound}
 * @ngdoc service
 * @ngname search.createLocationSearchBloodhound
 */
ngeo.search.CreateLocationSearchBloodhound;

/**
 * @param {ngeox.search.LocationSearchOptions=} opt_options Options.
 * @return {Bloodhound} The Bloodhound object.
 */
ngeo.search.createLocationSearchBloodhound = function(opt_options) {
  var options = opt_options || {};

  var sourceProjection = ol.proj.get('EPSG:21781');
  var targetProjection = options.targetProjection;

  /**
   * @param {string} bbox Bbox string.
   * @return {?ol.Extent} Parsed extent.
   */
  var parseBbox = function(bbox) {
    var regex = /BOX\((.*?) (.*?),(.*?) (.*?)\)/g;
    var match = regex.exec(bbox);
    if (match !== null) {
      return [
        parseFloat(match[1]),
        parseFloat(match[2]),
        parseFloat(match[3]),
        parseFloat(match[4])
      ];
    } else {
      return null;
    }
  };

  var removeHtmlTags = function(label) {
    return label.replace(/<\/?[ib]>/g, '');
  };

  var extractName = function(label) {
    var regex = /<b>(.*?)<\/b>/g;
    var match = regex.exec(label);
    if (match !== null) {
      return match[1];
    } else {
      return label;
    }
  };

  var bloodhoundOptions = /** @type {BloodhoundOptions} */ ({
    remote: {
      url: 'https://api3.geo.admin.ch/rest/services/api/SearchServer?type=locations&searchText=%QUERY',
      prepare: function(query, settings) {
        settings.url = settings.url.replace('%QUERY', query);
        if (options.limit !== undefined) {
          settings.url += '&limit=' + options.limit;
        }
        if (options.origins !== undefined) {
          settings.url += '&origins=' + options.origins;
        }

        return (options.prepare !== undefined) ?
            options.prepare(query, settings) : settings;
      },
      transform: function(/** @type{geoAdminx.SearchLocationResponse} */ parsedResponse) {
        var features = parsedResponse.results.map(function(/** @type{geoAdminx.SearchLocationResult} */ result) {
          var attrs = result.attrs;

          // note that x and y are switched!
          var point = new ol.geom.Point([attrs.y, attrs.x]);
          var bbox = parseBbox(attrs.geom_st_box2d);
          if (targetProjection !== undefined) {
            point.transform(sourceProjection, targetProjection);
            if (bbox !== null) {
              bbox = ol.proj.transformExtent(bbox, sourceProjection, targetProjection);
            }
          }

          attrs['geometry'] = point;
          attrs['bbox'] = bbox;

          // create a label without HTML tags
          var label = attrs.label;
          attrs['label_no_html'] = removeHtmlTags(label);
          attrs['label_simple'] = extractName(label);

          var feature = new ol.Feature(attrs);
          feature.setId(attrs.featureId);

          return feature;
        });

        return features;
      }
    },
    // datumTokenizer is required by the Bloodhound constructor but it
    // is not used when only a remote is passsed to Bloodhound.
    datumTokenizer: ol.nullFunction,
    queryTokenizer: Bloodhound.tokenizers.whitespace
  });

  // the options objects are cloned to avoid updating the passed object
  var bhOptions = ol.obj.assign({}, options.options || {});
  var remoteOptions = ol.obj.assign({}, options.remoteOptions || {});

  if (bhOptions.remote) {
    // move the remote options to opt_remoteOptions
    ol.obj.assign(remoteOptions, bhOptions.remote);
    delete bhOptions.remote;
  }

  ol.obj.assign(bloodhoundOptions, bhOptions);
  ol.obj.assign(bloodhoundOptions.remote, remoteOptions);

  return new Bloodhound(bloodhoundOptions);
};

/**
 * @type {!angular.Module}
 */
ngeo.search.createLocationSearchBloodhound.module = angular.module('ngeoCreateLocationSearchBloodhound', []);

ngeo.search.createLocationSearchBloodhound.module.value(
  'ngeoCreateLocationSearchBloodhound',
  ngeo.search.createLocationSearchBloodhound);


text:
Welcome to the Kubernetes Community contributing guide. We are excited about the prospect of you joining our [community](https://github.com/kubernetes/community)!

## Getting Started

We have full documentation on how to get started contributing here:

- [Kubernetes Contributor Guide](http://git.k8s.io/community/contributors/guide) - Main contributor documentation
- [Contributor Cheat Sheet](./contributors/guide/contributor-cheatsheet/) - Common resources for existing developers

## Mentorship

- [Mentoring Initiatives](https://git.k8s.io/community/mentoring)  - We have a diverse set of mentorship programs available that are always looking for volunteers!

## Contributing to Individual SIGs

Each SIG may or may not have it's own policies for editing their section of this repository.

Edits in SIG sub-directories should follow any additional guidelines described
by the respective SIG leads in the sub-directory's `CONTRIBUTING` file
(e.g. [sig-cli/CONTRIBUTING](sig-cli/CONTRIBUTING.md)).

Attending a [SIG meeting](/sig-list.md) or posting on their mailing list might be prudent if you want to make extensive contributions.


text:
package com.lab.epam.service;

import com.lab.epam.dao.PersistException;
import com.lab.epam.dao.imp.MySqlCategoryDao;
import com.lab.epam.dao.imp.MySqlStatusDao;
import com.lab.epam.entity.Category;
import com.lab.epam.entity.Status;

import java.util.List;

/**
 * Created by Admin on 11.06.2015.
 */
public class StatusService {

    MySqlStatusDao mySqlStatusDao = new MySqlStatusDao();

    public void create(Status object) throws PersistException {
        mySqlStatusDao.create(object);
    }

    public Status getByPK(Integer key) throws PersistException{
        return mySqlStatusDao.getByPK(key);
    }

    public void update(Status object) throws PersistException{
        mySqlStatusDao.update(object);
    }

    public void delete(Status object) throws PersistException{
        mySqlStatusDao.delete(object);
    }

    public List<Status> getAll() throws PersistException{
        return mySqlStatusDao.getAll();
    }

    public List<Status> getAllWithoutDeleted() throws PersistException{
        return mySqlStatusDao.getAllWithoutDeleted();
    }

}


text:
Cordova iOS - step 4
====================
Tweaking the WebView

## Take control!
- In Xcode open `<YourAppName>/Main.storyboard`
- Select the ViewController in the `Second scene` again and change the `Custom class` back from `CDVViewController` to `SecondViewController`
- Now open `SecondViewController.h` and make the class implement `CDVViewController` instead of `UIViewController`
- You'll need to add an import to make everything compile correctly again: `#import <Cordova/CDVViewController.h>`

Run the app and you shouldn't see anything different than the previous step, but this change gives us more control over how the webview is embedded, read on..

## Fixing the WebView height
To accomodate for the native tab bar we'll shrink the WebView a bit:

- Open `SecondViewController.m` and add this method:

```objective-c
- (void)viewWillAppear:(BOOL)animated
{
  CGRect viewBounds = self.view.bounds;
  CGFloat tabBarHeight = self.tabBarController.tabBar.frame.size.height;
  CGRect webViewBounds = CGRectMake(viewBounds.origin.x,
                                    viewBounds.origin.y,
                                    viewBounds.size.width,
                                    viewBounds.size.height - tabBarHeight);

  self.webView.frame = webViewBounds;
  self.webView.backgroundColor = [UIColor clearColor];

  [super viewWillAppear:animated];
}
```

## Check the result
Run the app, select the second tab, and scroll down - you should now see this:

![ScreenShot](result.png)


text:
CFX_ThreadLock::CFX_ThreadLock() {
}
CFX_ThreadLock::~CFX_ThreadLock() {}
void CFX_ThreadLock::Lock() {}
void CFX_ThreadLock::Unlock() {}
class FX_BASEARRAYDATA : public CFX_Target {
 public:
  FX_BASEARRAYDATA(int32_t growsize, int32_t blocksize)
      : iGrowSize(growsize),
        iBlockSize(blocksize),
        iTotalCount(0),
        iBlockCount(0),
        pBuffer(nullptr) {}

  ~FX_BASEARRAYDATA() { FX_Free(pBuffer); }

  int32_t iGrowSize;
  int32_t iBlockSize;
  int32_t iTotalCount;
  int32_t iBlockCount;
  uint8_t* pBuffer;
};
CFX_BaseArray::CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize) {
  FXSYS_assert(iGrowSize > 0 && iBlockSize > 0);
  m_pData = new FX_BASEARRAYDATA(iGrowSize, iBlockSize);
}
CFX_BaseArray::~CFX_BaseArray() {
  RemoveAll();
  delete m_pData;
}
int32_t CFX_BaseArray::GetSize() const {
  return m_pData->iBlockCount;
}
int32_t CFX_BaseArray::GetBlockSize() const {
  return m_pData->iBlockSize;
}
uint8_t* CFX_BaseArray::AddSpaceTo(int32_t index) {
  FXSYS_assert(index > -1);
  uint8_t*& pBuffer = m_pData->pBuffer;
  int32_t& iTotalCount = m_pData->iTotalCount;
  int32_t iBlockSize = m_pData->iBlockSize;
  if (index >= iTotalCount) {
    int32_t iGrowSize = m_pData->iGrowSize;
    iTotalCount = (index / iGrowSize + 1) * iGrowSize;
    int32_t iNewSize = iTotalCount * iBlockSize;
    if (!pBuffer) {
      pBuffer = FX_Alloc(uint8_t, iNewSize);
    } else {
      pBuffer = FX_Realloc(uint8_t, pBuffer, iNewSize);
    }
  }
  int32_t& iBlockCount = m_pData->iBlockCount;
  if (index >= iBlockCount) {
    iBlockCount = index + 1;
  }
  return pBuffer + index * iBlockSize;
}
uint8_t* CFX_BaseArray::GetAt(int32_t index) const {
  FXSYS_assert(index > -1 && index < m_pData->iBlockCount);
  return m_pData->pBuffer + index * m_pData->iBlockSize;
}
uint8_t* CFX_BaseArray::GetBuffer() const {
  return m_pData->pBuffer;
}
int32_t CFX_BaseArray::Append(const CFX_BaseArray& src,
                              int32_t iStart,
                              int32_t iCount) {
  int32_t iBlockSize = m_pData->iBlockSize;
  FXSYS_assert(iBlockSize == src.m_pData->iBlockSize);
  int32_t& iBlockCount = m_pData->iBlockCount;
  int32_t iAdded = src.GetSize();
  FXSYS_assert(iStart > -1 && iStart < iAdded);
  if (iCount < 0) {
    iCount = iAdded;
  }
  if (iStart + iCount > iAdded) {
    iCount = iAdded - iStart;
  }
  if (iCount < 1) {
    return 0;
  }
  uint8_t* pDst = m_pData->pBuffer + iBlockCount * iBlockSize;
  AddSpaceTo(iBlockCount + iCount - 1);
  FX_memcpy(pDst, src.m_pData->pBuffer + iStart * iBlockSize,
            iCount * iBlockSize);
  return iCount;
}
int32_t CFX_BaseArray::Copy(const CFX_BaseArray& src,
                            int32_t iStart,
                            int32_t iCount) {
  int32_t iBlockSize = m_pData->iBlockSize;
  FXSYS_assert(iBlockSize == src.m_pData->iBlockSize);
  int32_t iCopied = src.GetSize();
  FXSYS_assert(iStart > -1 && iStart < iCopied);
  if (iCount < 0) {
    iCount = iCopied;
  }
  if (iStart + iCount > iCopied) {
    iCount = iCopied - iStart;
  }
  if (iCount < 1) {
    return 0;
  }
  RemoveAll(TRUE);
  AddSpaceTo(iCount - 1);
  FX_memcpy(m_pData->pBuffer, src.m_pData->pBuffer + iStart * iBlockSize,
            iCount * iBlockSize);
  return iCount;
}
int32_t CFX_BaseArray::RemoveLast(int32_t iCount) {
  int32_t& iBlockCount = m_pData->iBlockCount;
  if (iCount < 0 || iCount > iBlockCount) {
    iCount = iBlockCount;
    iBlockCount = 0;
  } else {
    iBlockCount -= iCount;
  }
  return iCount;
}
void CFX_BaseArray::RemoveAll(FX_BOOL bLeaveMemory) {
  if (!bLeaveMemory) {
    uint8_t*& pBuffer = m_pData->pBuffer;
    if (pBuffer != NULL) {
      FX_Free(pBuffer);
      pBuffer = NULL;
    }
    m_pData->iTotalCount = 0;
  }
  m_pData->iBlockCount = 0;
}
CFX_BaseMassArrayImp::CFX_BaseMassArrayImp(int32_t iChunkSize,
                                           int32_t iBlockSize)
    : m_iChunkSize(iChunkSize),
      m_iBlockSize(iBlockSize),
      m_iChunkCount(0),
      m_iBlockCount(0) {
  FXSYS_assert(m_iChunkSize > 0 && m_iBlockSize > 0);
  m_pData = new CFX_PtrArray;
  m_pData->SetSize(16);
}
CFX_BaseMassArrayImp::~CFX_BaseMassArrayImp() {
  RemoveAll();
  delete m_pData;
}
uint8_t* CFX_BaseMassArrayImp::AddSpaceTo(int32_t index) {
  FXSYS_assert(index > -1);
  uint8_t* pChunk;
  if (index < m_iBlockCount) {
    pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize);
  } else {
    int32_t iMemSize = m_iChunkSize * m_iBlockSize;
    while (TRUE) {
      if (index < m_iChunkCount * m_iChunkSize) {
        pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize);
        break;
      } else {
        pChunk = FX_Alloc(uint8_t, iMemSize);
        if (m_iChunkCount < m_pData->GetSize()) {
          m_pData->SetAt(m_iChunkCount, pChunk);
        } else {
          m_pData->Add(pChunk);
        }
        m_iChunkCount++;
      }
    }
  }
  FXSYS_assert(pChunk != NULL);
  m_iBlockCount = index + 1;
  return pChunk + (index % m_iChunkSize) * m_iBlockSize;
}
uint8_t* CFX_BaseMassArrayImp::GetAt(int32_t index) const {
  FXSYS_assert(index > -1 && index < m_iBlockCount);
  uint8_t* pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize);
  FXSYS_assert(pChunk != NULL);
  return pChunk + (index % m_iChunkSize) * m_iBlockSize;
}
int32_t CFX_BaseMassArrayImp::Append(const CFX_BaseMassArrayImp& src,
                                     int32_t iStart,
                                     int32_t iCount) {
  FXSYS_assert(m_iBlockSize == src.m_iBlockSize);
  int32_t iAdded = src.m_iBlockCount;
  FXSYS_assert(iStart > -1 && iStart < iAdded);
  if (iCount < 0) {
    iCount = iAdded;
  }
  if (iStart + iCount > iAdded) {
    iCount = iAdded - iStart;
  }
  if (iCount < 1) {
    return m_iBlockCount;
  }
  int32_t iBlockCount = m_iBlockCount;
  int32_t iTotal = m_iBlockCount + iCount;
  AddSpaceTo(iTotal - 1);
  Append(iBlockCount, src, iStart, iCount);
  return m_iBlockCount;
}
int32_t CFX_BaseMassArrayImp::Copy(const CFX_BaseMassArrayImp& src,
                                   int32_t iStart,
                                   int32_t iCount) {
  FXSYS_assert(m_iBlockSize == src.m_iBlockSize);
  int32_t iCopied = src.m_iBlockCount;
  FXSYS_assert(iStart > -1);
  if (iStart >= iCopied) {
    return 0;
  }
  RemoveAll(TRUE);
  if (iCount < 0) {
    iCount = iCopied;
  }
  if (iStart + iCount > iCopied) {
    iCount = iCopied - iStart;
  }
  if (iCount < 1) {
    return 0;
  }
  if (m_iBlockCount < iCount) {
    AddSpaceTo(iCount - 1);
  }
  Append(0, src, iStart, iCount);
  return m_iBlockCount;
}
void CFX_BaseMassArrayImp::Append(int32_t iDstStart,
                                  const CFX_BaseMassArrayImp& src,
                                  int32_t iSrcStart,
                                  int32_t iSrcCount) {
  FXSYS_assert(iDstStart > -1 && m_iBlockSize == src.m_iBlockSize);
  int32_t iSrcTotal = src.m_iBlockCount;
  FXSYS_assert(iSrcTotal > 0 && m_iBlockCount >= iDstStart + iSrcCount);
  FXSYS_assert(iSrcStart > -1 && iSrcStart < iSrcTotal && iSrcCount > 0 &&
               iSrcStart + iSrcCount <= iSrcTotal);
  int32_t iDstChunkIndex = iDstStart / m_iChunkSize;
  int32_t iSrcChunkIndex = iSrcStart / src.m_iChunkSize;
  uint8_t* pDstChunk = (uint8_t*)GetAt(iDstStart);
  uint8_t* pSrcChunk = (uint8_t*)src.GetAt(iSrcStart);
  int32_t iDstChunkSize = m_iChunkSize - (iDstStart % m_iChunkSize);
  int32_t iSrcChunkSize = src.m_iChunkSize - (iSrcStart % src.m_iChunkSize);
  int32_t iCopySize =
      std::min(iSrcCount, std::min(iSrcChunkSize, iDstChunkSize));
  int32_t iCopyBytes = iCopySize * m_iBlockSize;
  while (iSrcCount > 0) {
    FXSYS_assert(pDstChunk != NULL && pSrcChunk != NULL);
    FXSYS_memcpy(pDstChunk, pSrcChunk, iCopyBytes);
    iSrcCount -= iCopySize;
    iSrcChunkSize -= iCopySize;
    if (iSrcChunkSize < 1) {
      iSrcChunkSize = src.m_iChunkSize;
      iSrcChunkIndex++;
      pSrcChunk = (uint8_t*)src.m_pData->GetAt(iSrcChunkIndex);
    } else {
      pSrcChunk += iCopyBytes;
    }
    iDstChunkSize -= iCopySize;
    if (iDstChunkSize < 1) {
      iDstChunkSize = m_iChunkSize;
      iDstChunkIndex++;
      pDstChunk = (uint8_t*)m_pData->GetAt(iDstChunkIndex);
    } else {
      pDstChunk += iCopyBytes;
    }
    iCopySize = std::min(iSrcCount, std::min(iSrcChunkSize, iDstChunkSize));
    iCopyBytes = iCopySize * m_iBlockSize;
  }
}
int32_t CFX_BaseMassArrayImp::RemoveLast(int32_t iCount) {
  if (iCount < 0 || iCount >= m_iBlockCount) {
    m_iBlockCount = 0;
  } else {
    m_iBlockCount -= iCount;
  }
  return m_iBlockCount;
}
void CFX_BaseMassArrayImp::RemoveAll(FX_BOOL bLeaveMemory) {
  if (bLeaveMemory) {
    m_iBlockCount = 0;
    return;
  }
  for (int32_t i = 0; i < m_iChunkCount; i++) {
    void* p = m_pData->GetAt(i);
    if (p == NULL) {
      continue;
    }
    FX_Free(p);
  }
  m_pData->RemoveAll();
  m_iChunkCount = 0;
  m_iBlockCount = 0;
}
CFX_BaseMassArray::CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize) {
  m_pData = new CFX_BaseMassArrayImp(iChunkSize, iBlockSize);
}
CFX_BaseMassArray::~CFX_BaseMassArray() {
  delete m_pData;
}
int32_t CFX_BaseMassArray::GetSize() const {
  return m_pData->m_iBlockCount;
}
uint8_t* CFX_BaseMassArray::AddSpaceTo(int32_t index) {
  return m_pData->AddSpaceTo(index);
}
uint8_t* CFX_BaseMassArray::GetAt(int32_t index) const {
  return m_pData->GetAt(index);
}
int32_t CFX_BaseMassArray::Append(const CFX_BaseMassArray& src,
                                  int32_t iStart,
                                  int32_t iCount) {
  return m_pData->Append(*(CFX_BaseMassArrayImp*)src.m_pData, iStart, iCount);
}
int32_t CFX_BaseMassArray::Copy(const CFX_BaseMassArray& src,
                                int32_t iStart,
                                int32_t iCount) {
  return m_pData->Copy(*(CFX_BaseMassArrayImp*)src.m_pData, iStart, iCount);
}
int32_t CFX_BaseMassArray::RemoveLast(int32_t iCount) {
  return m_pData->RemoveLast(iCount);
}
void CFX_BaseMassArray::RemoveAll(FX_BOOL bLeaveMemory) {
  m_pData->RemoveAll(bLeaveMemory);
}
typedef struct _FX_BASEDISCRETEARRAYDATA {
  int32_t iBlockSize;
  int32_t iChunkSize;
  int32_t iChunkCount;
  CFX_PtrArray ChunkBuffer;
} FX_BASEDISCRETEARRAYDATA, *FX_LPBASEDISCRETEARRAYDATA;
typedef FX_BASEDISCRETEARRAYDATA const* FX_LPCBASEDISCRETEARRAYDATA;
CFX_BaseDiscreteArray::CFX_BaseDiscreteArray(int32_t iChunkSize,
                                             int32_t iBlockSize) {
  FXSYS_assert(iChunkSize > 0 && iBlockSize > 0);
  FX_LPBASEDISCRETEARRAYDATA pData;
  m_pData = pData = new FX_BASEDISCRETEARRAYDATA;
  pData->ChunkBuffer.SetSize(16);
  pData->iChunkCount = 0;
  pData->iChunkSize = iChunkSize;
  pData->iBlockSize = iBlockSize;
}
CFX_BaseDiscreteArray::~CFX_BaseDiscreteArray() {
  RemoveAll();
  delete (FX_LPBASEDISCRETEARRAYDATA) m_pData;
}
uint8_t* CFX_BaseDiscreteArray::AddSpaceTo(int32_t index) {
  FXSYS_assert(index > -1);
  FX_LPBASEDISCRETEARRAYDATA pData = (FX_LPBASEDISCRETEARRAYDATA)m_pData;
  int32_t& iChunkCount = pData->iChunkCount;
  int32_t iChunkSize = pData->iChunkSize;
  uint8_t* pChunk = NULL;
  int32_t iChunk = index / iChunkSize;
  if (iChunk < iChunkCount) {
    pChunk = (uint8_t*)pData->ChunkBuffer.GetAt(iChunk);
  }
  if (!pChunk) {
    pChunk = FX_Alloc2D(uint8_t, iChunkSize, pData->iBlockSize);
    FXSYS_memset(pChunk, 0, iChunkSize * pData->iBlockSize);
    pData->ChunkBuffer.SetAtGrow(iChunk, pChunk);
    if (iChunkCount <= iChunk) {
      iChunkCount = iChunk + 1;
    }
  }
  return pChunk + (index % iChunkSize) * pData->iBlockSize;
}
uint8_t* CFX_BaseDiscreteArray::GetAt(int32_t index) const {
  FXSYS_assert(index > -1);
  FX_LPBASEDISCRETEARRAYDATA pData = (FX_LPBASEDISCRETEARRAYDATA)m_pData;
  int32_t iChunkSize = pData->iChunkSize;
  int32_t iChunk = index / iChunkSize;
  if (iChunk >= pData->iChunkCount) {
    return NULL;
  }
  uint8_t* pChunk = (uint8_t*)pData->ChunkBuffer.GetAt(iChunk);
  if (pChunk == NULL) {
    return NULL;
  }
  return pChunk + (index % iChunkSize) * pData->iBlockSize;
}
void CFX_BaseDiscreteArray::RemoveAll() {
  FX_LPBASEDISCRETEARRAYDATA pData = (FX_LPBASEDISCRETEARRAYDATA)m_pData;
  CFX_PtrArray& ChunkBuffer = pData->ChunkBuffer;
  int32_t& iChunkCount = pData->iChunkCount;
  for (int32_t i = 0; i < iChunkCount; i++) {
    void* p = ChunkBuffer.GetAt(i);
    if (p == NULL) {
      continue;
    }
    FX_Free(p);
  }
  ChunkBuffer.RemoveAll();
  iChunkCount = 0;
}
CFX_BaseStack::CFX_BaseStack(int32_t iChunkSize, int32_t iBlockSize) {
  m_pData = new CFX_BaseMassArrayImp(iChunkSize, iBlockSize);
}
CFX_BaseStack::~CFX_BaseStack() {
  delete (CFX_BaseMassArrayImp*)m_pData;
}
uint8_t* CFX_BaseStack::Push() {
  return m_pData->AddSpace();
}
void CFX_BaseStack::Pop() {
  int32_t& iBlockCount = m_pData->m_iBlockCount;
  if (iBlockCount < 1) {
    return;
  }
  iBlockCount--;
}
uint8_t* CFX_BaseStack::GetTopElement() const {
  int32_t iSize = m_pData->m_iBlockCount;
  if (iSize < 1) {
    return NULL;
  }
  return m_pData->GetAt(iSize - 1);
}
int32_t CFX_BaseStack::GetSize() const {
  return m_pData->m_iBlockCount;
}
uint8_t* CFX_BaseStack::GetAt(int32_t index) const {
  return m_pData->GetAt(index);
}
void CFX_BaseStack::RemoveAll(FX_BOOL bLeaveMemory) {
  m_pData->RemoveAll(bLeaveMemory);
}


text:
package easy.data.tests;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import easy.data.field.CompField;
import easy.data.field.IDataField;
import easy.data.field.ListField;
import easy.data.field.PrimField;
import easy.data.sig.*;
import easy.data.util.*;
import easy.data.xml.*;

import java.util.*;

public class XMLInstantiatorTest {

	XML xml1;
	PrimField pf1;
	PrimField pf2;
	PrimField pf3;
	PrimField pf4;
	CompField cf1;
	CompField cf2;
	ListField lf1;
	ListField lf2;
	ListField lf3;

	CompSig<Pair> cspair;

	static class Pair {
		String n;
		String v;
		public Pair(String n, String v) {
			this.n = n;
			this.v = v;
		}
		public boolean equals(Object other) {
			if (!(other instanceof Pair)) return false;
			Pair that = (Pair) other;
			return (that.n==this.n || that.n.equals(this.n)) &&
					(that.v==this.v || that.v.equals(this.v));
		}
		public String toString() { return n + ": " + v; }
	}

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		xml1 = IOUtil.loadXML("src/big/data/tests/dsspec1.xml");
		pf1 = new PrimField("name", "option name");
		pf2 = new PrimField("value", "option setting");
		pf3 = new PrimField(null);
		pf4 = new PrimField("dataspec/compfield/fields/field/name");
		cf1 = new CompField(null, "an option setting pair");
		cf2 = new CompField("options/option", "an option setting pair");
		lf1 = new ListField("options", "option", cf1, "list of option settings");
		lf2 = new ListField("blah", "blup", pf3, "messed up");
		lf3 = new ListField(null, "dataspec/compfield/fields/field/name", pf3, "top level field names");

		cf1.addField("value", pf2);
		cf1.addField("name", pf1);
		cf2.addField("value", pf2);
		cf2.addField("name", pf1);

		cspair = new CompSig<Pair>(Pair.class);
		cspair.addField(PrimSig.STRING_SIG, "name");
		cspair.addField(PrimSig.STRING_SIG, "value");
	}

	@After
	public void tearDown() throws Exception {
	}

	private static <T> T instantiate(IDataField f, XML xml, ISig s) {
		return f.apply(new XMLInstantiator<T>(xml, s));
	}

	@SuppressWarnings("rawtypes")
	@Test
	public final void test() {
		assertNull(instantiate(pf2, xml1, PrimSig.WILDCARD_SIG));
		assertEquals(instantiate(pf4, xml1, PrimSig.WILDCARD_SIG), "City");
		assertArrayEquals(new String[] { "City" },
						  ((ArrayList)instantiate(pf4, xml1, new ListSig(PrimSig.WILDCARD_SIG))).toArray());

		ArrayList<String> lst = instantiate(lf3, xml1, new ListSig(PrimSig.WILDCARD_SIG));
		assertArrayEquals(new String[] { "City", "State", "Name", "Status Comment", "Status" },
						  lst.toArray());

		assertEquals(new Pair("xmlpreprocclass", "WeatherConsolidate"),
					 instantiate(cf2, xml1, cspair));
		assertEquals(new Pair("FAA Airport Status", ""),
					 instantiate(cf1, xml1, cspair));
		assertNull(instantiate(cf1, xml1.getChild("dataspec"), cspair));   // no subfields successfully parsed
		assertNull(instantiate(cf1, xml1, new CompSig<Thread>(Thread.class)));

		assertNull(instantiate(lf2, xml1, new ListSig(PrimSig.WILDCARD_SIG)));
		assertArrayEquals(new Pair[] { new Pair("xmlpreprocclass", "WeatherConsolidate"),
										new Pair("question", "life"),
										new Pair("answer", "42")},
						  ((ArrayList)instantiate(lf1, xml1, new ListSig(cspair))).toArray());

		assertArrayEquals(new Object[] {},
						((ArrayList)instantiate(new ListField("options", "top", cf1), xml1, new ListSig(cspair))).toArray());
	}

	@Test
	public void testBoolean() {
		XML node = new XML("data");
		node.setContent("yes");
		assertEquals(true, instantiate(new PrimField(), node, PrimSig.BOOLEAN_SIG));
	}

}