text:
"""Run on a cluster using IPython parallel."""

import os

import yaml
from bcbio.distributed import clargs
from bcbio.pipeline import main

from bcbiovm import log as logging
from bcbiovm.client import base
from bcbiovm.common import constant
from bcbiovm.container.docker import common as docker_common
from bcbiovm.container.docker import mounts as docker_mounts
from bcbiovm.ipython import batchprep
from bcbiovm.provider import factory as provider_factory

LOG = logging.get_logger(__name__)

class IPython(base.Command):

    """Run on a cluster using IPython parallel."""

    def __init__(self, parent, parser):
        super(IPython, self).__init__(parent, parser)
        self._need_prologue = True
        self._need_datadir = True

    def setup(self):
        """Extend the parser configuration in order to expose this command."""
        parser = self._parser.add_parser(
            "ipython",
            help="Run on a cluster using IPython parallel.")
        parser.add_argument(
            "sample_config",
            help="YAML file with details about samples to process.")
        parser.add_argument(
            "scheduler", help="Scheduler to use.",
            choices=["lsf", "sge", "torque", "slurm", "pbspro"])
        parser.add_argument(
            "queue", help="Scheduler queue to run jobs on.")
        parser.add_argument(
            "-r", "--resources",
            help=("Cluster specific resources specifications. "
                  "Can be specified multiple times.\n"
                  "Supports SGE and SLURM parameters."),
            default=[], action="append")
        parser.add_argument(
            "--fcdir",
            help="A directory of Illumina output or fastq files to process",
            type=lambda path: (os.path.abspath(os.path.expanduser(path))))
        parser.add_argument(
            "--systemconfig",
            help=("Global YAML configuration file specifying system details. "
                  "Defaults to installed bcbio_system.yaml."))
        parser.add_argument(
            "-n", "--numcores", type=int, default=1,
            help="Total cores to use for processing")
        parser.add_argument(
            "--timeout", default=15, type=int,
            help=("Number of minutes before cluster startup times out."
                  "Defaults to 15"))
        parser.add_argument(
            "--retries", default=0, type=int,
            help=("Number of retries of failed tasks during distributed "
                  "processing. Default 0 (no retries)"))
        parser.add_argument(
            "-t", "--tag", default="",
            help="Tag name to label jobs on the cluster")
        parser.add_argument(
            "--tmpdir",
            help="Path of local on-machine temporary directory to process in.")
        parser.set_defaults(work=self.run)

    def prologue(self):
        """Executed once before the arguments parsing."""
        # Add user configured defaults to supplied command line arguments.
        self.defaults.add_defaults()
        # Retrieve supported remote inputs specified on the command line.
        self.defaults.retrieve()
        # Check if the datadir exists if it is required.
        self.defaults.check_datadir("Could not run IPython parallel "
                                    "analysis.")
        # Add all the missing arguments related to docker image.
        self.install.image_defaults()

    def work(self):
        """Run the command with the received information."""
        work_dir = os.getcwd()
        ready_config_file = os.path.join(
            work_dir, "%s-ready%s" %
            (os.path.splitext(os.path.basename(self.args.sample_config))))

        parallel = clargs.to_parallel(self.args, "bcbiovm.container.docker")
        parallel["wrapper"] = "runfn"

        LOG.debug("Loading the config: %s", self.args.sample_config)
        with open(self.args.sample_config) as in_handle:
            ready_config, _ = docker_mounts.normalize_config(
                yaml.load(in_handle), self.args.fcdir)

        LOG.debug("Writing the %s file.", ready_config_file)
        with open(ready_config_file, "w") as out_handle:
            yaml.safe_dump(ready_config, out_handle, default_flow_style=False,
                           allow_unicode=False)

        systemconfig = docker_common.local_system_config(
            config=self.args.systemconfig, work_dir=work_dir,
            datadir=self.args.datadir)

        ship_conf = provider_factory.get_ship_config("shared")
        parallel["wrapper_args"] = [
            constant.DOCKER,
            {
                "sample_config": ready_config_file,
                "fcdir": self.args.fcdir,
                "pack": ship_conf(work_dir, self.args.datadir,
                                  self.args.tmpdir),
                "systemconfig": systemconfig,
                "image": self.args.image
            }]

        # For testing, run on a local ipython cluster
        parallel["run_local"] = parallel.get("queue") == "localrun"

        main.run_main(work_dir,
                      run_info_yaml=ready_config_file,
                      config_file=systemconfig,
                      fc_dir=self.args.fcdir,
                      parallel=parallel)

        # Approach for running main function inside of docker.
        # Could be useful for architectures where we can spawn docker
        # jobs from docker.
        #
        # cmd_args = {
        #     "systemconfig": systemconfig,
        #     "image": args.image,
        #     "pack": cur_pack,
        #     "sample_config": args.sample_config,
        #     "fcdir": args.fcdir,
        #     "orig_systemconfig": args.systemconfig
        # }
        # main_args = [work_dir, ready_config_file, systemconfig,
        #              args.fcdir, parallel]
        # run.do_runfn("run_main", main_args, cmd_args, parallel,
        #              content.DOCKER)

class IPythonPrep(base.Command):

    """Prepare a batch script to run bcbio on a scheduler."""

    def setup(self):
        """Extend the parser configuration in order to expose this command."""
        parser = self._parser.add_parser(
            "ipythonprep",
            help="Prepare a batch script to run bcbio on a scheduler.")
        parser.add_argument(
            "sample_config",
            help="YAML file with details about samples to process.")
        parser.add_argument(
            "--fcdir",
            help="A directory of Illumina output or fastq files to process",
            type=lambda path: (os.path.abspath(os.path.expanduser(path))))
        parser.add_argument(
            "--systemconfig",
            help=("Global YAML configuration file specifying system details. "
                  "Defaults to installed bcbio_system.yaml."))
        parser.add_argument(
            "-n", "--numcores", type=int, default=1,
            help="Total cores to use for processing")
        parser.add_argument(
            "scheduler", help="Scheduler to use.",
            choices=["lsf", "sge", "torque", "slurm", "pbspro"])
        parser.add_argument(
            "queue", help="Scheduler queue to run jobs on.")
        parser.add_argument(
            "-r", "--resources",
            help=("Cluster specific resources specifications. "
                  "Can be specified multiple times.\n"
                  "Supports SGE and SLURM parameters."),
            default=[], action="append")
        parser.add_argument(
            "--timeout", default=15, type=int,
            help=("Number of minutes before cluster startup times out."
                  "Defaults to 15"))
        parser.add_argument(
            "--retries", default=0, type=int,
            help=("Number of retries of failed tasks during distributed "
                  "processing. Default 0 (no retries)"))
        parser.add_argument(
            "-t", "--tag", default="",
            help="Tag name to label jobs on the cluster")
        parser.add_argument(
            "--tmpdir",
            help="Path of local on-machine temporary directory to process in.")
        parser.set_defaults(work=self.run)

    def prologue(self):
        """Executed once before the arguments parsing."""
        # Add user configured defaults to supplied command line arguments.
        self.defaults.add_defaults()
        # Retrieve supported remote inputs specified on the command line.
        self.defaults.retrieve()
        # Check if the datadir exists if it is required.
        self.defaults.check_datadir("Could not prep batch scripts.")

    def work(self):
        """Run the command with the received information."""
        return batchprep.submit_script(self.args)

    def task_done(self, result):
        """What to execute after successfully finished processing a task."""
        commands = {"slurm": "sbatch", "sge": "qsub",
                    "lsf": "bsub", "torque": "qsub",
                    "pbspro": "qsub"}

        LOG.info("Start analysis with: %(command)s %(outfile)s",
                 {"command": commands[self.args.scheduler], "outfile": result})


text:
#region

using GTR.Core.Actions;
using GTR.Core.Engine;
using GTR.Core.Game;
using GTR.Core.Model;
using GTR.Core.Moves;
using GTR.Core.Util;

#endregion

namespace GTR.Core.Buildings
{
    internal abstract class BuildOrderActionBase : OrderActionBase
    {
        public BuildOrderActionBase(Player player, GameTable gameTable)
            : base(player, gameTable)
        {
        }

        public abstract RoleType Role { get; }

        protected virtual void PopulateBuildMoves(OrderCardModel handCard, MoveSpace moveSpace)
        {
            int buildCost = GameTable.GetSiteCost(handCard.GetMaterialType());
            int outstandingActions = Player.OutstandingActions.Count(Role);

            if (outstandingActions >= buildCost)
            {
                var buildCombo = GetBuildCombo(handCard);
                if (buildCombo != null)
                {
                    moveSpace.Add(buildCombo);
                }
            }
        }

        private BuildCombo GetBuildCombo(OrderCardModel handCard)
        {
            var siteDeck = GameTable.GetSiteDeck(handCard.GetMaterialType());
            if (siteDeck.Count == 0)
            {
                return null;
            }
            BuildingSite site = siteDeck.Top;

            // move building card on top of site foundation
            IMove<OrderCardModel> buildAction = new Move<OrderCardModel>(handCard, Player.Hand.OrderCards,
                site.BuildingFoundation);

            // move site foundation card from deck to player's camp
            IMove<BuildingSite> siteMove = new Move<BuildingSite>(site, siteDeck, Player.ConstructionZone);

            BuildCombo buildCombo = new BuildCombo(siteMove, buildAction);
            return buildCombo;
        }

        protected abstract void PopulateFeedMoves(OrderCardModel handCard, MoveSpace moveSpace);
    }
}

redpajama_set_name: RedPajamaGithub


text:
"ImageFlow" takes control of your image capturing with the help of OpenCV library. It provides control keys to traverse across video/image files.

Control keys:

[ space ] - stop video stream.

    [ esc ] - terminate the program.

      [ → ] - skip to the next image/video.

      [ ← ] - back to the previous image/video.

        [ ↑ ] - repeat video.

Provided control keys work only when you call `cv::imshow()` function. main.cpp file contains demo.

Dependencies:

* OpenCV 3.1.0 library (link core, videoio and highgui dll files)
* dirent.h file (for Windows OS you can find it here http://softagalleria.net/dirent.php or just download "dirent.h" directly from https://github.com/tronkko/dirent, UNIX based OS comes with it by default)


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;

namespace Lab06_01
{
    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvcWithDefaultRoute();
            //app.UseMvc(routes =>
            //{
            //    routes.MapRoute("default",
            //        "{controller=Home}/{action=Index}/{id?}",
            //        new { controller = "Home", action = "Index" });
            //});

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }
    }
}


text:
![typhonjs-escomplex-module](https://i.imgur.com/xsQDVG1.png)

[![NPM](https://img.shields.io/npm/v/typhonjs-escomplex-module.svg?label=npm)](https://www.npmjs.com/package/typhonjs-escomplex-module)
[![Documentation](http://docs.typhonjs.io/typhonjs-node-escomplex/typhonjs-escomplex-module/badge.svg)](http://docs.typhonjs.io/typhonjs-node-escomplex/typhonjs-escomplex-module/)
[![Code Style](https://img.shields.io/badge/code%20style-allman-yellowgreen.svg?style=flat)](https://en.wikipedia.org/wiki/Indent_style#Allman_style)
[![License](https://img.shields.io/badge/license-MPLv2-yellowgreen.svg?style=flat)](https://github.com/typhonjs-node-escomplex/typhonjs-escomplex-module/blob/master/LICENSE)
[![Gitter](https://img.shields.io/gitter/room/typhonjs/TyphonJS.svg)](https://gitter.im/typhonjs/TyphonJS)

[![Build Status](https://travis-ci.org/typhonjs-node-escomplex/typhonjs-escomplex-module.svg?branch=master)](https://travis-ci.org/typhonjs-node-escomplex/typhonjs-escomplex-module)
[![Coverage](https://img.shields.io/codecov/c/github/typhonjs-node-escomplex/typhonjs-escomplex-module.svg)](https://codecov.io/github/typhonjs-node-escomplex/typhonjs-escomplex-module)
[![Dependency Status](https://www.versioneye.com/user/projects/575ddc4a7757a00034dc5438/badge.svg?style=flat)](https://www.versioneye.com/user/projects/575ddc4a7757a00034dc5438)

Provides module / individual file oriented AST processing for typhonjs-escomplex complexity reports. The following JS AST generators are supported / tested: [acorn](https://www.npmjs.com/package/acorn), [babylon](https://www.npmjs.com/package/babylon), [espree](https://www.npmjs.com/package/espree), [esprima](https://www.npmjs.com/package/esprima). Any compliant JS parser that supports Babylon or ESTree AST should work as well.

More information forthcoming. This NPM module can be installed as a dependency in `package.json` as follows:
```
"dependencies": {
  "typhonjs-escomplex-module": "^0.0.9"
}
```

An ES6 example follows:
```
import escomplexModule from 'typhonjs-escomplex-module';

const ast = <some parsed AST>;

const report = escomplexModule.analyze(ast);
```

A CJS example follows:
```
var escomplexModule = require('typhonjs-escomplex-module');

var ast = <some parsed AST>;

var report = escomplexModule.analyze(ast);
```


text:
<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
  <rule-list>
    <name>almighty</name>
    <group>almighty</group>
    <group nc:operation="create">test</group>
    <rule>
      <module-name>*</module-name>
      <access-operations>*</access-operations>
      <action>permit</action>
    </rule>
  </rule-list>
  <groups>
    <group>
      <name>test</name>
      <user-name>smith</user-name>
    </group>
    <group>
      <name>almighty</name>
      <user-name>smith</user-name>
      <user-name>doe</user-name>
    </group>
  </groups>
  <denied-operations>0</denied-operations>
  <denied-data-writes>0</denied-data-writes>
  <denied-notifications>0</denied-notifications>
</nacm>


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.springapp</groupId>
    <artifactId>spring-essential</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>spring-essential</name>

    <properties>
        <spring.version>3.2.7.RELEASE</spring.version>
    </properties>

    <dependencies>

        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.2.9.RELEASE</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>

        <!-- File upload -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>spring-essential</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>**/*Tests.java</include>
                    </includes>
                </configuration>
            </plugin>

            <!-- jetty plugin -->
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <configuration>
                    <webApp>
                        <contextPath>/</contextPath>
                    </webApp>
                    <stopKey>webx</stopKey>
                    <stopPort>9999</stopPort>
                    <connectors>
                        <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                            <port>8081</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                    <requestLog implementation="org.eclipse.jetty.server.NCSARequestLog">
                        <filename>target/access.log</filename>
                        <retainDays>90</retainDays>
                        <append>false</append>
                        <extended>false</extended>
                        <logTimeZone>GMT+8:00</logTimeZone>
                    </requestLog>
                    <systemProperties>
                        <systemProperty>
                            <name>productionMode</name>
                            <value>${productionMode}</value>
                        </systemProperty>
                    </systemProperties>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


text:
#include "../intern.h"
#include "../utils.h"
#include "preprocessor.h"
#include "context.h"
#include "tokenizer.h"

#include <string.h>
#include <strings.h>

/* ==================================================================================================== */

#define _EXTCSS3_NEXT(intern, error) do {				\
	bool result = _extcss3_next_char(intern, error);	\
	if (EXTCSS3_SUCCESS != result) {					\
		return EXTCSS3_FAILURE;							\
	}													\
} while (0)

#define _EXTCSS3_FILL_FIXED_TOKEN(intern, token, type, chars, error) do {		\
	bool result = _extcss3_fill_fixed_token(intern, token, type, chars, error);	\
	if (EXTCSS3_SUCCESS != result) {											\
		return _extcss3_cleanup_tokenizer(*error, intern, true, true);			\
	}																			\
} while (0)

/* ==================================================================================================== */

/* HELPER */
static bool _extcss3_cleanup_tokenizer(unsigned int error, extcss3_intern *intern, bool token, bool ctxt);
static bool _extcss3_next_char(extcss3_intern *intern, unsigned int *error);
static bool _extcss3_token_add(extcss3_intern *intern, extcss3_token *token, unsigned int *error);

/* TOKEN FILLER */
static bool _extcss3_fill_fixed_token(extcss3_intern *intern, extcss3_token *token, unsigned int type, unsigned int chars, unsigned int *error);
static bool _extcss3_fill_ws_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error);
static bool _extcss3_fill_hash_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error);
static bool _extcss3_fill_at_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error);
static bool _extcss3_fill_comment_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error);
static bool _extcss3_fill_unicode_range_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error);
static bool _extcss3_fill_ident_like_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error);
static bool _extcss3_fill_url_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error);
static bool _extcss3_fill_string_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error);
static bool _extcss3_fill_number_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error);

/* CONSUMER */
static bool _extcss3_consume_escaped(extcss3_intern *intern, unsigned int *error);
static bool _extcss3_consume_bad_url_remnants(extcss3_intern *intern, unsigned int *error);
static bool _extcss3_consume_name(extcss3_intern *intern, unsigned int *error);

/* CHECKER */
static bool _extcss3_check_start_valid_escape(const char *str);
static bool _extcss3_check_start_name(const char *str);
static bool _extcss3_check_start_ident(char *str);
static bool _extcss3_check_start_number(const char *str);
static bool _extcss3_check_is_name(const char *str);

/* ==================================================================================================== */

bool extcss3_tokenize(extcss3_intern *intern, unsigned int *error)
{
	extcss3_token *token;
	unsigned int i;
	char *reader;

	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

	if ((intern == NULL) || (intern->copy.str == NULL)) {
		return _extcss3_cleanup_tokenizer(*error = EXTCSS3_ERR_NULL_PTR, NULL, false, false);
	} else if ((intern->base_token = token = extcss3_create_token()) == NULL) {
		return _extcss3_cleanup_tokenizer(*error = EXTCSS3_ERR_MEMORY, NULL, false, false);
	} else if (
		EXTCSS3_HAS_MODIFIER(intern) &&
		((intern->base_ctxt = intern->last_ctxt = extcss3_create_ctxt()) == NULL)
	) {
		return _extcss3_cleanup_tokenizer(*error = EXTCSS3_ERR_MEMORY, intern, true, false);
	}

	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

	/**
	 * To be able to identify some token types, we must be able to
	 * look forward in the "prepared" string. Therefore we "preload"
	 * "i" characters. The "reader" and "writer" pointers of the
	 * state machine run in parallel but offset by "i" characters.
	 */
	for (i = 5; i--; ) {
		if (EXTCSS3_SUCCESS != extcss3_preprocess(intern, error)) {
			return _extcss3_cleanup_tokenizer(*error, intern, true, true);
		}
	}

	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

	/* https://www.w3.org/TR/css-syntax-3/#consume-a-token */
	while ((intern->last_token == NULL) || (intern->last_token->type != EXTCSS3_TYPE_EOF)) {
		reader = intern->state.reader;

		switch (*reader) {
			case ' ':
			case '\n':
			case '\t':
			{
				if (EXTCSS3_SUCCESS != _extcss3_fill_ws_token(intern, token, error)) {
					return _extcss3_cleanup_tokenizer(*error, intern, true, true);
				}

				break;
			}
			case '"':
			case '\'':
			{
				if (EXTCSS3_SUCCESS != _extcss3_fill_string_token(intern, token, error)) {
					return _extcss3_cleanup_tokenizer(*error, intern, true, true);
				}

				break;
			}
			case '#':
			{
				if (
					(EXTCSS3_SUCCESS == _extcss3_check_is_name(reader + 1)) ||
					(EXTCSS3_SUCCESS == _extcss3_check_start_valid_escape(reader + 1))
				) {
					if (EXTCSS3_SUCCESS != _extcss3_fill_hash_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '$':
			{
				if (reader[1] == '=') {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_SUFFIX_MATCH, 2, error);
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '(':
			{
				_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_BR_RO, 1, error);
				break;
			}
			case ')':
			{
				_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_BR_RC, 1, error);
				break;
			}
			case '[':
			{
				_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_BR_SO, 1, error);
				break;
			}
			case ']':
			{
				_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_BR_SC, 1, error);
				break;
			}
			case '{':
			{
				_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_BR_CO, 1, error);
				break;
			}
			case '}':
			{
				_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_BR_CC, 1, error);
				break;
			}
			case ',':
			{
				_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_COMMA, 1, error);
				break;
			}
			case ':':
			{
				_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_COLON, 1, error);
				break;
			}
			case ';':
			{
				_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_SEMICOLON, 1, error);
				break;
			}
			case '*':
			{
				if (reader[1] == '=') {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_SUBSTR_MATCH, 2, error);
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '+':
			case '.':
			{
				if (EXTCSS3_SUCCESS == _extcss3_check_start_number(reader)) {
					if (EXTCSS3_SUCCESS != _extcss3_fill_number_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '-':
			{
				if (EXTCSS3_SUCCESS == _extcss3_check_start_number(reader)) {
					if (EXTCSS3_SUCCESS != _extcss3_fill_number_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				} else if (EXTCSS3_SUCCESS == _extcss3_check_start_ident(reader)) {
					if (EXTCSS3_SUCCESS != _extcss3_fill_ident_like_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				} else if ((reader[1] == '-') && (reader[2] == '>')) {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_CDC, 3, error);
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '/':
			{
				if (reader[1] == '*') {
					if (EXTCSS3_SUCCESS != _extcss3_fill_comment_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '<':
			{
				if (reader[1] == '!' && reader[2] == '-' && reader[3] == '-') {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_CDO, 4, error);
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '@':
			{
				if (EXTCSS3_SUCCESS == _extcss3_check_start_ident(reader + 1)) {
					if (EXTCSS3_SUCCESS != _extcss3_fill_at_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '\\':
			{
				if (EXTCSS3_SUCCESS == _extcss3_check_start_valid_escape(reader + 1)) {
					if (EXTCSS3_SUCCESS != _extcss3_fill_ident_like_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '^':
			{
				if (reader[1] == '=') {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_PREFIX_MATCH, 2, error);
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '|':
			{
				if (reader[1] == '=') {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DASH_MATCH, 2, error);
				} else if (reader[1] == '|') {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_COLUMN, 2, error);
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case '~':
			{
				if (reader[1] == '=') {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_INCLUDE_MATCH, 2, error);
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
			case 'u':
			case 'U':
			{
				if ((reader[1] == '+') && ((reader[2] == '?') || EXTCSS3_IS_HEX(reader[2]))) {
					if (EXTCSS3_SUCCESS != _extcss3_fill_unicode_range_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				} else {
					if (EXTCSS3_SUCCESS != _extcss3_fill_ident_like_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				}

				break;
			}
			case '\0':
			{
				_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_EOF, 1, error);
				break;
			}
			default:
			{
				if (EXTCSS3_IS_DIGIT(*reader)) {
					if (EXTCSS3_SUCCESS != _extcss3_fill_number_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				} else if (EXTCSS3_SUCCESS == _extcss3_check_start_name(reader)) {
					if (EXTCSS3_SUCCESS != _extcss3_fill_ident_like_token(intern, token, error)) {
						return _extcss3_cleanup_tokenizer(*error, intern, true, true);
					}
				} else {
					_EXTCSS3_FILL_FIXED_TOKEN(intern, token, EXTCSS3_TYPE_DELIM, 1, error);
				}

				break;
			}
		}

		/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		if (EXTCSS3_SUCCESS != _extcss3_token_add(intern, token, error)) {
			return _extcss3_cleanup_tokenizer(*error, intern, true, true);
		}

		/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		if (token->type == EXTCSS3_TYPE_EOF) {
			break;
		} else if ((token = extcss3_create_token()) == NULL) {
			return _extcss3_cleanup_tokenizer(*error = EXTCSS3_ERR_MEMORY, intern, true, true);
		}
	}

	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

	return _extcss3_cleanup_tokenizer(0, intern, false, true);
}

/* ==================================================================================================== */
/* HELPER */

static inline bool _extcss3_cleanup_tokenizer(unsigned int error, extcss3_intern *intern, bool token, bool ctxt)
{
	if (intern != NULL) {
		if (token && (intern->base_token != NULL)) {
			extcss3_release_tokens_list(intern->base_token);
			intern->base_token = NULL;
		}

		if (ctxt && (intern->base_ctxt != NULL)) {
			extcss3_release_ctxts_list(intern->base_ctxt);
			intern->base_ctxt = NULL;
		}
	}

	return error == 0 ? EXTCSS3_SUCCESS : EXTCSS3_FAILURE;
}

static inline bool _extcss3_next_char(extcss3_intern *intern, unsigned int *error)
{
	if (EXTCSS3_SUCCESS != extcss3_preprocess(intern, error)) {
		return EXTCSS3_FAILURE;
	} else if (*intern->state.reader != '\0') {
		intern->state.reader += extcss3_char_len(*intern->state.reader);
	}

	return EXTCSS3_SUCCESS;
}

static inline bool _extcss3_token_add(extcss3_intern *intern, extcss3_token *token, unsigned int *error)
{
	extcss3_token *prev;

	if ((token->prev = intern->last_token) != NULL) {
		intern->last_token->next = token;
	}

	intern->last_token = token;

	// Mark the first @import <string> token as an <url> token
	if (token->type == EXTCSS3_TYPE_STRING) {
		prev = token->prev;

		while (prev != NULL) {
			if ((prev->type == EXTCSS3_TYPE_WS) || (prev->type == EXTCSS3_TYPE_COMMENT)) {
				prev = prev->prev;
				continue;
			} else if (prev->type != EXTCSS3_TYPE_AT_KEYWORD) {
				break;
			}

			if (prev->data.len == 7 /* strlen("@import") */) {
				if (EXTCSS3_SUCCESS == extcss3_ascii_strncasecmp(prev->data.str, "@import", 7)) {
					token->type		= EXTCSS3_TYPE_URL;
					token->flag		= EXTCSS3_FLAG_AT_URL_STRING;
					token->info.str	= token->data.str;
					token->info.len	= 1;
				}
			}

			break;
		}
	}

	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

	if (intern->base_ctxt != NULL) {
		if (EXTCSS3_TYPE_IS_MODIFIABLE(token->type) && (intern->modifier.callback != NULL)) {
			intern->modifier.callback(intern);

			if ((token->user.str != NULL) && (token->user.len > token->data.len)) {
				intern->modifier.user_strlen_diff -= token->data.len;
				intern->modifier.user_strlen_diff += token->user.len;
			}
		}

		if (EXTCSS3_SUCCESS != extcss3_ctxt_update(intern, error)) {
			return EXTCSS3_FAILURE;
		}
	}

	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

	return EXTCSS3_SUCCESS;
}

/* ==================================================================================================== */
/* TOKEN FILLER */

/**
 * Add one of the tokens with a fixed bytes length:
 *
 * (1) EXTCSS3_TYPE_DELIM
 * (2) EXTCSS3_TYPE_INCLUDE_MATCH
 * (2) EXTCSS3_TYPE_DASH_MATCH
 * (2) EXTCSS3_TYPE_PREFIX_MATCH
 * (2) EXTCSS3_TYPE_SUFFIX_MATCH
 * (2) EXTCSS3_TYPE_SUBSTR_MATCH
 * (2) EXTCSS3_TYPE_COLUMN
 * (4) EXTCSS3_TYPE_CDO
 * (3) EXTCSS3_TYPE_CDC
 * (1) EXTCSS3_TYPE_COLON
 * (1) EXTCSS3_TYPE_SEMICOLON
 * (1) EXTCSS3_TYPE_COMMA
 * (1) EXTCSS3_TYPE_BR_RO
 * (1) EXTCSS3_TYPE_BR_RC
 * (1) EXTCSS3_TYPE_BR_SO
 * (1) EXTCSS3_TYPE_BR_SC
 * (1) EXTCSS3_TYPE_BR_CO
 * (1) EXTCSS3_TYPE_BR_CC
 * (1) EXTCSS3_TYPE_EOF
 */
static inline bool _extcss3_fill_fixed_token(extcss3_intern *intern, extcss3_token *token, unsigned int type, unsigned int chars, unsigned int *error)
{
	token->type = type;
	token->data.str = intern->state.reader;

	if (token->type != EXTCSS3_TYPE_EOF) {
		while (chars--) {
			_EXTCSS3_NEXT(intern, error);
		}
	}

	token->data.len = intern->state.reader - token->data.str;

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-a-token (whitespace)
 */
static inline bool _extcss3_fill_ws_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error)
{
	token->type = EXTCSS3_TYPE_WS;
	token->data.str = intern->state.reader;

	while (EXTCSS3_IS_WS(*intern->state.reader)) {
		_EXTCSS3_NEXT(intern, error);
	}

	token->data.len = intern->state.reader - token->data.str;

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-a-token (U+0023 NUMBER SIGN (#))
 */
static inline bool _extcss3_fill_hash_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error)
{
	token->type = EXTCSS3_TYPE_HASH;
	token->flag = EXTCSS3_FLAG_UNRESTRICTED;
	token->data.str = intern->state.reader;

	if (EXTCSS3_SUCCESS == _extcss3_check_start_ident(intern->state.reader + 1)) {
		token->flag = EXTCSS3_FLAG_ID;
	}

	if (EXTCSS3_SUCCESS != _extcss3_consume_name(intern, error)) {
		return EXTCSS3_FAILURE;
	}

	token->data.len = intern->state.reader - token->data.str;

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-a-token (U+0040 COMMERCIAL AT (@))
 */
static inline bool _extcss3_fill_at_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error)
{
	token->type = EXTCSS3_TYPE_AT_KEYWORD;
	token->data.str = intern->state.reader;

	if (EXTCSS3_SUCCESS != _extcss3_consume_name(intern, error)) {
		return EXTCSS3_FAILURE;
	}

	token->data.len = intern->state.reader - token->data.str;

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-a-token (U+002F SOLIDUS (/))
 */
static inline bool _extcss3_fill_comment_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error)
{
	token->type = EXTCSS3_TYPE_COMMENT;
	token->data.str = intern->state.reader;

	// Consume '/' and '*'
	_EXTCSS3_NEXT(intern, error);
	_EXTCSS3_NEXT(intern, error);

	while ((*intern->state.reader != '\0') && ((*intern->state.reader != '*') || (intern->state.reader[1] != '/'))) {
		_EXTCSS3_NEXT(intern, error);
	}

	// Consume '*' and '/'
	if (*intern->state.reader != '\0') {
		_EXTCSS3_NEXT(intern, error);

		if (*intern->state.reader != '\0') {
			_EXTCSS3_NEXT(intern, error);
		}
	}

	token->data.len = intern->state.reader - token->data.str;

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-a-unicode-range-token
 */
static inline bool _extcss3_fill_unicode_range_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error)
{
	unsigned int i, q;

	token->type = EXTCSS3_TYPE_UNICODE_RANGE;
	token->data.str = intern->state.reader;

	// Consume 'U' and '+'
	_EXTCSS3_NEXT(intern, error);
	_EXTCSS3_NEXT(intern, error);

	for (i = 0, q = 0; i < 6; i++) {
		if (!EXTCSS3_IS_HEX(*intern->state.reader)) {
			if (*intern->state.reader == '?') {
				q++;
			} else {
				break;
			}
		}

		_EXTCSS3_NEXT(intern, error);
	}

	// While the standard would require us to interpret/decode the start and the end of
	// the range, the string representation is good enough for now. We are not a parser.

	if (q || (*intern->state.reader != '-') || !EXTCSS3_IS_HEX(intern->state.reader[1])) {
		token->data.len = intern->state.reader - token->data.str;
	} else {
		_EXTCSS3_NEXT(intern, error);

		for (i = 0; i < 6; i++) {
			if (!EXTCSS3_IS_HEX(*intern->state.reader)) {
				break;
			}

			_EXTCSS3_NEXT(intern, error);
		}

		token->data.len = intern->state.reader - token->data.str;
	}

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-an-ident-like-token
 */
static inline bool _extcss3_fill_ident_like_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error)
{
	token->data.str = intern->state.reader;

	if (EXTCSS3_SUCCESS != _extcss3_consume_name(intern, error)) {
		return EXTCSS3_FAILURE;
	}

	if (*intern->state.reader == '(') {
		if (
			((intern->state.reader - token->data.str) == 3) &&
			EXTCSS3_CHARS_EQ(token->data.str[0], 'u') &&
			EXTCSS3_CHARS_EQ(token->data.str[1], 'r') &&
			EXTCSS3_CHARS_EQ(token->data.str[2], 'l')
		) {
			return _extcss3_fill_url_token(intern, token, error);
		} else {
			token->type = EXTCSS3_TYPE_FUNCTION;
			token->data.len = intern->state.reader - token->data.str;

			// Consume the '(' after the function name
			_EXTCSS3_NEXT(intern, error);
		}
	} else {
		token->type = EXTCSS3_TYPE_IDENT;
		token->data.len = intern->state.reader - token->data.str;
	}

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-a-url-token
 */
static inline bool _extcss3_fill_url_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error)
{
	extcss3_token tmp;

	// Consume the '(' after "url"
	_EXTCSS3_NEXT(intern, error);

	// Consume all leading whitespace
	while (EXTCSS3_IS_WS(*intern->state.reader)) {
		_EXTCSS3_NEXT(intern, error);
	}

	token->type = EXTCSS3_TYPE_URL;
	token->data.str = intern->state.reader;

	if (*intern->state.reader == '\0') {
		token->data.len = 0;
	} else if ((*intern->state.reader == '"') || (*intern->state.reader == '\'')) {
		if (EXTCSS3_SUCCESS != _extcss3_fill_string_token(intern, &tmp, error)) {
			return EXTCSS3_FAILURE;
		}

		if (tmp.type == EXTCSS3_TYPE_BAD_STRING) {
			token->type = EXTCSS3_TYPE_BAD_URL;

			if (EXTCSS3_SUCCESS != _extcss3_consume_bad_url_remnants(intern, error)) {
				return EXTCSS3_FAILURE;
			}

			token->data.len = intern->state.reader - token->data.str;
		} else {
			token->data.str = tmp.data.str;
			token->data.len = tmp.data.len;

			token->flag = EXTCSS3_FLAG_STRING;
			token->info.str = token->data.str;
			token->info.len = 1;

			// Consume all trailing whitespace
			while (EXTCSS3_IS_WS(*intern->state.reader)) {
				_EXTCSS3_NEXT(intern, error);
			}

			if ((*intern->state.reader == ')') || (*intern->state.reader == '\0')) {
				_EXTCSS3_NEXT(intern, error);
			} else {
				token->type = EXTCSS3_TYPE_BAD_URL;

				if (EXTCSS3_SUCCESS != _extcss3_consume_bad_url_remnants(intern, error)) {
					return EXTCSS3_FAILURE;
				}

				token->data.len = intern->state.reader - token->data.str;
			}
		}
	} else {
		while (1) {
			token->data.len = intern->state.reader - token->data.str;

			if ((*intern->state.reader == ')') || (*intern->state.reader == '\0')) {
				return _extcss3_next_char(intern, error);
			} else if (EXTCSS3_IS_WS(*intern->state.reader)) {
				// Consume all trailing whitespace
				while (EXTCSS3_IS_WS(*intern->state.reader)) {
					_EXTCSS3_NEXT(intern, error);
				}

				if ((*intern->state.reader == ')') || (*intern->state.reader == '\0')) {
					return _extcss3_next_char(intern, error);
				} else {
					token->type = EXTCSS3_TYPE_BAD_URL;

					if (EXTCSS3_SUCCESS != _extcss3_consume_bad_url_remnants(intern, error)) {
						return EXTCSS3_FAILURE;
					}

					token->data.len = intern->state.reader - token->data.str;

					return EXTCSS3_SUCCESS;
				}
			} else if (
				(*intern->state.reader == '"')	||
				(*intern->state.reader == '\'')	||
				(*intern->state.reader == '(')	||
				EXTCSS3_NON_PRINTABLE(*intern->state.reader)
			) {
				token->type = EXTCSS3_TYPE_BAD_URL;

				if (EXTCSS3_SUCCESS != _extcss3_consume_bad_url_remnants(intern, error)) {
					return EXTCSS3_FAILURE;
				}

				token->data.len = intern->state.reader - token->data.str;

				return EXTCSS3_SUCCESS;
			} else if (*intern->state.reader == '\\') {
				if (EXTCSS3_SUCCESS == _extcss3_check_start_valid_escape(intern->state.reader)) {
					if (EXTCSS3_SUCCESS != _extcss3_consume_escaped(intern, error)) {
						return EXTCSS3_FAILURE;
					}
				} else {
					token->type = EXTCSS3_TYPE_BAD_URL;

					if (EXTCSS3_SUCCESS != _extcss3_consume_bad_url_remnants(intern, error)) {
						return EXTCSS3_FAILURE;
					}

					token->data.len = intern->state.reader - token->data.str;

					return EXTCSS3_SUCCESS;
				}
			} else {
				_EXTCSS3_NEXT(intern, error);
			}
		}
	}

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-a-string-token
 */
static inline bool _extcss3_fill_string_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error)
{
	char *tmp = intern->state.reader;

	// Consume the opening '"' or '\''
	_EXTCSS3_NEXT(intern, error);

	token->type = EXTCSS3_TYPE_STRING;
	token->flag = EXTCSS3_FLAG_STRING;
	token->info.str = tmp;
	token->info.len = 1;

	while (true) {
		if ((*intern->state.reader == *tmp) || (*intern->state.reader == '\0')) {
			if (*intern->state.reader != '\0') {
				// Consume the closing '"' or '\''
				_EXTCSS3_NEXT(intern, error);
			}

			break;
		} else if (*intern->state.reader == '\n') {
			token->type = EXTCSS3_TYPE_BAD_STRING;

			break;
		} else if (*intern->state.reader == '\\') {
			if (intern->state.reader[1] == '\0') {
				// Consume the '\\'
				_EXTCSS3_NEXT(intern, error);

				break;
			} else if (intern->state.reader[1] == '\n') {
				_EXTCSS3_NEXT(intern, error);
			} else if (EXTCSS3_SUCCESS == _extcss3_check_start_valid_escape(intern->state.reader)) {
				if (EXTCSS3_SUCCESS != _extcss3_consume_escaped(intern, error)) {
					return EXTCSS3_FAILURE;
				}

				continue; // Do not move the reader pointer to the next character
			}
		}

		_EXTCSS3_NEXT(intern, error);
	}

	token->data.str = tmp;
	token->data.len = intern->state.reader - tmp;

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-a-numeric-token
 */
static inline bool _extcss3_fill_number_token(extcss3_intern *intern, extcss3_token *token, unsigned int *error)
{
	token->flag = EXTCSS3_FLAG_INTEGER;
	token->data.str = intern->state.reader;

	if ((*intern->state.reader == '+') || (*intern->state.reader == '-')) {
		_EXTCSS3_NEXT(intern, error);
	}

	while (EXTCSS3_IS_DIGIT(*intern->state.reader)) {
		_EXTCSS3_NEXT(intern, error);
	}

	if ((*intern->state.reader == '.') && EXTCSS3_IS_DIGIT(intern->state.reader[1])) {
		_EXTCSS3_NEXT(intern, error);

		token->flag = EXTCSS3_FLAG_NUMBER;

		while (EXTCSS3_IS_DIGIT(*intern->state.reader)) {
			_EXTCSS3_NEXT(intern, error);
		}
	}

	if (EXTCSS3_CHARS_EQ(*intern->state.reader, 'e')) {
		if (EXTCSS3_IS_DIGIT(intern->state.reader[1])) {
			_EXTCSS3_NEXT(intern, error);

			token->flag = EXTCSS3_FLAG_NUMBER;

			while (EXTCSS3_IS_DIGIT(*intern->state.reader)) {
				_EXTCSS3_NEXT(intern, error);
			}
		} else if ((((intern->state.reader[1] == '+') || (intern->state.reader[1] == '-'))) && EXTCSS3_IS_DIGIT(intern->state.reader[2])) {
			_EXTCSS3_NEXT(intern, error);
			_EXTCSS3_NEXT(intern, error);

			token->flag = EXTCSS3_FLAG_NUMBER;

			while (EXTCSS3_IS_DIGIT(*intern->state.reader)) {
				_EXTCSS3_NEXT(intern, error);
			}
		}
	}

	// !!! The conversion to a number is intentionally skipped !!!

	if (*intern->state.reader == '%') {
		token->type = EXTCSS3_TYPE_PERCENTAGE;
		token->info.str = intern->state.reader;

		// Consume the '%'
		_EXTCSS3_NEXT(intern, error);

		token->info.len = intern->state.reader - token->info.str;
	} else if (EXTCSS3_SUCCESS == _extcss3_check_start_ident(intern->state.reader)) {
		token->type = EXTCSS3_TYPE_DIMENSION;
		token->info.str = intern->state.reader;

		if (EXTCSS3_SUCCESS != _extcss3_consume_name(intern, error)) {
			return EXTCSS3_FAILURE;
		}

		token->info.len = intern->state.reader - token->info.str;
	} else {
		token->type = EXTCSS3_TYPE_NUMBER;
	}

	token->data.len = intern->state.reader - token->data.str;

	return EXTCSS3_SUCCESS;
}

/* ==================================================================================================== */
/* CONSUMER */

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-an-escaped-code-point
 */
static inline bool _extcss3_consume_escaped(extcss3_intern *intern, unsigned int *error)
{
	unsigned int i, v;
	char hex[7];
	char *reader_start, *writer_start;

	reader_start = intern->state.reader;
	writer_start = intern->state.writer;

	// Consume '\\'
	if (EXTCSS3_SUCCESS != _extcss3_next_char(intern, error)) {
		return EXTCSS3_FAILURE;
	} else if (!EXTCSS3_IS_HEX(*intern->state.reader)) {
		return _extcss3_next_char(intern, error);
	}

	for (i = 0; i < 6; i++) {
		if (!EXTCSS3_IS_HEX(*intern->state.reader)) {
			break;
		}

		hex[i] = *intern->state.reader;

		_EXTCSS3_NEXT(intern, error);
	}

	hex[i] = '\0';

	if (EXTCSS3_IS_WS(*intern->state.reader)) {
		_EXTCSS3_NEXT(intern, error);

		i++;
	}

	v = (int)strtol(hex, NULL, 16);

	if ((v <= 0) || (v > EXTCSS3_MAX_ALLOWED_CP) || EXTCSS3_FOR_SURROGATE_CP(v)) {
		i++; // The '\\' has to be removed, too

		if (i != EXTCSS3_REPLACEMENT_LEN) {
			memmove(reader_start + EXTCSS3_REPLACEMENT_LEN, intern->state.reader, intern->state.writer - intern->state.reader + 1);
			memcpy(reader_start, EXTCSS3_REPLACEMENT_CHR, EXTCSS3_REPLACEMENT_LEN);

			intern->state.writer = writer_start + EXTCSS3_REPLACEMENT_LEN;
			intern->state.reader = reader_start + EXTCSS3_REPLACEMENT_LEN;
		} else {
			memcpy(reader_start, EXTCSS3_REPLACEMENT_CHR, EXTCSS3_REPLACEMENT_LEN);
		}
	}

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-the-remnants-of-a-bad-url
 */
static inline bool _extcss3_consume_bad_url_remnants(extcss3_intern *intern, unsigned int *error)
{
	while (true) {
		_EXTCSS3_NEXT(intern, error);

		if ((*intern->state.reader == ')') || (*intern->state.reader == '\0')) {
			return _extcss3_next_char(intern, error);
		} else if (EXTCSS3_SUCCESS == _extcss3_check_start_valid_escape(intern->state.reader)) {
			if (EXTCSS3_SUCCESS != _extcss3_consume_escaped(intern, error)) {
				return EXTCSS3_FAILURE;
			}
		}
	}

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#consume-a-name
 */
static inline bool _extcss3_consume_name(extcss3_intern *intern, unsigned int *error)
{
	while (true) {
		_EXTCSS3_NEXT(intern, error);

		if (EXTCSS3_SUCCESS == _extcss3_check_is_name(intern->state.reader)) {
			continue;
		} else if (EXTCSS3_SUCCESS == _extcss3_check_start_valid_escape(intern->state.reader)) {
			if (EXTCSS3_SUCCESS != _extcss3_consume_escaped(intern, error)) {
				return EXTCSS3_FAILURE;
			}

			if (EXTCSS3_SUCCESS != _extcss3_check_start_ident(intern->state.reader)) {
				break;
			}
		} else {
			break;
		}
	}

	return EXTCSS3_SUCCESS;
}

/* ==================================================================================================== */
/* CHECKER */

/**
 * https://www.w3.org/TR/css-syntax-3/#starts-with-a-valid-escape
 */
static inline bool _extcss3_check_start_valid_escape(const char *str)
{
	if ((*str != '\\') || (str[1] == '\n')) {
		return EXTCSS3_FAILURE;
	}

	return EXTCSS3_SUCCESS;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#name-start-code-point
 */
static inline bool _extcss3_check_start_name(const char *str)
{
	if ((*str == '_') || EXTCSS3_IS_LETTER(*str) || EXTCSS3_IS_NON_ASCII(*str)) {
		return EXTCSS3_SUCCESS;
	}

	return EXTCSS3_FAILURE;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#would-start-an-identifier
 */
static inline bool _extcss3_check_start_ident(char *str)
{
	if (*str == '-') {
		if (
			(EXTCSS3_SUCCESS == _extcss3_check_start_name(str + 1)) ||
			(EXTCSS3_SUCCESS == _extcss3_check_start_valid_escape(str + 1))
		) {
			return EXTCSS3_SUCCESS;
		}

		return EXTCSS3_FAILURE;
	} else if (
		(EXTCSS3_SUCCESS == _extcss3_check_start_name(str)) ||
		(EXTCSS3_SUCCESS == _extcss3_check_start_valid_escape(str))
	) {
		return EXTCSS3_SUCCESS;
	}

	return EXTCSS3_FAILURE;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#starts-with-a-number
 */
static inline bool _extcss3_check_start_number(const char *str)
{
	if ((*str == '+') || (*str == '-')) {
		if (EXTCSS3_IS_DIGIT(str[1])) {
			return EXTCSS3_SUCCESS;
		} else if ((str[1] == '.') && EXTCSS3_IS_DIGIT(str[2])) {
			return EXTCSS3_SUCCESS;
		}

		return EXTCSS3_FAILURE;
	} else if ((*str == '.') && EXTCSS3_IS_DIGIT(str[1])) {
		return EXTCSS3_SUCCESS;
	} else if (EXTCSS3_IS_DIGIT(*str)) {
		return EXTCSS3_SUCCESS;
	}

	return EXTCSS3_FAILURE;
}

/**
 * https://www.w3.org/TR/css-syntax-3/#name-code-point
 */
static inline bool _extcss3_check_is_name(const char *str)
{
	if ((EXTCSS3_SUCCESS == _extcss3_check_start_name(str)) || EXTCSS3_IS_DIGIT(*str) || (*str == '-')) {
		return EXTCSS3_SUCCESS;
	}

	return EXTCSS3_FAILURE;
}


text:
package org.openuap.cms.engine.generate.impl;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.openuap.base.util.StringUtil;
import org.openuap.cms.config.CMSConfig;
import org.openuap.cms.engine.PublishEngineMode;
import org.openuap.cms.engine.generate.CmsStaticFileGenerateEngine;
import org.openuap.cms.node.manager.NodeManager;
import org.openuap.cms.node.model.Node;
import org.openuap.cms.psn.manager.PsnManager;
import org.openuap.cms.psn.model.Psn;
import org.openuap.cms.publish.manager.ExtraPublishManager;
import org.openuap.cms.publish.model.ExtraPublish;
import org.openuap.cms.repo.manager.DynamicContentManager;
import org.openuap.cms.repo.model.ContentIndex;
import org.openuap.cms.util.ui.PublishMode;
import org.openuap.runtime.util.ObjectLocator;
import org.openuap.tpl.engine.TemplateContext;
import org.openuap.tpl.engine.TemplateEngine;
import org.springframework.util.StringUtils;

/**
 *

 * 缺省CMS静态内容生成
 *

 *
 *

 * $Id: DefaultCmsStaticFileGenerateEngine.java 3924 2010-10-26 11:53:36Z
 * orangeforjava $
 *

 *
 * @author Weiping Ju
 *
 */
public class DefaultCmsStaticFileGenerateEngine implements
		CmsStaticFileGenerateEngine {

	private DynamicContentManager dynamicContentManager;

	private NodeManager nodeManager;

	private TemplateEngine templateEngine;

	private PsnManager psnManager;

	private ExtraPublishManager extraPublishManager;

	/*
	 * (non-Javadoc)
	 *
	 * @seeorg.openuap.cms.publish.engine.generate.CmsStaticFileGenerateEngine#
	 * generateAllNodeStaticFile(java.lang.Long,
	 * org.openuap.cms.publish.engine.PublishEngineMode, java.util.List)
	 */
	public void generateAllNodeStaticFile(Long parentId,
			PublishEngineMode mode, List errors) {

		// 处理首页
		if (mode.isContainIndex()) {
			generateNodeIndexStaticFile(parentId, errors);
		}
		// 处理附加发布
		if (mode.isContainExtraPublish()) {
			generateNodeAllExtraIndexStaticFile(parentId, errors);
		}
		// 处理内容页
		if (mode.isContainContent()) {
			//
			long publishNums = dynamicContentManager
					.getNodePublishContentCount(parentId);
			int pageSize = mode.getProcessContentNums();
			int totalPage = (int) (publishNums / pageSize);
			if (publishNums % pageSize > 0) {
				totalPage++;
			}
			//
			for (int i = 0; i < totalPage; i++) {
				List ciList = dynamicContentManager.getNodePublishContents(
						parentId, new Long(i * pageSize), new Long(pageSize));
				if (ciList != null) {
					for (int j = 0; j < ciList.size(); j++) {
						ContentIndex ci = (ContentIndex) ciList.get(j);
						//
						generateContentStaticFile(parentId, ci.getIndexId(),
								errors);
					}
				}
			}
		}
		// 递归处理子结点
		if (mode.isContainChildNode()) {
			List childNodes = nodeManager.getChildNodes(parentId);
			if (childNodes != null) {
				for (int i = 0; i < childNodes.size(); i++) {
					Node childNode = (Node) childNodes.get(i);
					//
					generateAllNodeStaticFile(childNode.getNodeId(), mode,
							errors);
				}
			}
		}
	}

	/*
	 *
	 */
	public void generateContentStaticFile(Long nodeId, Long indexId, List errors) {
		try {
			// 获得内容索引对象
			ContentIndex ci = dynamicContentManager
					.getContentIndexById(indexId);
			if (ci == null) {
				errors.add("the indexId=" + indexId
						+ " ContentIndex is not exits.");
				return;
			}
			//
			// 获得内容所在的结点
			Node node = nodeManager.getNode(nodeId);
			if (node == null) {
				errors.add("the nodeId=" + nodeId + " Node is not exits.");

				return;
			}
			generateContentStaticFile(node, ci, errors);
		} catch (Exception ex) {
			ex.printStackTrace();
			errors.add(ex);
		}
	}

	/*
	 * (non-Javadoc)
	 *
	 * @seeorg.openuap.cms.publish.engine.generate.CmsStaticFileGenerateEngine#
	 * generateNodeAllExtraIndexStaticFile(java.lang.Long, java.util.List)
	 */
	public void generateNodeAllExtraIndexStaticFile(Long nodeId, List errors) {
		List publishes = extraPublishManager.getPublishes(nodeId);
		if (publishes != null) {
			for (int i = 0; i < publishes.size(); i++) {
				generateNodeExtraIndexStaticFile(nodeId,
						(ExtraPublish) publishes.get(i), errors);
			}
		}
	}

	/*
	 * 附加发布
	 *
	 * @seeorg.openuap.cms.publish.engine.generate.CmsStaticFileGenerateEngine#
	 * generateNodeExtraIndexStaticFile(java.lang.Long, java.lang.Long,
	 * java.util.List)
	 */
	public void generateNodeExtraIndexStaticFile(Long nodeId, Long publishId,
			List errors) {
		// TODO 附加发布缓存添加
		ExtraPublish publish = extraPublishManager.getPublishById(publishId);
		if (publish != null) {
			generateNodeExtraIndexStaticFile(nodeId, publish, errors);
		}
	}

	protected synchronized void generateNodeExtraIndexStaticFile(Long nodeId,
			ExtraPublish publish, List errors) {
		Node node = nodeManager.getNode(nodeId);
		Integer publishMode = node.getPublishMode();
		Integer selfPublishMode = publish.getPublishMode();
		if (selfPublishMode != null && !selfPublishMode.equals(new Integer(-1))) {
			publishMode = selfPublishMode;
		}
		if (publishMode.equals(PublishMode.STATIC_MODE.getMode())) {
			// 只处理静态发布模式
			String tpl = publish.getTpl();
			//
			String psnUrl = publish.getSelfPsnUrl();
			//
			if (psnUrl == null) {
				// 如果自定义psnUrl
				psnUrl = node.getContentPsn();
			}
			//
			String url = psnManager.getPsnUrlInfo(psnUrl);
			String publishFileName = publish.getPublishFileName();
			publishFileName = publishFileName.replaceAll("\\{NodeID\\}", node
					.getNodeId().toString());

			publishFileName = publishFileName.replaceAll("\\{PublishID\\}",
					publish.getPublishId().toString());
			url = url + "/" + publishFileName;
			//
			TemplateContext context = new TemplateContext();
			context.setTplName(tpl);
			Map model = Collections.synchronizedMap(new HashMap());
			model.put("node", node);
			model.put("nodeId", nodeId);
			model.put("url", url);
			model.put("publish", publish);
			// 得到输出文件
			File outFile = getDestNodeExtraFile(publish, node);
			model.put("outFile", outFile);
			context.setModel(model);
			//
			getTemplateEngine().renderTemplate(context, errors);
		}
	}

	/*
	 * 更新结点首页
	 *
	 * @seeorg.openuap.cms.publish.engine.generate.CmsStaticFileGenerateEngine#
	 * generateNodeIndexStaticFile(java.lang.Long, java.util.List)
	 */
	public void generateNodeIndexStaticFile(Long nodeId, List errors) {
		Node node = nodeManager.getNode(nodeId);
		Integer publishMode = node.getPublishMode();
		if (publishMode.equals(PublishMode.STATIC_MODE.getMode())) {
			// 如果是静态发布模式
			String indexTpl = node.getIndexTpl();
			//
			//
			String url = psnManager.getPsnUrlInfo(node.getContentUrl());
			String indexFileName = node.getIndexName();
			indexFileName = indexFileName.replaceAll("\\{NodeID\\}", node
					.getNodeId().toString());
			url = url + "/" + indexFileName;
			// add function,if the url has change,should update the nodeUrl
			// value
			String nodeUrl = node.getNodeUrl();
			if (nodeUrl == null || !nodeUrl.equals(url)) {
				node.setNodeUrl(url);
				nodeManager.saveNode(node);
			}
			//

			TemplateContext context = new TemplateContext();
			context.setTplName(indexTpl);
			Map model = Collections.synchronizedMap(new HashMap());
			model.put("node", node);
			model.put("nodeId", nodeId);
			model.put("url", url);
			context.setModel(model);
			getTemplateEngine().renderTemplate(context, errors);

		}
	}

	/*
	 * (non-Javadoc)
	 *
	 * @seeorg.openuap.cms.publish.engine.generate.CmsStaticFileGenerateEngine#
	 * getContent(java.lang.Long, java.lang.Long, int, java.util.List)
	 */
	public String getContent(Long nodeId, Long indexId, int page, List errors,
			boolean preview) {
		try {
			// 获得内容索引对象
			ContentIndex ci = dynamicContentManager
					.getContentIndexById(indexId);
			if (ci == null) {
				return null;
			}
			//
			// 获得内容所在的结点
			Node node = nodeManager.getNode(nodeId);
			if (node == null) {
				return null;
			} else {
				Integer publishMode = node.getPublishMode();
				Integer selfPublishMode = ci.getPublishMode();
				//
				if (selfPublishMode != null
						&& !selfPublishMode.equals(new Integer(-1))) {
					publishMode = selfPublishMode;
				}
			}
			String tpl = null;
			String url = null;
			// 获得内容自定义模板
			String selfTpl = ci.getSelfTemplate();
			if (StringUtils.hasText(selfTpl)) {
				tpl = selfTpl;
			} else {
				// get from the node info
				String conentTpl = node.getContentTpl();
				tpl = conentTpl;
			}
			// get the psn url info,it will be used to some url link
			url = ci.getUrl();
			// 纠正url
			// String okUrl = getContentUrl(ci, node);
			// if (okUrl != null && !okUrl.equals(url)) {
			// url = okUrl;
			// ci.setUrl(okUrl);
			// dynamicContentManager.saveContentIndex(ci);
			// }
			// 产生内容
			TemplateContext context = new TemplateContext();
			context.setTplName(tpl);
			Map model = Collections.synchronizedMap(new HashMap());
			model.put("node", node);
			model.put("page", page);
			model.put("nodeId", nodeId);
			if (preview) {
				url=CMSConfig.getInstance().getBaseUrl()+"admin/publish.jhtml?action=Preview&nodeId="+nodeId+"&indexId="+indexId;
				model.put("url", url);
			} else {
				model.put("url", url);
			}
			model.put("ci", ci);
			if (preview) {
				model.put("__preview__", "true");
			}
			//
			model.put("__direct_out__", "yes");
			//
			context.setModel(model);
			getTemplateEngine().renderTemplate(context, errors);
			// 获取返回内容
			String content = context.getTplContent();
			return content;
		} catch (Exception ex) {
			ex.printStackTrace();
			errors.add(ex);
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 *
	 * @seeorg.openuap.cms.publish.engine.generate.CmsStaticFileGenerateEngine#
	 * getExtraContent(java.lang.Long, java.lang.Long, int, java.util.List)
	 */
	public String getExtraContent(Long nodeId, Long publishId, int page,
			List errors) {
		ExtraPublish publish = extraPublishManager.getPublishById(publishId);
		if (publish != null) {
			Node node = nodeManager.getNodeById(nodeId);

			String tpl = publish.getTpl();
			//
			String psnUrl = publish.getSelfPsnUrl();
			//
			if (psnUrl == null) {
				// 如果自定义psnUrl
				psnUrl = node.getContentPsn();
			}
			//
			String url = psnManager.getPsnUrlInfo(psnUrl);
			String publishFileName = publish.getPublishFileName();
			publishFileName = publishFileName.replaceAll("\\{NodeID\\}", node
					.getNodeId().toString());

			publishFileName = publishFileName.replaceAll("\\{PublishID\\}",
					publish.getPublishId().toString());
			url = url + "/" + publishFileName;
			//
			TemplateContext context = new TemplateContext();
			context.setTplName(tpl);
			Map model = Collections.synchronizedMap(new HashMap());
			model.put("node", node);
			model.put("nodeId", nodeId);
			model.put("url", url);
			model.put("publish", publish);
			model.put("__direct_out__", "yes");
			context.setModel(model);
			getTemplateEngine().renderTemplate(context, errors);
			String content = context.getTplContent();
			return content;
		}
		return null;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @seeorg.openuap.cms.publish.engine.generate.CmsStaticFileGenerateEngine#
	 * getNodeIndex(java.lang.Long, int, java.util.List)
	 */
	public String getNodeIndex(Long nodeId, int page, List errors) {
		Node node = nodeManager.getNodeById(nodeId);
		if (node != null) {

			String indexTpl = node.getIndexTpl();
			//
			// fix bug:node.getNodeUrl() should be node.getIndexPortalUrl();
			String url = psnManager.getPsnUrlInfo(node.getIndexPortalUrl());
			String indexFileName = node.getIndexName();
			indexFileName = indexFileName.replaceAll("\\{NodeID\\}", node
					.getNodeId().toString());
			url = url + "/" + indexFileName;
			// add function,if the url has change,should update the nodeUrl
			// value
			String nodeUrl = node.getNodeUrl();
			if (nodeUrl == null || !nodeUrl.equals(url)) {
				node.setNodeUrl(url);
				nodeManager.saveNode(node);
			}
			//
			TemplateContext context = new TemplateContext();
			context.setTplName(indexTpl);
			Map model = Collections.synchronizedMap(new HashMap());
			model.put("node", node);
			model.put("nodeId", nodeId);
			model.put("url", url);
			model.put("__direct_out__", "yes");
			context.setModel(model);
			getTemplateEngine().renderTemplate(context, errors);
			String content = context.getTplContent();
			return content;
		}
		return null;
	}

	/*
	 * 模板预览
	 *
	 * @seeorg.openuap.cms.publish.engine.generate.CmsStaticFileGenerateEngine#
	 * previewTemplate(java.lang.Long, java.lang.Long, java.lang.String,
	 * java.lang.Long, int, int, java.util.List)
	 */
	public String previewTemplate(Long nodeId, Long indexId, String tplContent,
			Long extraPublishId, int type, int page, List errors) {
		// TODO Auto-generated method stub
		return null;
	}

	public void setTemplateEngine(TemplateEngine templateEngine) {
		this.templateEngine = templateEngine;
	}

	public void setDynamicContentManager(
			DynamicContentManager dynamicContentManager) {
		this.dynamicContentManager = dynamicContentManager;
	}

	public void setNodeManager(NodeManager nodeManager) {
		this.nodeManager = nodeManager;
	}

	// //
	private String getContentUrl(ContentIndex contentIndex, Node node) {
		String url = "";
		// first look up the self url,if exist,it is,otherwise
		// from the node info,get the url info
		// after get the url,need get the file name
		// first get the self filename,if not exist,need get from the node info
		// from node info,include the path name and file name
		// cat the url and the file name is the finla url
		String selfUrl = contentIndex.getSelfUrl();
		String selfFileName = contentIndex.getSelfPublishFileName();
		long timeStamp = contentIndex.getPublishDate().longValue();
		if (StringUtils.hasText(selfUrl)) {
			// get from self url
			url = selfUrl;
			return url;
		} else {
			// get from node info,psn url defintion.
			String nodeUrl = node.getContentUrl();
			url = psnManager.getPsnUrlInfo(nodeUrl);
		}
		if (StringUtils.hasText(selfFileName)) {
			url += "/" + selfFileName;
		} else {
			String subDir = node.getSubDir();
			String destDir = this.getSubDirName(subDir, timeStamp);
			if (!destDir.equals("")) {
				url += "/" + destDir;
			}
			//
			// String stimeStamp = "" + timeStamp;
			String fileName = node.getPublishFileFormat();
			//
			fileName = getPublishFileName(fileName, timeStamp, contentIndex);
			if (!fileName.equals("")) {
				url += "/" + fileName;
			}
		}
		return url;
	}

	private String getSubDirName(String subDir, long timeStamp) {
		String destDir = "";
		if (StringUtils.hasText(subDir) && !subDir.equals("none")) {
			String ft = "yyyy-MM-dd";
			if (!subDir.equals("auto")) {
				subDir = subDir.replaceAll("Y", "yyyy");
				subDir = subDir.replaceAll("m", "MM");
				subDir = subDir.replaceAll("d", "dd");
				ft = subDir;
			}
			SimpleDateFormat sf = new SimpleDateFormat(ft);
			destDir = sf.format(new Date(timeStamp));
		}
		return destDir;
	}

	private String getPublishFileName(String fileName, long timeStamp,
			ContentIndex ci) {
		String destFileName = fileName;
		destFileName = destFileName.replaceAll("\\{TimeStamp\\}", ""
				+ timeStamp);
		destFileName = destFileName.replaceAll("\\{ContentID\\}", ci
				.getContentId().toString());

		destFileName = destFileName.replaceAll("\\{IndexID\\}", ci.getIndexId()
				.toString());
		destFileName = destFileName.replaceAll("\\{NodeID\\}", ci.getNodeId()
				.toString());
		return destFileName;
	}

	public File getDestDir(Long nodeId, Long indexId) {
		Node node = nodeManager.getNodeById(nodeId);
		ContentIndex ci = dynamicContentManager.getContentIndexById(indexId);

		CMSConfig config = CMSConfig.getInstance();
		String fullPath = "";
		String sysRootPath = config.getSysRootPath();
		String relativePath = "";
		String selfPsn = ci.getSelfPsn();
		if (StringUtils.hasText(selfPsn)) {
			relativePath = getRelativePath(selfPsn);
		} else {
			String pblPsn = node.getContentPsn();
			relativePath = getRelativePath(pblPsn);
		}
		if (!relativePath.equals("")) {
			fullPath = sysRootPath + "/" + relativePath;
		} else {
			fullPath = sysRootPath;
		}
		// sub dir
		String fileName = "";
		String selfFileName = ci.getSelfPublishFileName();
		//
		if (StringUtils.hasText(selfFileName)) {
			//
			int pos = selfFileName.lastIndexOf("/");
			String subDir = "";

			if (pos > -1) {
				subDir = selfFileName.substring(0, pos);
				fullPath += "/" + subDir;
				fileName = selfFileName.substring(pos + 1);
			} else {
				fileName = selfFileName;
			}

		} else {
			String subDir = node.getSubDir();
			String destDir = "";
			destDir = getDestDirName(subDir, ci);
			if (!destDir.equals("")) {
				fullPath += "/" + destDir;
			}
			fileName = getDestFileName(indexId, node, ci);
		}
		//
		fullPath = StringUtil.normalizePath(fullPath);
		//
		File psnDir = new File(fullPath);
		return psnDir;
	}

	/**
	 * 获得指定内容对应的文件
	 */
	public File getDestFile(Long nodeId, Long indexId) {
		try {
			Node node = nodeManager.getNode(nodeId);
			ContentIndex ci = dynamicContentManager
					.getContentIndexById(indexId);

			CMSConfig config = CMSConfig.getInstance();
			String fullPath = "";
			String sysRootPath = config.getSysRootPath();
			String relativePath = "";
			String selfPsn = ci.getSelfPsn();
			if (StringUtils.hasText(selfPsn)) {
				relativePath = getRelativePath(selfPsn);
			} else {
				String pblPsn = node.getContentPsn();
				relativePath = getRelativePath(pblPsn);
			}
			if (!relativePath.equals("")) {
				fullPath = sysRootPath + "/" + relativePath;
			} else {
				fullPath = sysRootPath;
			}
			// sub dir
			String fileName = "";
			String selfFileName = ci.getSelfPublishFileName();
			//
			if (StringUtils.hasText(selfFileName)) {
				//
				int pos = selfFileName.lastIndexOf("/");
				String subDir = "";

				if (pos > -1) {
					subDir = selfFileName.substring(0, pos);
					fullPath += "/" + subDir;
					fileName = selfFileName.substring(pos + 1);
				} else {
					fileName = selfFileName;
				}

			} else {
				String subDir = node.getSubDir();
				String destDir = "";
				destDir = getDestDirName(subDir, ci);
				if (!destDir.equals("")) {
					fullPath += "/" + destDir;
				}
				fileName = getDestFileName(indexId, node, ci);
			}
			//
			fullPath = StringUtil.normalizePath(fullPath);
			File psnDir = new File(fullPath);
			if (!psnDir.exists()) {
				psnDir.mkdirs();
			}
			File destFile = new File(psnDir, fileName);
			return destFile;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}

	}

	private String getDestFileName(Long indexId, Node node, ContentIndex ci) {
		String fileName = "";
		ci.getPublishDate().longValue();
		long timeStamp = ci.getPublishDate().longValue();
		String stimeStamp = "" + timeStamp;
		fileName = node.getPublishFileFormat();
		//
		fileName = fileName.replaceAll("\\{TimeStamp\\}", stimeStamp);
		fileName = fileName.replaceAll("\\{ContentID\\}", ci.getContentId()
				.toString());
		fileName = fileName.replaceAll("\\{IndexID\\}", indexId.toString());
		fileName = fileName.replaceAll("\\{NodeID\\}", ci.getNodeId()
				.toString());
		return fileName;
	}

	private String getDestDirName(String subDir, ContentIndex ci) {
		String destDir = "";
		if (subDir != null && !subDir.equals("") && subDir.equals("none")) {
			String ft = "yyyy-MM-dd";
			if (!subDir.equals("auto")) {
				subDir = subDir.replaceAll("Y", "yyyy");
				subDir = subDir.replaceAll("m", "MM");
				subDir = subDir.replaceAll("d", "dd");
				ft = subDir;
			}
			SimpleDateFormat sf = new SimpleDateFormat(ft);
			long publishDate = ci.getPublishDate().longValue(); // * 1000l;
			destDir = sf.format(new Date(publishDate));
		}
		return destDir;
	}

	private String getRelativePath(String selfPsn) throws NumberFormatException {
		String relativePath = "";
		String sp = "\\{PSN:(\\d+)\\}((\\/\\p{Print}*\\s*)*)";
		Pattern p = Pattern.compile(sp);
		Matcher m = p.matcher(selfPsn);
		boolean result = m.find();
		while (result) {
			String path = m.group(2);
			String psnId = m.group(1);
			Psn psn = psnManager.getPsnFromCache(new Long(psnId));
			// String psnUrl = psn.getPsn();
			if (psn.getType() == Psn.LOCAL_PSN_TYPE) {
				// now,only process the local
				// remote will be do later.
				relativePath = psn.getLocalPath();
				relativePath += "/" + path;
			}
			result = m.find();
		} // end while result
		return relativePath;
	}

	public ExtraPublishManager getExtraPublishManager() {
		return extraPublishManager;
	}

	public void setExtraPublishManager(ExtraPublishManager extraPublishManager) {
		this.extraPublishManager = extraPublishManager;
	}

	public PsnManager getPsnManager() {
		return psnManager;
	}

	public void setPsnManager(PsnManager psnManager) {
		this.psnManager = psnManager;
	}

	public DynamicContentManager getDynamicContentManager() {
		return dynamicContentManager;
	}

	public NodeManager getNodeManager() {
		return nodeManager;
	}

	/**
	 * 获取模板引擎插件
	 *
	 * @return
	 */
	public TemplateEngine getTemplateEngine() {
		if (templateEngine == null) {
			templateEngine = (TemplateEngine) ObjectLocator.lookup(
					"templateEngine", "org.openuap.tpl.engine");
		}
		return templateEngine;
	}

	/**
	 * 获得目标节点附加发布文件
	 *
	 * @param context
	 * @return
	 */
	protected File getDestNodeExtraFile(ExtraPublish publish, Node node) {
		String fullPath = "";
		CMSConfig config = CMSConfig.getInstance();
		String sysRootPath = config.getSysRootPath();
		String relativePath = "";
		String publishFileName = "";
		//
		if (publish == null || node == null) {
			return null;
		}

		String pblPsn = publish.getSelfPsn();
		if (StringUtils.hasText(pblPsn)) {
			relativePath = getRelativePath(pblPsn);
		}
		//
		if (relativePath.equals("")) {
			pblPsn = node.getContentPsn();
			relativePath = getRelativePath(pblPsn);
		}
		//
		if (!relativePath.equals("")) {
			fullPath = sysRootPath + "/" + relativePath;
		} else {
			fullPath = sysRootPath;
		}
		//

		if (publish != null) {
			publishFileName = publish.getPublishFileName();
		}
		//
		File destFile = new File(fullPath, publishFileName);
		return destFile;
	}

	public void generateContentStaticFile(Node node, ContentIndex ci,
			List errors) {
		try {

			if (ci == null) {
				return;
			}
			//
			// 获得内容所在的结点
			if (node == null) {
				return;
			} else {
				Integer publishMode = node.getPublishMode();
				Integer selfPublishMode = ci.getPublishMode();
				//
				if (selfPublishMode != null
						&& !selfPublishMode.equals(new Integer(-1))) {
					publishMode = selfPublishMode;
				}
				// 检查结点的发布模式,非静态发布结点不需要处理
				if (!publishMode.equals(PublishMode.STATIC_MODE.getMode())) {
					return;
				}
			}
			String tpl = null;
			String url = null;
			// 获得内容自定义模板
			String selfTpl = ci.getSelfTemplate();
			if (StringUtils.hasText(selfTpl)) {
				tpl = selfTpl;
			} else {
				// get from the node info
				String conentTpl = node.getContentTpl();
				tpl = conentTpl;
			}
			// get the psn url info,it will be used to some url link
			url = ci.getUrl();
			// 纠正url
			String okUrl = getContentUrl(ci, node);
			if (okUrl != null && !okUrl.equals(url)) {
				url = okUrl;
				ci.setUrl(okUrl);
				dynamicContentManager.saveContentIndex(ci);
			}
			// 产生静态文件
			TemplateContext context = new TemplateContext();
			context.setTplName(tpl);
			Map model = Collections.synchronizedMap(new HashMap());
			model.put("node", node);
			model.put("nodeId", node.getNodeId());
			model.put("url", url);
			model.put("ci", ci);
			context.setModel(model);
			getTemplateEngine().renderTemplate(context, errors);
		} catch (Exception ex) {
			ex.printStackTrace();
			errors.add(ex);
		}

	}
}


text:
package org.apache.harmony.nio.tests.java.nio;

import java.nio.IntBuffer;

public class HeapIntBufferTest extends IntBufferTest {
    protected void setUp() throws Exception {
        super.setUp();
        buf = IntBuffer.allocate(BUFFER_LENGTH);
        loadTestData1(buf);
        baseBuf = buf;
    }

    protected void tearDown() throws Exception {
        super.tearDown();
        buf = null;
        baseBuf = null;
    }

    public void testAllocatedIntBuffer_IllegalArg() {
        try {
            IntBuffer.allocate(-1);
            fail("Should throw Exception"); //$NON-NLS-1$
        } catch (IllegalArgumentException e) {
            // expected
        }
    }
}


text:
package com.drew.metadata.exif;

import com.drew.lang.annotations.NotNull;
import com.drew.lang.annotations.Nullable;
import com.drew.metadata.TagDescriptor;

/**
 * Provides human-readable string representations of tag values stored in a CasioType2MakernoteDirectory.
 *
 * @author Drew Noakes http://drewnoakes.com
 */
public class CasioType2MakernoteDescriptor extends TagDescriptor<CasioType2MakernoteDirectory>
{
    public CasioType2MakernoteDescriptor(@NotNull CasioType2MakernoteDirectory directory)
    {
        super(directory);
    }

    @Nullable
    public String getDescription(int tagType)
    {
        switch (tagType) {
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_THUMBNAIL_DIMENSIONS:
                return getThumbnailDimensionsDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_THUMBNAIL_SIZE:
                return getThumbnailSizeDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_THUMBNAIL_OFFSET:
                return getThumbnailOffsetDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_QUALITY_MODE:
                return getQualityModeDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_IMAGE_SIZE:
                return getImageSizeDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_FOCUS_MODE_1:
                return getFocusMode1Description();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_ISO_SENSITIVITY:
                return getIsoSensitivityDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_WHITE_BALANCE_1:
                return getWhiteBalance1Description();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_FOCAL_LENGTH:
                return getFocalLengthDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_SATURATION:
                return getSaturationDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_CONTRAST:
                return getContrastDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_SHARPNESS:
                return getSharpnessDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_PRINT_IMAGE_MATCHING_INFO:
                return getPrintImageMatchingInfoDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_CASIO_PREVIEW_THUMBNAIL:
                return getCasioPreviewThumbnailDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_WHITE_BALANCE_BIAS:
                return getWhiteBalanceBiasDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_WHITE_BALANCE_2:
                return getWhiteBalance2Description();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_OBJECT_DISTANCE:
                return getObjectDistanceDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_FLASH_DISTANCE:
                return getFlashDistanceDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_RECORD_MODE:
                return getRecordModeDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_SELF_TIMER:
                return getSelfTimerDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_QUALITY:
                return getQualityDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_FOCUS_MODE_2:
                return getFocusMode2Description();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_TIME_ZONE:
                return getTimeZoneDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_BESTSHOT_MODE:
                return getBestShotModeDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_CCD_ISO_SENSITIVITY:
                return getCcdIsoSensitivityDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_COLOUR_MODE:
                return getColourModeDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_ENHANCEMENT:
                return getEnhancementDescription();
            case CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_FILTER:
                return getFilterDescription();
            default:
                return super.getDescription(tagType);
        }
    }

    @Nullable
    public String getFilterDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_FILTER);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "Off";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getEnhancementDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_ENHANCEMENT);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "Off";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getColourModeDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_COLOUR_MODE);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "Off";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getCcdIsoSensitivityDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_CCD_ISO_SENSITIVITY);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "Off";
            case 1:
                return "On";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getBestShotModeDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_BESTSHOT_MODE);
        if (value==null)
            return null;
        switch (value) {
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getTimeZoneDescription()
    {
        return _directory.getString(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_TIME_ZONE);
    }

    @Nullable
    public String getFocusMode2Description()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_FOCUS_MODE_2);
        if (value==null)
            return null;
        switch (value) {
            case 1:
                return "Fixation";
            case 6:
                return "Multi-Area Focus";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getQualityDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_QUALITY);
        if (value==null)
            return null;
        switch (value) {
            case 3:
                return "Fine";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getSelfTimerDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_SELF_TIMER);
        if (value==null)
            return null;
        switch (value) {
            case 1:
                return "Off";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getRecordModeDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_RECORD_MODE);
        if (value==null)
            return null;
        switch (value) {
            case 2:
                return "Normal";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getFlashDistanceDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_FLASH_DISTANCE);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "Off";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getObjectDistanceDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_OBJECT_DISTANCE);
        if (value==null)
            return null;
        return Integer.toString(value) + " mm";
    }

    @Nullable
    public String getWhiteBalance2Description()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_WHITE_BALANCE_2);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "Manual";
            case 1:
                return "Auto"; // unsure about this
            case 4:
                return "Flash"; // unsure about this
            case 12:
                return "Flash";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getWhiteBalanceBiasDescription()
    {
        return _directory.getString(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_WHITE_BALANCE_BIAS);
    }

    @Nullable
    public String getCasioPreviewThumbnailDescription()
    {
        final byte[] bytes = _directory.getByteArray(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_CASIO_PREVIEW_THUMBNAIL);
        if (bytes==null)
            return null;
        return "<" + bytes.length + " bytes of image data>";
    }

    @Nullable
    public String getPrintImageMatchingInfoDescription()
    {
        // TODO research PIM specification http://www.ozhiker.com/electronics/pjmt/jpeg_info/pim.html
        return _directory.getString(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_PRINT_IMAGE_MATCHING_INFO);
    }

    @Nullable
    public String getSharpnessDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_SHARPNESS);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "-1";
            case 1:
                return "Normal";
            case 2:
                return "+1";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getContrastDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_CONTRAST);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "-1";
            case 1:
                return "Normal";
            case 2:
                return "+1";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getSaturationDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_SATURATION);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "-1";
            case 1:
                return "Normal";
            case 2:
                return "+1";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getFocalLengthDescription()
    {
        Double value = _directory.getDoubleObject(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_FOCAL_LENGTH);
        if (value==null)
            return null;
        return Double.toString(value / 10d) + " mm";
    }

    @Nullable
    public String getWhiteBalance1Description()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_WHITE_BALANCE_1);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "Auto";
            case 1:
                return "Daylight";
            case 2:
                return "Shade";
            case 3:
                return "Tungsten";
            case 4:
                return "Florescent";
            case 5:
                return "Manual";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getIsoSensitivityDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_ISO_SENSITIVITY);
        if (value==null)
            return null;
        switch (value) {
            case 3:
                return "50";
            case 4:
                return "64";
            case 6:
                return "100";
            case 9:
                return "200";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getFocusMode1Description()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_FOCUS_MODE_1);
        if (value==null)
            return null;
        switch (value) {
            case 0:
                return "Normal";
            case 1:
                return "Macro";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getImageSizeDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_IMAGE_SIZE);
        if (value==null)
            return null;
        switch (value) {
            case 0:  return "640 x 480 pixels";
            case 4:  return "1600 x 1200 pixels";
            case 5:  return "2048 x 1536 pixels";
            case 20: return "2288 x 1712 pixels";
            case 21: return "2592 x 1944 pixels";
            case 22: return "2304 x 1728 pixels";
            case 36: return "3008 x 2008 pixels";
            default: return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getQualityModeDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_QUALITY_MODE);
        if (value==null)
            return null;
        switch (value) {
            case 1:
                return "Fine";
            case 2:
                return "Super Fine";
            default:
                return "Unknown (" + value + ")";
        }
    }

    @Nullable
    public String getThumbnailOffsetDescription()
    {
        return _directory.getString(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_THUMBNAIL_OFFSET);
    }

    @Nullable
    public String getThumbnailSizeDescription()
    {
        Integer value = _directory.getInteger(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_THUMBNAIL_SIZE);
        if (value==null)
            return null;
        return Integer.toString(value) + " bytes";
    }

    @Nullable
    public String getThumbnailDimensionsDescription()
    {
        int[] dimensions = _directory.getIntArray(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_THUMBNAIL_DIMENSIONS);
        if (dimensions==null || dimensions.length!=2)
            return _directory.getString(CasioType2MakernoteDirectory.TAG_CASIO_TYPE2_THUMBNAIL_DIMENSIONS);
        return dimensions[0] + " x " + dimensions[1] + " pixels";
    }
}


text:
"""
Rename a font.

Changes font menu name and filename. User can also specify their
own output path.

Usage:
gftools rename-font font.ttf "New Family Name"
"""
import argparse
from fontTools.ttLib import TTFont
from gftools.utils import font_familyname
from gftools.fix import rename_font

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("font")
    parser.add_argument("new_name")
    parser.add_argument("-o", "--out")
    args = parser.parse_args()

    font = TTFont(args.font)
    current_name = font_familyname(font)
    rename_font(font, args.new_name)

    if args.out:
        out = args.out
    else:
        out = args.font.replace(
            current_name.replace(" ", ""), args.new_name.replace(" ", "")
        )
    print("Saving font: {}".format(out))
    font.save(out)

if __name__ == "__main__":
    main()


text:
<?php

namespace Kendoctor\Bundle\TestBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Paper
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Kendoctor\Bundle\TestBundle\Entity\PaperRepository")
 */
class Paper
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="title", type="string", length=50)
     */
    private $title;

    /**
     * @var string
     *
     * @ORM\Column(name="description", type="text")
     */
    private $description;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="createdAt", type="datetime")
     */
    private $createdAt;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="updatedAt", type="datetime")
     */
    private $updatedAt;

    /**
     * @var boolean
     *
     * @ORM\Column(name="isPublished", type="boolean")
     */
    private $isPublished;

    /**
     *
     * @var Kendoctor\Bundle\TestBundle\Entity\ItemGroup ItemGroups
     *
     * @ORM\OneToMany(targetEntity="ItemGroup", mappedBy="Paper", cascade={"all"})
     */
    private $ItemGroups;

    public function __construct()
    {
        $this->isPublished = false;
        $this->createdAt = new \DateTime();
        $this->updatedAt = new \DateTime();
        $this->ItemGroups = new \Doctrine\Common\Collections\ArrayCollection();
    }
    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set title
     *
     * @param string $title
     * @return Paper
     */
    public function setTitle($title)
    {
        $this->title = $title;

        return $this;
    }

    /**
     * Get title
     *
     * @return string
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set description
     *
     * @param string $description
     * @return Paper
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     * @return Paper
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set updatedAt
     *
     * @param \DateTime $updatedAt
     * @return Paper
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    /**
     * Get updatedAt
     *
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    /**
     * Set isPublished
     *
     * @param boolean $isPublished
     * @return Paper
     */
    public function setIsPublished($isPublished)
    {
        $this->isPublished = $isPublished;

        return $this;
    }

    /**
     * Get isPublished
     *
     * @return boolean
     */
    public function getIsPublished()
    {
        return $this->isPublished;
    }

    /**
     * Add ItemGroups
     *
     * @param \Kendoctor\Bundle\TestBundle\Entity\ItemGroup $itemGroup
     * @return Paper
     */
    public function addItemGroup(\Kendoctor\Bundle\TestBundle\Entity\ItemGroup $itemGroup)
    {
        $this->ItemGroups[] = $itemGroup;
        $itemGroup->setPaper($this);
        return $this;
    }

    /**
     * Remove ItemGroups
     *
     * @param \Kendoctor\Bundle\TestBundle\Entity\ItemGroup $itemGroups
     */
    public function removeItemGroup(\Kendoctor\Bundle\TestBundle\Entity\ItemGroup $itemGroups)
    {
        $this->ItemGroups->removeElement($itemGroups);
    }

    /**
     * Get ItemGroups
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getItemGroups()
    {
        return $this->ItemGroups;
    }

    public function setItemGroups(\Doctrine\Common\Collections\Collection  $itemGroups)
    {
        foreach($itemGroups as $itemGroup)
        {
            $this->addItemGroup($itemGroup);
        }
    }

    public function __toString()
    {
        return $this->title;
    }

}


text:
/**
 * main.css
 * (c) 2015 Michael Dominice
 * main.css is freely distributable under the MIT license.
 */
html, body {
    height: 100%;
}

body {
    padding-top: 100px;
}


text:
def extractOrientalrabbitWordpressCom(item):
	'''
	Parser for 'orientalrabbit.wordpress.com'
	'''

	vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
	if not (chp or vol) or "preview" in item['title'].lower():
		return None

	tagmap = [
		('tmrw',       'How Many Tomorrows There Are',                      'translated'),
		('scgl',       'Side Character Survival Guidelines',                'translated'),
		('wlwm',       'A White Lotus Host Who Does Not Want To Be a White Moonlight Is Not a Good Host',                      'translated'),
		('ralp',       'I Ran Away after I was Forced into a Love Polygon',                      'translated'),
		('PRC',       'PRC',                      'translated'),
		('Loiterous', 'Loiterous',                'oel'),
	]

	for tagname, name, tl_type in tagmap:
		if tagname in item['tags']:
			return buildReleaseMessageWithType(item, name, vol, chp, frag=frag, postfix=postfix, tl_type=tl_type)

	return False