text:
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of TomoForm
 *
 * @author holivares
 */
// src/Inei/Bundle/PayrollBundle/Form/Type/TomoType.php

namespace Inei\Bundle\PayrollBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;

class PlanillaType2 extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {
        $folio = $options['folio'];
        $builder->add('codiEmplPer', 'text', array(
                    'attr' => array(
                        'data-title' => 'NOMBRES Y APELLIDOS',
                        'class' => 'nombre',
                        'style' => 'width:200px;'
                    ),
                    'max_length' => 100
                ))
                ->add('registro', 'hidden', array(
                ))
                ->add('codigos', 'hidden', array(
                ))
                ->add('descripcion', 'textarea', array(
                    'attr' => array(
                        'data-title' => 'OBSERVACION',
                        'class' => 'descripcion',
                        'style' => 'width:200px;'
                    ),
                    'required' => false
                ));

        $builder->addEventListener(
                FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($folio) {
                    $form = $event->getForm();
                    $campos = array();
                    $formOptions = array();
                    foreach ($folio->getConceptos() as $value) {
                        $concepto = $value->getCodiConcTco();
                        $formOptions['label'] = $concepto->getCodiConcTco();
                       // $formOptions['data'] = '0';
                        $formOptions['attr'] = array(
                            'data-title' => $concepto->getDescCortTco(),
                            'class' => 'monto',
                            'style' => 'width:150px;font-size:10px;'
                        );
                        $formOptions['attr']['placeholder'] = $concepto->getDescCortTco();
                        if(array_key_exists($concepto->getCodiConcTco(), $campos)){
                            $campos[$concepto->getCodiConcTco()] += 1;
                        } else {
                            $campos[$concepto->getCodiConcTco()] = 1;
                        }
                        $index = $campos[$concepto->getCodiConcTco()];
                        $flag = '_'.$index;//($index>1)?'_'.$index:'';
                        $form->add($concepto->getCodiConcTco().$flag, 'text', $formOptions);
                    }
                }
        );
    }

    public function getName() {
        return 'planilla2';
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            //'data_class' => 'Inei\Bundle\PayrollBundle\Entity\PlanillaHistoricas',
            'csrf_protection' => true,
            'csrf_field_name' => '_token',
            'method' => 'post',
            // a unique key to help generate the secret token
        ));

        $resolver->setRequired(array(
            'folio',
        ));

        $resolver->setAllowedTypes(array(
            'folio' => 'Inei\Bundle\PayrollBundle\Entity\Folios',
        ));
    }

}


text:
<TEMPLATE ID="l2_loco2" FORMAT="WRAPPER">

<ELEMENT ID="CQLVLCZ" SUB="LINK_TEXT_COLOR" TYPE="READONLY" LOAD="THEME::LINK_TEXT_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCY" SUB="DISCLAIMER_TEXT_COLOR" TYPE="READONLY" LOAD="THEME::DISCLAIMER_TEXT_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCX" SUB="TABLE_HEADING_TEXT_COLOR" TYPE="READONLY" LOAD="THEME::TABLE_HEADING_TEXT_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCW" SUB="TABLE_HEADING_FONT_FACE" TYPE="READONLY" LOAD="THEME::TABLE_HEADING_FONT_FACE" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCV" SUB="DISCLAIMER_BACKGROUND_COLOR" TYPE="READONLY" LOAD="THEME::DISCLAIMER_BACKGROUND_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCU" SUB="ALERT_COLOR" TYPE="READONLY" LOAD="THEME::ALERT_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCT" SUB="CONTENT_FONT_SIZE" TYPE="READONLY" LOAD="THEME::CONTENT_FONT_SIZE" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCS" SUB="LINK_ACTIVE_TEXT_COLOR" TYPE="READONLY" LOAD="THEME::LINK_ACTIVE_TEXT_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCR" SUB="TABLE_LISTING_BACKGROUND_COLOR_ALTERNATE" TYPE="READONLY" LOAD="THEME::TABLE_LISTING_BACKGROUND_COLOR_ALTERNATE" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCQ" SUB="TABLE_HEADING_BACKGROUND_COLOR" TYPE="READONLY" LOAD="THEME::TABLE_HEADING_BACKGROUND_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCP" SUB="PRETTY_NAME" TYPE="READONLY" LOAD="THEME::PRETTY_NAME" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCO" SUB="DISCLAIMER_FONT_FACE" TYPE="READONLY" LOAD="THEME::DISCLAIMER_FONT_FACE" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCN" SUB="NAME" TYPE="READONLY" LOAD="THEME::NAME" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCM" SUB="CONTENT_FONT_FACE" TYPE="READONLY" LOAD="THEME::CONTENT_FONT_FACE" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCL" SUB="TABLE_LISTING_FONT_FACE" TYPE="READONLY" LOAD="THEME::TABLE_LISTING_FONT_FACE" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCK" SUB="TABLE_LISTING_TEXT_COLOR" TYPE="READONLY" LOAD="THEME::TABLE_LISTING_TEXT_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCJ" SUB="TABLE_LISTING_FONT_SIZE" TYPE="READONLY" LOAD="THEME::TABLE_LISTING_FONT_SIZE" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCI" SUB="CONTENT_TEXT_COLOR" TYPE="READONLY" LOAD="THEME::CONTENT_TEXT_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCH" SUB="TABLE_LISTING_BACKGROUND_COLOR" TYPE="READONLY" LOAD="THEME::TABLE_LISTING_BACKGROUND_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCG" SUB="CONTENT_BACKGROUND_COLOR" TYPE="READONLY" LOAD="THEME::CONTENT_BACKGROUND_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCF" SUB="DISCLAIMER_FONT_SIZE" TYPE="READONLY" LOAD="THEME::DISCLAIMER_FONT_SIZE" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCE" SUB="TABLE_HEADING_FONT_SIZE" TYPE="READONLY" LOAD="THEME::TABLE_HEADING_FONT_SIZE" RAW="1"></ELEMENT>
<ELEMENT ID="CQLVLCD" SUB="LINK_VISITED_TEXT_COLOR" TYPE="READONLY" LOAD="THEME::LINK_VISITED_TEXT_COLOR" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXC" SUB="HOMECATEGORY_URL" TYPE="READONLY" LOAD="URL::HOMECATEGORY_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXD" SUB="WRAPPER_URL" TYPE="READONLY" LOAD="URL::WRAPPER_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXE" SUB="CART_URL" TYPE="READONLY" LOAD="URL::CART_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXF" SUB="SUBSCRIBE_URL" TYPE="READONLY" LOAD="URL::SUBSCRIBE_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXG" SUB="FEEDBACK_URL" TYPE="READONLY" LOAD="URL::FEEDBACK_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXH" SUB="LOGOUT_FUNCTION_URL" TYPE="READONLY" LOAD="URL::LOGOUT_FUNCTION_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXI" SUB="SHIPQUOTE_URL" TYPE="READONLY" LOAD="URL::SHIPQUOTE_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXJ" SUB="PRIVACY_URL" TYPE="READONLY" LOAD="URL::PRIVACY_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXK" SUB="SITEBUTTON_URL" TYPE="READONLY" LOAD="URL::SITEBUTTON_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXL" SUB="HOMEPAGE_URL" TYPE="READONLY" LOAD="URL::HOMEPAGE_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXM" SUB="COUNTER_URL" TYPE="READONLY" LOAD="URL::COUNTER_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXN" SUB="RETURNS_URL" TYPE="READONLY" LOAD="URL::RETURNS_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXO" SUB="PASSWORD_URL" TYPE="READONLY" LOAD="URL::PASSWORD_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXP" SUB="UPDATE_PAYMENT_URL" TYPE="READONLY" LOAD="URL::UPDATE_PAYMENT_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXQ" SUB="FORGOT_URL" TYPE="READONLY" LOAD="URL::FORGOT_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXR" SUB="NAVBUTTON_URL" TYPE="READONLY" LOAD="URL::NAVBUTTON_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXS" SUB="CONTACT_URL" TYPE="READONLY" LOAD="URL::CONTACT_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXT" SUB="LOGOUT_URL" TYPE="READONLY" LOAD="URL::LOGOUT_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXU" SUB="GALLERY_URL" TYPE="READONLY" LOAD="URL::GALLERY_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXV" SUB="REMOVE_URL" TYPE="READONLY" LOAD="URL::REMOVE_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXW" SUB="HOME_URL" TYPE="READONLY" LOAD="URL::HOME_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXX" SUB="ABOUT_ZOOVY_URL" TYPE="READONLY" LOAD="URL::ABOUT_ZOOVY_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXY" SUB="NEWS_URL" TYPE="READONLY" LOAD="URL::NEWS_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIXZ" SUB="SECURE_URL" TYPE="READONLY" LOAD="URL::SECURE_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYA" SUB="ABOUT_URL" TYPE="READONLY" LOAD="URL::ABOUT_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYB" SUB="USERBUTTON_URL" TYPE="READONLY" LOAD="URL::USERBUTTON_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYC" SUB="CLOSED_URL" TYPE="READONLY" LOAD="URL::CLOSED_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYD" SUB="FASTORDER_URL" TYPE="READONLY" LOAD="URL::FASTORDER_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYE" SUB="MAIL_FORM_URL" TYPE="READONLY" LOAD="URL::MAIL_FORM_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYF" SUB="GRAPHICS_URL" TYPE="READONLY" LOAD="URL::GRAPHICS_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYG" SUB="IMAGE_URL" TYPE="READONLY" LOAD="URL::IMAGE_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYH" SUB="CONTACTUS_URL" TYPE="READONLY" LOAD="URL::CONTACTUS_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYI" SUB="DYNAMIC_URL" TYPE="READONLY" LOAD="URL::DYNAMIC_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYJ" SUB="NONSECURE_URL" TYPE="READONLY" LOAD="URL::NONSECURE_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYK" SUB="CONTACT_US_URL" TYPE="READONLY" LOAD="URL::CONTACT_US_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYL" SUB="SEARCH_URL" TYPE="READONLY" LOAD="URL::SEARCH_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYM" SUB="ABOUTUS_URL" TYPE="READONLY" LOAD="URL::ABOUTUS_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYN" SUB="CUSTOMER_MAIN_URL" TYPE="READONLY" LOAD="URL::CUSTOMER_MAIN_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYO" SUB="MERCHANT_LOGIN_URL" TYPE="READONLY" LOAD="URL::MERCHANT_LOGIN_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYP" SUB="CATEGORY_URL" TYPE="READONLY" LOAD="URL::CATEGORY_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYQ" SUB="ADULT_URL" TYPE="READONLY" LOAD="URL::ADULT_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYR" SUB="CLAIM_URL" TYPE="READONLY" LOAD="URL::CLAIM_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYS" SUB="CLAIM_MULTI_URL" TYPE="READONLY" LOAD="URL::CLAIM_MULTI_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYT" SUB="ABOUT_US_URL" TYPE="READONLY" LOAD="URL::ABOUT_US_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYU" SUB="RESULTS_URL" TYPE="READONLY" LOAD="URL::RESULTS_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYV" SUB="PRODUCT_URL" TYPE="READONLY" LOAD="URL::PRODUCT_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYW" SUB="CONTINUE_URL" TYPE="READONLY" LOAD="URL::CONTINUE_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYX" SUB="REDIR_URL" TYPE="READONLY" LOAD="URL::REDIR_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYY" SUB="KILL_COOKIES_URL" TYPE="READONLY" LOAD="URL::KILL_COOKIES_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIYZ" SUB="LOGIN_URL" TYPE="READONLY" LOAD="URL::LOGIN_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIZA" SUB="CHECKOUT_URL" TYPE="READONLY" LOAD="URL::CHECKOUT_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIZB" SUB="ORDER_STATUS_URL" TYPE="READONLY" LOAD="URL::ORDER_STATUS_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIZC" SUB="NO_COOKIES_URL" TYPE="READONLY" LOAD="URL::NO_COOKIES_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIZD" SUB="PAYPAL_URL" TYPE="READONLY" LOAD="URL::PAYPAL_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIZE" SUB="CANCEL_ORDER_URL" TYPE="READONLY" LOAD="URL::CANCEL_ORDER_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIZF" SUB="WISHLIST_URL" TYPE="READONLY" LOAD="URL::WISHLIST_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIZG" SUB="MAIL_CONFIG_URL" TYPE="READONLY" LOAD="URL::MAIL_CONFIG_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIZH" SUB="DISABLED_URL" TYPE="READONLY" LOAD="URL::DISABLED_URL" RAW="1"></ELEMENT>
<ELEMENT ID="CQQZIZI" COLORS="128" TYPE="CONFIG" CATEGORIES="16400" CREATED="20020328" TITLE="loco2" OCREATED="20020328" PROPERTIES="2" SUBTYPE="C"><CSS><![CDATA[.zbody {  background-color: #304D5E; }
.zborder {  border: 1px solid #CCCCCC; }
.zbox {  border: 1px solid #304D5E; }
.zbox_body {  background-color: #5B90B0; color: #000000; font-family: Arial, Helvetica; font-size: 11pt; }
.zbox_head {  background-color: #304D5E; color: #FFFF00; font-family: Arial, Helvetica; font-size: 11pt; }
.zcolor {  background-color: #304d5e; color: #ffff00; }
.zcolor_contrast {  background-color: #afccdd; color: #10107f; }
.zcolor_dark {  background-color: #000d1e; color: #bfbf00; }
.zcolor_light {  background-color: #708d9e; color: #ffff40; }
.zform_button {  background-color: #708d9e; border: 1px solid #000d1e; color: #000d1e; font-family: Arial, Helvetica; font-size: 8pt; }
.zform_select {  background-color: #FFFFFF; border: 1px solid #000d1e; color: #000000; font-family: Arial, Helvetica; font-size: 8pt; }
.zform_textarea {  background-color: #FFFFFF; border: 1px solid #000d1e; color: #000000; font-family: Arial, Helvetica; font-size: 8pt; }
.zform_textbox {  background-color: #FFFFFF; border: 1px solid #000d1e; color: #000000; font-family: Arial, Helvetica; font-size: 8pt; }
.zhint {  color: #FFFFFF; font-family: Arial, Helvetica; font-size: 8pt; }
.zlink {  color: #1E00FC; }
.zsmall {  color: #FFFFFF; font-family: Arial, Helvetica; font-size: 8pt; }
.ztab0 {  background-color: #cdffff; color: #404040; font-family: Arial, Helvetica; font-size: 9pt; }
.ztab1 {  background-color: #5B90B0; color: #000000; font-family: Arial, Helvetica; font-size: 9pt; font-weight: bold; }
.ztabbody {  background-color: #304D5E; color: #FFFF00; font-family: Arial, Helvetica; font-size: 8pt; }
.ztable_head {  background-color: #304D5E; color: #FFFF00; font-family: Arial, Helvetica; font-size: 11pt; }
.ztable_row {  color: #000000; font-family: Arial, Helvetica; font-size: 11pt; }
.ztable_row0 {  background-color: #5B90B0; color: #000000; font-family: Arial, Helvetica; font-size: 11pt; }
.ztable_row1 {  background-color: #8DCFF7; color: #000000; font-family: Arial, Helvetica; font-size: 11pt; }
.ztable_row_small {  color: #000000; font-family: Arial, Helvetica; font-size: 8pt; }
.ztable_row_title {  color: #000000; font-family: Arial, Helvetica; font-size: 13pt; font-weight: bold; }
.ztitle {  color: #FFFFFF; font-family: Arial, Helvetica; font-size: 12pt; font-weight: bold; }
.ztitle2 {  color: #FFFFFF; font-family: Arial, Helvetica; font-size: 11pt; font-weight: bold; }
.ztxt {  color: #FFFFFF; font-family: Arial, Helvetica; font-size: 11pt; }
.zwarn {  color: #FF0000; font-weight: bold; }
]]></CSS>
<THEME><![CDATA[alert_color=FF0000&content_background_color=304D5E&content_font_face=Arial%2c+Helvetica&content_font_size=3&content_text_color=FFFFFF&disclaimer_background_color=304D5E&disclaimer_font_face=Arial%2c+Helvetica&disclaimer_font_size=1&disclaimer_text_color=FFFFFF&link_active_text_color=1E00FC&link_text_color=1E00FC&link_visited_text_color=1E00FC&name=&pretty_name=&table_heading_background_color=304D5E&table_heading_font_face=Arial%2c+Helvetica&table_heading_font_size=3&table_heading_text_color=FFFF00&table_listing_background_color=5B90B0&table_listing_background_color_alternate=8DCFF7&table_listing_font_face=Arial%2c+Helvetica&table_listing_font_size=3&table_listing_text_color=000000]]></THEME>
<SITEBUTTONS><![CDATA[forward=l2_loco2|gif|67|20&add_to_cart=l2_loco2|gif|91|20&back=l2_loco2|gif|68|20&default=l2_loco2|gif|88|20&add_to_site=l2_loco2|gif|122|32&checkout=l2_loco2|gif|75|20&continue_shopping=l2_loco2|gif|141|20&update_cart=l2_loco2|gif|94|20&cancel=l2_loco2|gif|55|20]]></SITEBUTTONS>
</ELEMENT>
<ELEMENT ID="CQQZIZJ" TYPE="OUTPUT"><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

]]>
</ELEMENT>
<ELEMENT ID="CQQZIZK" TYPE="HEAD"></ELEMENT>
<ELEMENT ID="CQQZIZL" TYPE="OUTPUT"><![CDATA[
<map name="right">
	<area href="%CART_URL%" shape="RECT" coords="28,85,73,107" alt="Shopping Cart">
	<area href="%SEARCH_URL%" shape="RECT" coords="80,85,139,107" alt="Search">
	<area href="%ABOUT_URL%" shape="RECT" coords="153,85,224,107" alt="About Us">
	<area href="%CONTACT_URL%" shape="RECT" coords="238,85,324,107" alt="Contact Us">
</map>

								]]>
</ELEMENT>
<ELEMENT ID="CQQZIZP" HEIGHT="80" WIDTH="300" TYPE="LOGO"></ELEMENT>
<ELEMENT ID="CQQZIZQ" TYPE="OUTPUT"><![CDATA[

								]]>
</ELEMENT>
<ELEMENT ID="CQQZIZR" WIDTH="150" TYPE="MENU" BUTTONTYPE="l2_loco2_off"><![CDATA[

<a href="<% load($cat_url);  default("");  print(); %>" OnMouseOver="on(<% load($cat_num);  default("");  print(); %>)" OnMouseOut="off(<% load($cat_num);  default("");  print(); %>)"><img src="<% load($button_imgsrc);  default("");  print(); %>" width="<% load($button_width);  default("");  print(); %>" height="<% load($button_height);  default("");  print(); %>" border="0" name="roll_<% load($cat_num);  default("");  print(); %>">

]]>
</ELEMENT>
<ELEMENT ID="CQQZIZS" TYPE="OUTPUT"><![CDATA[

					]]>
</ELEMENT>
<ELEMENT ID="CQQZIZT" TYPE="SIDEBAR"></ELEMENT>
<ELEMENT ID="CQQZIZU" TYPE="OUTPUT"><![CDATA[

								 ]]>
</ELEMENT>
<ELEMENT ID="CQQZIZV" TYPE="TITLE"></ELEMENT>
<ELEMENT ID="CQQZIZW" TYPE="OUTPUT"><![CDATA[

]]>
</ELEMENT>
<ELEMENT ID="CQQZIZX" TYPE="BODY"></ELEMENT>
<ELEMENT ID="CQQZIZY" TYPE="OUTPUT"><![CDATA[

]]>
</ELEMENT>
<ELEMENT ID="CQQZIZZ" TYPE="FOOTER" TRANSPARENT="TRUE"></ELEMENT>
<ELEMENT ID="CQQZJAA" TYPE="OUTPUT"><![CDATA[

]]>
</ELEMENT>

</TEMPLATE>

redpajama_set_name: RedPajamaGithub


text:
<extends:toolkit:form.field/>

<block:element>

        @if(injected('add-icon'))

        @endif
        <input
                inputID:consume
                id="${id}"
                data-input="true"
                class="form-control @if(inject('error')) is-invalid@endif@if(inject('success')) is-valid@endif@if(injected('class')) ${class}@endif"
                type="${type|password}"
                name="${name}"
                placeholder="${placeholder}"
                value="${value}${context}"
                @if(injected('maxlength'))
                  maxlength="${maxlength}"
                @endif
                @if(injected('minlength'))
                  minlength="${minlength}"
                @endif
                @if(injected('pattern'))
                  pattern="${pattern}"
                @endif
                @if(injected('autocomplete'))
                  autocomplete="${autocomplete}"
                @endif
                @if(injected('disabled'))disabled @endif
        />

</block:element>


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Encycl. Méth. Bot. 1(1): 104 (1783)

#### Original name
Amanita vinosa Lam.

### Remarks
null


text:
package com.opengamma.financial.analytics.model.volatility.surface.black;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.threeten.bp.Period;

import com.opengamma.OpenGammaRuntimeException;
import com.opengamma.analytics.financial.model.interestrate.curve.ForwardCurve;
import com.opengamma.analytics.financial.model.volatility.smile.fitting.sabr.ForexSmileDeltaSurfaceDataBundle;
import com.opengamma.analytics.financial.model.volatility.smile.fitting.sabr.SmileSurfaceDataBundle;
import com.opengamma.analytics.financial.model.volatility.smile.fitting.sabr.StandardSmileSurfaceDataBundle;
import com.opengamma.core.marketdatasnapshot.VolatilitySurfaceData;
import com.opengamma.financial.analytics.volatility.surface.BloombergFXOptionVolatilitySurfaceInstrumentProvider.FXVolQuoteType;
import com.opengamma.util.time.Tenor;
import com.opengamma.util.tuple.ObjectsPair;
import com.opengamma.util.tuple.Pair;
import com.opengamma.util.tuple.Pairs;
import com.opengamma.util.tuple.Triple;

import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
import it.unimi.dsi.fastutil.doubles.DoubleLinkedOpenHashSet;
import it.unimi.dsi.fastutil.doubles.DoubleList;

/**
 *
 */
public class BlackVolatilitySurfaceUtils {
  private static final Logger LOGGER = LoggerFactory.getLogger(BlackVolatilitySurfaceUtils.class);

  public static double[] getUniqueExpiries(final VolatilitySurfaceData<Object, Object> volatilitySurface) {
    final double[] expiries = getArrayOfDoubles(volatilitySurface.getXs());
    final DoubleLinkedOpenHashSet expirySet = new DoubleLinkedOpenHashSet(expiries);
    final double[] uniqueExpiries = expirySet.toDoubleArray();
    Arrays.sort(uniqueExpiries);
    return uniqueExpiries;
  }

  public static Object[] getUniqueExpiriesWithData(final VolatilitySurfaceData<Object, Object> volatilitySurface) {
    final SortedSet<Object> uniqueXValues = volatilitySurface.getUniqueXValues();
    return uniqueXValues.toArray(new Object[uniqueXValues.size()]);
  }

  public static double[] getUniqueStrikes(final VolatilitySurfaceData<Object, Object> volatilitySurface) {
    final double[] strikes = getArrayOfDoubles(volatilitySurface.getYs());
    final DoubleLinkedOpenHashSet strikeSet = new DoubleLinkedOpenHashSet(strikes);
    final double[] uniqueStrikes = strikeSet.toDoubleArray();
    Arrays.sort(uniqueStrikes);
    return uniqueStrikes;
  }

  public static Pair<double[][], double[][]> getStrikesAndValues(final double[] expiries, final double[] strikes,
      final VolatilitySurfaceData<Object, Object> volatilitySurface) {
    final int nExpiries = expiries.length;
    final int nStrikes = strikes.length;
    final double[][] fullStrikes = new double[nExpiries][];
    final double[][] fullValues = new double[nExpiries][];
    for (int i = 0; i < nExpiries; i++) {
      final DoubleList availableStrikes = new DoubleArrayList();
      final DoubleList availableVols = new DoubleArrayList();
      for (int j = 0; j < nStrikes; j++) {
        final Double vol = volatilitySurface.getVolatility(expiries[i], strikes[j]);
        if (vol != null) {
          availableStrikes.add(strikes[j]);
          availableVols.add(vol);
        }
      }
      if (availableVols.size() == 0) {
        throw new OpenGammaRuntimeException("No volatility values found for expiry " + expiries[i]);
      }
      fullStrikes[i] = availableStrikes.toDoubleArray();
      fullValues[i] = availableVols.toDoubleArray();
    }
    return Pairs.of(fullStrikes, fullValues);
  }

  public static Triple<double[], double[][], double[][]> getStrikesAndValues(final double[] expiries, final double[] strikes,
      final VolatilitySurfaceData<Object, Object> volatilitySurface,
      final int minNumberOfStrikes) {
    final int nExpiries = expiries.length;
    final int nStrikes = strikes.length;
    final List<double[]> fullStrikes = new ArrayList<>();
    final List<double[]> fullValues = new ArrayList<>();
    final DoubleList availableExpiries = new DoubleArrayList();
    for (int i = 0; i < nExpiries; i++) {
      final DoubleList availableStrikes = new DoubleArrayList();
      final DoubleList availableVols = new DoubleArrayList();
      for (int j = 0; j < nStrikes; j++) {
        final Double vol = volatilitySurface.getVolatility(expiries[i], strikes[j]);
        if (vol != null) {
          availableStrikes.add(strikes[j]);
          availableVols.add(vol);
        }
      }
      if (availableVols.size() == 0) {
        throw new OpenGammaRuntimeException("No volatility values found for expiry " + expiries[i]);
      } else if (availableVols.size() >= minNumberOfStrikes) {
        availableExpiries.add(expiries[i]);
        fullStrikes.add(availableStrikes.toDoubleArray());
        fullValues.add(availableVols.toDoubleArray());
      }
    }
    return Triple.of(availableExpiries.toDoubleArray(), fullStrikes.toArray(new double[0][]), fullValues.toArray(new double[0][]));
  }

  public static Triple<double[], double[][], double[][]> getStrippedStrikesAndValues(final VolatilitySurfaceData<Object, Object> volatilitySurface) {
    final Object[] expiries = getUniqueExpiriesWithData(volatilitySurface);
    final Object[] strikeValues = volatilitySurface.getYs();
    final int nExpiries = expiries.length;
    final int nStrikes = strikeValues.length;
    final double[][] strikes = new double[nExpiries][];
    final double[][] values = new double[nExpiries][];
    for (int i = 0; i < nExpiries; i++) {
      final DoubleList availableStrikes = new DoubleArrayList();
      final DoubleList availableVols = new DoubleArrayList();
      for (int j = 0; j < nStrikes; j++) {
        final Double vol = volatilitySurface.getVolatility(expiries[i], strikeValues[j]);
        if (vol != null) {
          availableStrikes.add((Double) strikeValues[j]);
          availableVols.add(vol);
        }
      }
      strikes[i] = availableStrikes.toDoubleArray();
      values[i] = availableVols.toDoubleArray();
    }
    return Triple.of(getArrayOfDoubles(expiries), strikes, values);
  }

  public static SmileSurfaceDataBundle getDataFromStandardQuotes(final ForwardCurve forwardCurve,
      final VolatilitySurfaceData<Object, Object> volatilitySurface) {
    final double[] uniqueExpiries = getUniqueExpiries(volatilitySurface);
    final double[] uniqueStrikes = getUniqueStrikes(volatilitySurface);
    final Pair<double[][], double[][]> strikesAndValues = getStrikesAndValues(uniqueExpiries, uniqueStrikes, volatilitySurface);
    // Convert vols and strikes to double[][],
    // noting that different expiries may have different populated strikes
    return new StandardSmileSurfaceDataBundle(forwardCurve, uniqueExpiries, strikesAndValues.getFirst(), strikesAndValues.getSecond());
  }

  public static SmileSurfaceDataBundle getDataFromStandardQuotes(final ForwardCurve forwardCurve, final VolatilitySurfaceData<Object, Object> volatilitySurface,
      final int minNumberOfStrikes) {
    final double[] uniqueExpiries = getUniqueExpiries(volatilitySurface);
    final double[] uniqueStrikes = getUniqueStrikes(volatilitySurface);
    final Triple<double[], double[][], double[][]> strikesAndValues = getStrikesAndValues(uniqueExpiries, uniqueStrikes, volatilitySurface, minNumberOfStrikes);
    // Convert vols and strikes to double[][],
    // noting that different expiries may have different populated strikes
    return new StandardSmileSurfaceDataBundle(forwardCurve, strikesAndValues.getFirst(), strikesAndValues.getSecond(), strikesAndValues.getThird());
  }

  public static ForexSmileDeltaSurfaceDataBundle getDataFromStrangleRiskReversalQuote(final ForwardCurve forwardCurve,
      final VolatilitySurfaceData<Tenor, Pair<Number, FXVolQuoteType>> fxVolatilitySurface) {
    final Object[] tenors = fxVolatilitySurface.getXs();
    Arrays.sort(tenors);
    final Object[] quotes = fxVolatilitySurface.getYs();
    final Number[] deltaValues = getDeltaValues(quotes);
    final int nExpiries = tenors.length;
    final int nDeltas = deltaValues.length - 1;
    final double[] expiries = new double[nExpiries];
    final double[] deltas = new double[nDeltas];
    final double[] atms = new double[nExpiries];
    final double[][] riskReversals = new double[nDeltas][nExpiries];
    final double[][] strangle = new double[nDeltas][nExpiries];
    for (int i = 0; i < nExpiries; i++) {
      final Tenor tenor = (Tenor) tenors[i];
      final double t = getTime(tenor);
      final Double atm = fxVolatilitySurface.getVolatility(tenor, ObjectsPair.of(deltaValues[0], FXVolQuoteType.ATM));
      if (atm == null) {
        throw new OpenGammaRuntimeException("Could not get ATM volatility data for surface");
      }
      expiries[i] = t;
      atms[i] = atm;
    }
    for (int i = 0; i < nDeltas; i++) {
      final Number delta = deltaValues[i + 1];
      if (delta != null) {
        deltas[i] = delta.doubleValue() / 100.;
        final DoubleArrayList riskReversalList = new DoubleArrayList();
        final DoubleArrayList strangleList = new DoubleArrayList();
        for (int j = 0; j < nExpiries; j++) {
          final Double rr = fxVolatilitySurface.getVolatility((Tenor) tenors[j], ObjectsPair.of(delta, FXVolQuoteType.RISK_REVERSAL));
          final Double s = fxVolatilitySurface.getVolatility((Tenor) tenors[j], ObjectsPair.of(delta, FXVolQuoteType.BUTTERFLY));
          if (rr != null && s != null) {
            riskReversalList.add(rr);
            strangleList.add(s);
          } else {
            LOGGER.info("Had a null value for tenor number " + j);
          }
        }
        riskReversals[i] = riskReversalList.toDoubleArray();
        strangle[i] = strangleList.toDoubleArray();
      }
    }
    final boolean isCallData = true; // TODO this shouldn't be hard-coded
    return new ForexSmileDeltaSurfaceDataBundle(forwardCurve, expiries, deltas, atms, riskReversals, strangle, isCallData);
  }

  private static double getTime(final Tenor tenor) {
    final Period period = tenor.getPeriod();
    if (period.getYears() != 0) {
      return period.getYears();
    }
    if (period.getMonths() != 0) {
      return (double) period.getMonths() / 12;
    }
    if (period.getDays() != 0) {
      return (double) period.getDays() / 365;
    }
    throw new OpenGammaRuntimeException("Should never happen");
  }

  private static Number[] getDeltaValues(final Object[] quotes) {
    final TreeSet<Object> values = new TreeSet<>();
    for (final Object pair : quotes) {
      values.add(((Pair<?, ?>) pair).getFirst());
    }
    return values.toArray((Number[]) Array.newInstance(Number.class, values.size()));
  }

  private static double[] getArrayOfDoubles(final Object[] arrayOfObject) {
    final double[] expiries;
    // TODO there is sometimes a problem with Fudge, where a Double[] is transported as Object[]. Needs to be fixed
    final Object[] xData = arrayOfObject;
    final int n = xData.length;
    expiries = new double[n];
    for (int i = 0; i < n; i++) {
      final Object data = xData[i];
      if (data instanceof Double) {
        expiries[i] = (Double) xData[i];
      } else if (data instanceof Float) {
        expiries[i] = ((Float) xData[i]).doubleValue();
      } else if (data instanceof Long) {
        expiries[i] = ((Long) xData[i]).doubleValue();
      } else if (data instanceof Integer) {
        expiries[i] = ((Integer) xData[i]).doubleValue();
      } else if (data instanceof Byte) {
        expiries[i] = ((Byte) xData[i]).doubleValue();
      } else {
        throw new OpenGammaRuntimeException("Cannot cast " + data.getClass() + " to double");
      }
    }
    return expiries;
  }
}


text:
extern void db_ping();
extern void db_ping_wtp(const char *wtpid,const char *acid);

extern int db_init();
int db_start();
int db_get_tasks(struct conn * conn,const char * wtpid);
void db_put_wtp_prop(const char *wtp_id,const char * id,const char *sub_id,const char * val);
mavl_t db_get_update_tasks(struct conn * conn,const char * wtpid);

void db_put_radio_prop(const char *wtp_id,const char *rid, const char * key,const char *sub_key,const char * val);
extern mavl_t db_get_radio_tasks(struct conn * conn,const char * wtpid);

#endif


text:
package com.hss01248.imageloaderdemo;

import android.widget.ImageView;

/**
 * Created by Administrator on 2017/11/5.
 */

public class ScaleTypeInfo {

    ImageView.ScaleType scaleType;
    String scaleTypeStr;
    int resId;

    public ScaleTypeInfo(ImageView.ScaleType scaleType, String scaleTypeStr, int resId) {
        this.scaleType = scaleType;
        this.scaleTypeStr = scaleTypeStr;
        this.resId = resId;
    }
}


text:
using namespace snowcrash;
using namespace snowcrashtest;

const mdp::ByteBuffer ActionFixture
    = "# My Method [GET]\n\n"
      "Method Description\n\n"
      "+ Response 200 (text/plain)\n\n"
      "        OK.";

TEST_CASE("Method block classifier", "[action]")
{
    mdp::MarkdownParser markdownParser;
    mdp::MarkdownNode markdownAST;
    SectionType sectionType;
    markdownParser.parse(ActionFixture, markdownAST);

    REQUIRE(!markdownAST.children().empty());
    sectionType = SectionProcessor<Action>::sectionType(markdownAST.children().begin());
    REQUIRE(sectionType == ActionSectionType);

    // Nameless method
    markdownAST.children().front().text = "GET";
    REQUIRE(!markdownAST.children().empty());
    sectionType = SectionProcessor<Action>::sectionType(markdownAST.children().begin());
    REQUIRE(sectionType == ActionSectionType);
}

TEST_CASE("Parsing action", "[action]")
{
    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(ActionFixture, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    CHECK(action.report.warnings.empty());

    REQUIRE(action.node.name == "My Method");
    REQUIRE(action.node.method == "GET");
    REQUIRE(action.node.description == "Method Description");

    REQUIRE(action.node.examples.size() == 1);
    REQUIRE(action.node.examples.front().requests.size() == 0);
    REQUIRE(action.node.examples.front().responses.size() == 1);

    REQUIRE(action.node.examples.front().responses[0].name == "200");
    REQUIRE(action.node.examples.front().responses[0].body == "OK.\n");
    REQUIRE(action.node.examples.front().responses[0].headers.size() == 1);
    REQUIRE(action.node.examples.front().responses[0].headers[0].first == "Content-Type");
    REQUIRE(action.node.examples.front().responses[0].headers[0].second == "text/plain");

    SourceMapHelper::check(action.sourceMap.name.sourceMap, 0, 19);
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 19);
    SourceMapHelper::check(action.sourceMap.description.sourceMap, 19, 20);
    REQUIRE(action.sourceMap.examples.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[0].requests.collection.size() == 0);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection.size() == 1);

    SourceMapHelper::check(action.sourceMap.examples.collection[0].responses.collection[0].body.sourceMap, 72, 7);
    SourceMapHelper::check(action.sourceMap.examples.collection[0].responses.collection[0].name.sourceMap, 41, 27);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection[0].headers.collection.size() == 1);
    SourceMapHelper::check(
        action.sourceMap.examples.collection[0].responses.collection[0].headers.collection[0].sourceMap, 41, 27);
}

TEST_CASE("Parse named action with () in title", "[action]")
{
    mdp::ByteBuffer source
        = "# My Action (Deprecated) [GET]\n"
          "+ Response 204\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    CHECK(action.report.warnings.empty());

    REQUIRE(action.node.name == "My Action (Deprecated)");
    REQUIRE(action.node.method == "GET");
}

TEST_CASE("Parse named action with path including () in title", "[action]")
{
    mdp::ByteBuffer source
        = "# My Action (Deprecated) [GET /test]\n"
          "+ Response 204\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    CHECK(action.report.warnings.empty());

    REQUIRE(action.node.name == "My Action (Deprecated)");
    REQUIRE(action.node.method == "GET");
    REQUIRE(action.node.uriTemplate == "/test");
}

TEST_CASE("Parse named action with [] in title", "[action]")
{
    mdp::ByteBuffer source
        = "# My Action [DEPRECATED] [GET]\n"
          "+ Response 204\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    CHECK(action.report.warnings.empty());

    REQUIRE(action.node.name == "My Action [DEPRECATED]");
    REQUIRE(action.node.method == "GET");
}

TEST_CASE("Parse Action description with list", "[action]")
{
    mdp::ByteBuffer source
        = "# GET\n"
          "Small Description\n"
          "+ A\n"
          "+ B\n"
          "+ Response 204\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    CHECK(action.report.warnings.empty());

    REQUIRE(action.node.method == "GET");
    REQUIRE(action.node.description == "Small Description\n\n+ A\n\n+ B");

    REQUIRE(action.node.examples.size() == 1);
    REQUIRE(action.node.examples.front().responses.size() == 1);
    REQUIRE(action.node.examples.front().requests.empty());

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 6);
    SourceMapHelper::check(action.sourceMap.description.sourceMap, 6, 26);
    REQUIRE(action.sourceMap.examples.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[0].requests.collection.size() == 0);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection.size() == 1);
}

TEST_CASE("Parse method with multiple requests and responses", "[action]")
{
    mdp::ByteBuffer source
        = "# PUT\n"
          "+ Request A\n"
          "  B\n"
          "  + Body\n\n"
          "            C\n\n"
          "+ Request D\n"
          "  E\n"
          "  + Body\n\n"
          "            F\n\n"
          "+ Response 200\n"
          "  G\n"
          "  + Body\n\n"
          "            H\n\n"
          "+ Response 200\n"
          "  I\n"
          "  + Body\n\n"
          "            J\n\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.size() == 1); // warn responses with the same name

    REQUIRE(action.node.name.empty());
    REQUIRE(action.node.method == "PUT");
    REQUIRE(action.node.description.empty());
    REQUIRE(action.node.parameters.empty());

    REQUIRE(action.node.examples.size() == 1);
    REQUIRE(action.node.examples.front().requests.size() == 2);

    REQUIRE(action.node.examples.front().requests[0].name == "A");
    REQUIRE(action.node.examples.front().requests[0].description == "B");
    REQUIRE(action.node.examples.front().requests[0].body == "C\n");
    REQUIRE(action.node.examples.front().requests[0].schema.empty());
    REQUIRE(action.node.examples.front().requests[0].parameters.empty());
    REQUIRE(action.node.examples.front().requests[0].headers.empty());

    REQUIRE(action.node.examples.front().requests[1].name == "D");
    REQUIRE(action.node.examples.front().requests[1].description == "E");
    REQUIRE(action.node.examples.front().requests[1].body == "F\n");
    REQUIRE(action.node.examples.front().requests[1].schema.empty());
    REQUIRE(action.node.examples.front().requests[1].parameters.empty());
    REQUIRE(action.node.examples.front().requests[1].headers.empty());

    REQUIRE(action.node.examples.front().responses.size() == 2);

    REQUIRE(action.node.examples.front().responses[0].name == "200");
    REQUIRE(action.node.examples.front().responses[0].description == "G");
    REQUIRE(action.node.examples.front().responses[0].body == "H\n");
    REQUIRE(action.node.examples.front().responses[0].schema.empty());
    REQUIRE(action.node.examples.front().responses[0].parameters.empty());
    REQUIRE(action.node.examples.front().responses[0].headers.empty());

    REQUIRE(action.node.examples.front().responses[1].name == "200");
    REQUIRE(action.node.examples.front().responses[1].description == "I");
    REQUIRE(action.node.examples.front().responses[1].body == "J\n");
    REQUIRE(action.node.examples.front().responses[1].schema.empty());
    REQUIRE(action.node.examples.front().responses[1].parameters.empty());
    REQUIRE(action.node.examples.front().responses[1].headers.empty());

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 6);
    REQUIRE(action.sourceMap.description.sourceMap.empty());
    REQUIRE(action.sourceMap.examples.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[0].requests.collection.size() == 2);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection.size() == 2);
}

TEST_CASE("Parse method with multiple incomplete requests", "[action][blocks]")
{
    mdp::ByteBuffer source
        = "# GET /1\n"
          "+ Request A\n"
          "+ Request B\n"
          "  C\n"
          "+ Response 200\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.size() == 2); // empty asset & preformatted asset
    REQUIRE(action.report.warnings[0].code == EmptyDefinitionWarning);
    REQUIRE(action.report.warnings[1].code == IndentationWarning);

    REQUIRE(action.node.name.empty());
    REQUIRE(action.node.method == "GET");
    REQUIRE(action.node.description.empty());
    REQUIRE(action.node.parameters.empty());

    REQUIRE(action.node.examples.front().requests.size() == 2);
    REQUIRE(action.node.examples.front().requests[0].name == "A");
    REQUIRE(action.node.examples.front().requests[0].body.empty());
    REQUIRE(action.node.examples.front().requests[0].schema.empty());
    REQUIRE(action.node.examples.front().requests[0].parameters.empty());
    REQUIRE(action.node.examples.front().requests[0].headers.empty());

    REQUIRE(action.node.examples.front().requests[1].name == "B");
    REQUIRE(action.node.examples.front().requests[1].description.empty());
    REQUIRE(action.node.examples.front().requests[1].body == "C\n\n");
    REQUIRE(action.node.examples.front().requests[1].schema.empty());
    REQUIRE(action.node.examples.front().requests[1].parameters.empty());
    REQUIRE(action.node.examples.front().requests[1].headers.empty());

    REQUIRE(action.node.examples.front().responses.size() == 1);

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 9);
    REQUIRE(action.sourceMap.description.sourceMap.empty());
    REQUIRE(action.sourceMap.examples.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[0].requests.collection.size() == 2);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection.size() == 1);
}

TEST_CASE("Parse method with foreign item", "[action]")
{
    mdp::ByteBuffer source
        = "# MKCOL\n"
          "+ Request\n"
          "  + Body\n\n"
          "            Foo\n\n"
          "+ Bar\n"
          "+ Response 200\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.size() == 1);
    REQUIRE(action.report.warnings[0].code == IgnoringWarning);

    REQUIRE(action.node.name.empty());
    REQUIRE(action.node.method == "MKCOL");
    REQUIRE(action.node.description.empty());
    REQUIRE(action.node.parameters.empty());

    REQUIRE(action.node.examples.size() == 1);
    REQUIRE(action.node.examples.front().requests.size() == 1);
    REQUIRE(action.node.examples.front().requests[0].name.empty());
    REQUIRE(action.node.examples.front().requests[0].body == "Foo\n");
    REQUIRE(action.node.examples.front().requests[0].schema.empty());
    REQUIRE(action.node.examples.front().requests[0].parameters.empty());
    REQUIRE(action.node.examples.front().requests[0].headers.empty());
    REQUIRE(action.node.examples.front().responses.size() == 1);

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 8);
    REQUIRE(action.sourceMap.description.sourceMap.empty());
    REQUIRE(action.sourceMap.examples.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[0].requests.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection.size() == 1);
}

TEST_CASE("Parse method with a HR", "[action]")
{
    mdp::ByteBuffer source
        = "# PATCH /1\n\n"
          "A\n"
          "---\n"
          "B\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.size() == 1); // no response

    REQUIRE(action.node.name.empty());
    REQUIRE(action.node.method == "PATCH");
    REQUIRE(action.node.description == "A\n---\n\nB");
    REQUIRE(action.node.examples.empty());

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 12);
    SourceMapHelper::check(action.sourceMap.description.sourceMap, 12, 8);
    REQUIRE(action.sourceMap.examples.collection.size() == 0);
}

TEST_CASE("Parse method without name", "[action]")
{
    mdp::ByteBuffer source = "# GET";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.size() == 1); // no response

    REQUIRE(action.node.name.empty());
    REQUIRE(action.node.method == "GET");
    REQUIRE(action.node.description.empty());

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 5);
    REQUIRE(action.sourceMap.description.sourceMap.empty());
    REQUIRE(action.sourceMap.examples.collection.size() == 0);
}

TEST_CASE("Parse action with parameters", "[action]")
{
    mdp::ByteBuffer source
        = "# GET /resource/{id}\n"
          "+ Parameters\n"
          "    + id (required, number, `42`) ... Resource Id\n"
          "\n"
          "+ Response 204\n"
          "\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.empty());

    REQUIRE(action.node.parameters.size() == 1);
    REQUIRE(action.node.parameters[0].name == "id");
    REQUIRE(action.node.parameters[0].description == "Resource Id");
    REQUIRE(action.node.parameters[0].type == "number");
    REQUIRE(action.node.parameters[0].defaultValue.empty());
    REQUIRE(action.node.parameters[0].exampleValue == "42");
    REQUIRE(action.node.parameters[0].values.empty());

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 21);
    REQUIRE(action.sourceMap.description.sourceMap.empty());
    REQUIRE(action.sourceMap.parameters.collection.size() == 1);
    SourceMapHelper::check(action.sourceMap.parameters.collection[0].name.sourceMap, 40, 44);
    REQUIRE(action.sourceMap.examples.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[0].requests.collection.size() == 0);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection.size() == 1);
}

TEST_CASE("Give a warning when 2xx CONNECT has a body", "[action]")
{
    mdp::ByteBuffer source
        = "# CONNECT /1\n"
          "+ Response 201\n\n"
          "        {}\n\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.size() == 1);

    REQUIRE(action.node.method == "CONNECT");
    REQUIRE(action.node.examples.size() == 1);
    REQUIRE(action.node.examples[0].responses.size() == 1);
    REQUIRE(action.node.examples[0].responses[0].body == "{}\n");

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 13);
    REQUIRE(action.sourceMap.description.sourceMap.empty());
    REQUIRE(action.sourceMap.examples.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[0].requests.collection.size() == 0);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection.size() == 1);
}

TEST_CASE("Give a warning when response to HEAD has a body", "[action]")
{
    mdp::ByteBuffer source
        = "# HEAD /1\n"
          "+ Response 200\n\n"
          "        {}\n\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.size() == 1);
    REQUIRE(action.report.warnings[0].code == EmptyDefinitionWarning);

    REQUIRE(action.node.method == "HEAD");
    REQUIRE(action.node.examples.size() == 1);
    REQUIRE(action.node.examples[0].responses.size() == 1);
    REQUIRE(action.node.examples[0].responses[0].body == "{}\n");

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 10);
    REQUIRE(action.sourceMap.description.sourceMap.empty());
    REQUIRE(action.sourceMap.examples.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[0].requests.collection.size() == 0);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection.size() == 1);
}

TEST_CASE("Missing 'LINK' HTTP request method", "[action]")
{
    mdp::ByteBuffer source
        = "# LINK /1\n"
          "+ Response 204\n\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.empty());

    REQUIRE(action.node.examples.size() == 1);
    REQUIRE(action.node.examples[0].requests.empty());
    REQUIRE(action.node.examples[0].responses.size() == 1);

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 10);
    REQUIRE(action.sourceMap.description.sourceMap.empty());
    REQUIRE(action.sourceMap.examples.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[0].requests.collection.size() == 0);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection.size() == 1);
}

TEST_CASE("Warn when request is not followed by a response", "[action]")
{
    mdp::ByteBuffer source
        = "# GET /1\n"
          "+ response 200 \n"
          "\n"
          "        200\n"
          "\n"
          "+ request A\n"
          "\n"
          "        A\n";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.size() == 1);
    REQUIRE(action.report.warnings[0].code == EmptyDefinitionWarning);

    REQUIRE(action.node.examples.size() == 2);
    REQUIRE(action.node.examples[0].requests.size() == 0);
    REQUIRE(action.node.examples[0].responses.size() == 1);
    REQUIRE(action.node.examples[1].requests.size() == 1);
    REQUIRE(action.node.examples[1].responses.size() == 0);

    REQUIRE(action.sourceMap.name.sourceMap.empty());
    SourceMapHelper::check(action.sourceMap.method.sourceMap, 0, 9);
    REQUIRE(action.sourceMap.description.sourceMap.empty());
    REQUIRE(action.sourceMap.examples.collection.size() == 2);
    REQUIRE(action.sourceMap.examples.collection[0].requests.collection.size() == 0);
    REQUIRE(action.sourceMap.examples.collection[0].responses.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[1].requests.collection.size() == 1);
    REQUIRE(action.sourceMap.examples.collection[1].responses.collection.size() == 0);
}

// TODO: This test is failing because of a bug in action attributes. Need to fix the bug.
// TEST_CASE("Parse action attributes", "[action]")
// {
//    mdp::ByteBuffer source = \
//    "# GET /1\n\n"\
//    "+ attributes (Coupon)\n"\
//    "+ request A\n\n"\
//    "+ response 204\n\n"
//    "+ request B\n\n"\
//    "  + attributes (string)\n\n"\
//    "+ response 204";

//    ParseResult<Action> action;
//    NamedTypes namedTypes;

//    NamedTypeHelper::build("Coupon", mson::ObjectBaseType, namedTypes);
//    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption,
//    Models(), NULL, namedTypes);

//    REQUIRE(action.report.error.code == Error::OK);
//    REQUIRE(action.report.warnings.empty());

//    REQUIRE(action.node.attributes.source.typeDefinition.typeSpecification.name.symbol.literal == "Coupon");
//    REQUIRE(action.node.examples.size() == 2);
//    REQUIRE(action.node.examples[0].requests.size() == 1);
//    REQUIRE(action.node.examples[0].requests[0].attributes.source.empty());
//    REQUIRE(action.node.examples[0].responses.size() == 1);
//    REQUIRE(action.node.examples[1].requests.size() == 1);
//    REQUIRE(action.node.examples[1].requests[0].attributes.source.typeDefinition.typeSpecification.name.base ==
//    mson::StringTypeName);
//    REQUIRE(action.node.examples[1].responses.size() == 1);
// }

TEST_CASE("Named Endpoint", "[named_endpoint]")
{
    const mdp::ByteBuffer source
        = "# Group Test Group\n\n"
          "## My Named Endpoint [GET /test/endpoint]\n\n"
          "Endpoint Description\n\n"
          "+ Response 200 (text/plain)\n\n"
          "        OK.";

    ParseResult<Blueprint> blueprint;
    snowcrash::parse(source, 0, blueprint);

    REQUIRE(blueprint.report.error.code == Error::OK);
    REQUIRE(blueprint.report.warnings.empty());

    REQUIRE(blueprint.node.content.elements().size() == 1);
    REQUIRE(blueprint.node.content.elements().at(0).element == Element::CategoryElement);
    REQUIRE(blueprint.node.content.elements().at(0).content.elements().size() == 1);
    REQUIRE(blueprint.node.content.elements().at(0).content.elements().at(0).element == Element::ResourceElement);

    const Resource& resource = blueprint.node.content.elements().at(0).content.elements().at(0).content.resource;
    REQUIRE(resource.name == "My Named Endpoint");
    REQUIRE(resource.uriTemplate == "/test/endpoint");
    REQUIRE(resource.actions.size() == 1);

    Action action = resource.actions.at(0);
    REQUIRE(action.method == "GET");
}

TEST_CASE("Named Endpoints Edge Cases", "[named_endpoint]")
{
    const mdp::ByteBuffer source
        = "# Endpoint 1  [GET /e1]\n\n"
          "+ Response 204\n\n"
          "# Endpoint 2  [GET /e1]\n\n"
          "+ Response 204\n\n"
          "# Endpoint 3  [POST /e1]\n\n"
          "+ Response 204\n";

    ParseResult<Blueprint> blueprint;
    snowcrash::parse(source, 0, blueprint);

    REQUIRE(blueprint.report.error.code == Error::OK);
    REQUIRE(blueprint.report.warnings.size() == 2);

    REQUIRE(blueprint.report.warnings.at(0).code == DuplicateWarning);
    REQUIRE(blueprint.report.warnings.at(1).code == DuplicateWarning);

    REQUIRE(blueprint.node.content.elements().size() == 3);
    REQUIRE(blueprint.node.content.elements().at(0).element == Element::ResourceElement);
    REQUIRE(blueprint.node.content.elements().at(0).content.elements().size() == 0);
    REQUIRE(blueprint.node.content.elements().at(1).element == Element::ResourceElement);
    REQUIRE(blueprint.node.content.elements().at(1).content.elements().size() == 0);
    REQUIRE(blueprint.node.content.elements().at(2).element == Element::ResourceElement);
    REQUIRE(blueprint.node.content.elements().at(2).content.elements().size() == 0);

    {
        const Resource& resource = blueprint.node.content.elements().at(0).content.resource;
        REQUIRE(resource.name == "Endpoint 1");
        REQUIRE(resource.uriTemplate == "/e1");
        REQUIRE(resource.actions.size() == 1);

        Action action = resource.actions.at(0);
        REQUIRE(action.method == "GET");
    }

    {
        const Resource& resource = blueprint.node.content.elements().at(1).content.resource;
        REQUIRE(resource.name == "Endpoint 2");
        REQUIRE(resource.uriTemplate == "/e1");
        REQUIRE(resource.actions.size() == 1);

        Action action = resource.actions.at(0);
        REQUIRE(action.method == "GET");
    }

    {
        const Resource& resource = blueprint.node.content.elements().at(2).content.resource;
        REQUIRE(resource.name == "Endpoint 3");
        REQUIRE(resource.uriTemplate == "/e1");
        REQUIRE(resource.actions.size() == 1);

        Action action = resource.actions.at(0);
        REQUIRE(action.method == "POST");
    }
}

TEST_CASE("Action section containing properties keyword under it", "[action][127]")
{
    const mdp::ByteBuffer source
        = "# A [GET /]\n"
          "+ Properties\n"
          "+ Response 204";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.empty());

    REQUIRE(action.node.examples.size() == 1);
    REQUIRE(action.node.examples[0].requests.empty());
    REQUIRE(action.node.examples[0].responses.size() == 1);
}

TEST_CASE("Miss leading slash in URI", "[action][350]")
{
    const mdp::ByteBuffer source = "A [GET {param}]";

    snowcrash::ParseResult<snowcrash::Blueprint> blueprint;
    snowcrash::SectionParserData pd(0, source, blueprint.node);
    MarkdownNodes nodes;
    nodes.push_back(mdp::MarkdownNode(mdp::HeaderMarkdownNodeType, NULL, mdp::ByteBuffer(source)));
    Report report;
    SectionProcessor<Action>::checkForTypoMistake(nodes.begin(), pd, report);

    REQUIRE(report.error.code == Error::OK);
    REQUIRE(report.warnings.size() == 1);
    REQUIRE(report.warnings.begin()->code == snowcrash::URIWarning);
    REQUIRE(report.warnings.begin()->message
        == "URI path in 'A [GET {param}]' is not absolute, it should have a leading forward slash");
}

TEST_CASE("Detect invalid reference to URI Template parameters in Action", "[action]")
{
    mdp::ByteBuffer source
        = "## List [GET /orders{?abc}]\n\n"
          "+ Parameters\n"
          "    + ab (string)\n"
          "    + bc (string)\n"
          "    + ac (string)\n\n"
          "+ Response 200";

    ParseResult<Action> action;
    SectionParserHelper<Action, ActionParser>::parse(source, ActionSectionType, action, ExportSourcemapOption);

    REQUIRE(action.report.error.code == Error::OK);
    REQUIRE(action.report.warnings.size() == 3);
    REQUIRE(action.report.warnings[0].code == LogicalErrorWarning);
    REQUIRE(action.report.warnings[1].code == LogicalErrorWarning);
    REQUIRE(action.report.warnings[2].code == LogicalErrorWarning);

    REQUIRE(action.node.name == "List");
    REQUIRE(action.node.uriTemplate == "/orders{?abc}");

    SourceMapHelper::check(action.report.warnings[0].location, 0, 29);
    SourceMapHelper::check(action.report.warnings[1].location, 0, 29);
    SourceMapHelper::check(action.report.warnings[2].location, 0, 29);
}


text:
import React from 'react';

export default () => (
  <div>
    DynamicForm
  </div>
);


text:
Documents

Rationale

Routing, in web app parlance, is about defining what code to execute when a given URL is invoked.

             NSR takes care of the necessary plumbing to make that happen,
             freeing the programmer of the cumbersome details, allowing her to focus on the problem domain.

How does it work?

             As was stated in the lines above, it's not necessary to know NSR
             inner workings in order to be productive using it. Having said that, it is nevertheless useful to
             have some insight on a couple of key aspects, fundamentally what could be called the "request wrapping
             mechanism".

             When you feed NSR with a url handling function, i.e.
             router.get("/answertoall", function(request, response) {response.end("42");}); what NSR
             does is to wrap that function into another, unnamed one, which has the primary mission of "augmenting" the request
             object and it stores said function in an array of url-handling functions, thus acting as a middleware piece of code.

             At run time, when a client invokes the matching URL, the "middleware" function will be called, which, after doing its trickery
             to "dress" the request object, will ultimately call the original url-handling function that was provided.

            What does "augmenting-dressing" the request object mean?

            Well, basically, NSR provides the request object with 3 properties:

request.get which is an object representation of the <dfn>query string</dfn>

request.post an object representation of what was posted, if anything

request.body is the union of the two previous items

            It should be pointed down that regardless the transmission method, NSR
            takes the necessary steps to make all 3 of them true javascript objects with all that implies, JSON and all.
            Worst case is an empty object {}, no errors.

            So, you can use request.get.whatever for router.get,
            request.post.whatever for router.post, but in any case, if you don't care about request method,
            using request.body.whatever is a safe bet, most obviously useful if you do not know in advance
            the request method, for example: router.any("/threefold", function(request, response)
            {response.end((parseInt(request.body.number) * 3).toString();});

             Wrapping up, you just got to remember request.get, request.post and request.body

And that's all there is about it.

Options

NSR sticks to some conventions ("public" as directory name for static assets, etc),

which the programmer can override when instantiating the router, for instance:

var router = new Router({static_route: __dirname + "/static"});

to change usage of the default "public" directory for static resources

List of default options:

                logging: true

                log: console.log

                static_route: "#{process.cwd()}/public"

                serve_static: true

                list_dir: true

                default_home: ['index.html', 'index.htm', 'default.htm']

                cgi_dir: "cgi-bin"

                serve_cgi: true

                serve_php: true

                php_cgi: "php-cgi"

                served_by: 'Node Simple Router'

                software_name: 'node-simple-router'

                admin_user: 'admin'

                admin_pwd: 'admin'

                use_nsr_session: true

                avail_nsr_session_handlers: ['dispatch.memory_store', 'dispatch.text_store']

                nsr_session_handler: 'dispatch.memory_store'

                Most of them are self explanatory, but some deserve further comments,
                which will be added on doc completion.

Router API

Router object supports the following methods

<dfn>get</dfn>

Usage:
router.get('/users/:id', function(request, response) {
                        response.end("User: " + getUserById(request.params.id).fullName);});

<dfn>post</dfn>

Usage:
router.post('/users', function(request, response) {
                        insertUser(request.post.user, function(new_user_id) {
                          request.post.user.id = new_user_id;
                          response.end(JSON.stringify(request.post.user);});
                        });

Handling file uploads

                        NSR handles 'multipart/form-data' out of the box.
                        When NSR detects a post having enctype="multipart/form-data" it
                        adds to the request object the properties: fileName, fileLen, fileData and
                        fileType, which client code (your server) can handle as shown in the following usage example.
                        This code can be seen in action invoked from upload example

Usage:
router.post("/handle_upload", function(request, response) {
        var encoding, fullname;
        response.writeHead(200, {'Content-type': 'text/html'});
        if (request.fileName) {
           response.write("<h2>Uploaded File Data</h2&g");
           response.write("File name = " + request.fileName + "<br/>");
           response.write("File length = " + request.fileLen + " bytes<br/>");
           response.write("File type = " + request.fileType + "<br/>");
           fullname = "" + __dirname + "/public/uploads/" + request.fileName;
           if (request.fileType.indexOf('text') >= 0) {
              encoding = 'utf8';
           }
           else {
             encoding = 'binary';
           }
           return fs.writeFile(fullname, request.fileData, {encoding: encoding}, function(err) {
             if (err) {
               response.write("<p style='color: red;'>Something went wrong, uploaded file could not be saved.</p>");
             }
             else {
               response.write('<div style="text-align:center; padding: 1em; border: 1px solid; border-radius: 5px;">');
               if (request.fileType.indexOf('image') >= 0) {
                 response.write("<img src='/uploads/" + request.fileName + "' />");
               }
               else {
                 response.write("<pre>" + request.fileData + "</pre>");
               }
               response.write("</div>");
             }
             response.write("<hr/>");
             return response.end("<div style=\"text-align: center;\"><button onclick=\"history.back();\">Back</button></div>");
           });
         }
         else {
           response.write("<p style='color: red;'>Something went wrong, looks like nothing was uploaded.</p>");
           return response.end("<div style=\"text-align: center;\"><button onclick=\"history.back();\">Back</button></div>");
         }
      });

<dfn>put</dfn>

Usage:
router.put('/users', function(request, response) {
                                    updateUser(request.post.user, function(updated_user_id) {
                                    response.end(updated_user_id);})
                                    });

<dfn>patch</dfn>
   A variant for PUT

Usage:
router.patch('/users', function(request, response) {
                                    updateUser(request.post.user, function(updated_user_id) {
                                    response.end(updated_user_id);});
                                    });

<dfn>delete</dfn>

Usage:
router.delete('/users', function(request, response) {
                                    deleteUser(request.post.user_id, function(user_id) {
                                    response.end(user_id);});
                                    });

<dfn>any</dfn>
   To be used when the request method is not known in advance. Sort of "catch all"

Usage:
router.any('/users', function(request, response) {
                            response.end("User: " + getUserById(request.body.user_id).fullName);}); // Observe the usage of 'request.body' as the union of 'request.get' and 'request.post'

<dfn>Complementary methods</dfn>

                            Up to here, all the enumerated methods are directly related to NSR primary activity: routing.
                            They are what you will use 90% of the time.
What follows are method loosely related to
                            routing activity, but are the ones that give NSR some of its
                            distinctiveness.

<dfn>proxy_pass</dfn>
   To deliver to the client the contents of an url from another server

Usage:
router.get('/whatismyip', function(request, response) {
                            router.proxy_pass('http://testing.savos.ods.org/wimi', response);});

<dfn>cgi</dfn>
   To pass the client the results of an external CGI program.

                                This one deserves an additional comment on its usefulness. While some - many perhaps - would argue
                                that CGI doesn't make any sense from a Node.js development perspective, I still it's a worthy inclusion
                                for a couple of reasons

First of all, you may have a legacy CGI module that you want/need to use in your brand new Node.js server - would you rewrite, for instance, Crafty, the chess engine, in Node? -

Writing programs that can talk to each other through standard means (stdin, stdout) has passed the test of time, and I think it has it niche even in the web server world.

If performance is a concern - and it should be - the present considerations still stand for the next item: SCGI, which NSR also supports. But there would not have been SCGI without CGI

Last but not least, CGI support makes the same sense in the context of a Node.js web server thant it does in Nginx, Apache, etc.. I'm not aware of anybody suggestiong CGI support should be dropped from any of them.

Usage:

<samp>
    By default, any static resource having a path that includes the router option 'cgi-dir'
    (which defaults to "cgi-bin") will be treated by NSR as a cgi program, provided the router option 'serve_cgi' is true.

    For example, the uri: /cgi-bin/hello.py will be handled as a CGI program.

    On the other hand, you can invoke directly the cgi method of the router, like so:

    router.cgi('/hidden-cgi-dir/mycgi.rb', request, response);

    Nevertheless, such way of using it is discouraged as it does not follow CGI standard
    guidelines.
</samp>

<dfn>scgi_pass</dfn>

To pass the client the results of an external program running under the SCGI protocol.

Same considerations as those pertaining to CGI, with the added benefit of not having to spawn a new process each time.

Why SCGI and not <dfn title="Fast CGI">FCGI</dfn>? Well, SCGI protocol was far easier to implement, and I really couldn't find significant performance differences between the two. FCGI may be implenented in future versions.

  Usage:

  //Example SCGI invocation. Output will be provided by a SCGI process listening on tcp port 26000.
  router.post("/scgi", function(request, response) {
    router.scgi_pass(26000, request, response);
  });

  The first parameter for scgi_pass is the port number (for tcp sockets)
  or the socket name (for unix sockets) at which the SCGI process is listening.

<dfn>render_template</dfn>

To provide rudimentary template handling without compromising the goal of keeping NSR lean and simple.

                                Even though templating is not directly related to routing, having a micro-templating utility was considered handy.

                                It is basically a naive implementation of mustache.js, which tries to follow the spec, but at its current stage lacks partials and lambdas. Template handling as you would with any mustache template, as shown in the following example.

Usage:

  router.get("/greet_user/:user_id", function(request, response) {
    get_user_by_id(request.params.user_id, function (user) {
      template_str = "<h2>Hello, {{ name }}!<h2>";
      compiled_str = router.render_template(template_str, user); // returns "<h2>Hello, Joe Router!<h2>"
      response.end(compiled_str);
    }
  });

                              Give it a test ride here

New in version 0.8.8: render_template_file(fileName, context, callback, keep_tokens) was added

                               The method signature is almost the same than for render_template with 2 differences worth noting

The first parameter is a string containing the file name, not the template string itself.

There is a new parameter, previous to last one: a callback function with the following signature
                                     cb(exists, rendered_text);. The reason for this is that obviously file retrieval is an async IO
                                     operation and as such it needs a callback, which render_template doesn't need as there is no IO involved.

                               Obviously it would have been better to keep only one method (render_template), letting it guess if the first parameter is
                               a file name or a template string, but doing it that way would introduce a backward incompatibility since render_template
                               returns a string, while becoming async would make it need a callback. So... too late to regret. It's not big deal, anyway.

<dfn>Session handling</dfn>

This section deals with session handling utilities built in with NSR.

                                NSR augments the request object with a nsr_session object
                                unless the option use_nsr_session is set to a falsy value (defaults to true).

                                nsr_session is a javascript object that holds the session keys and values
                                defined by the application. Incidentally, the reason NSR uses
                                request.nsr_session and not request.session is to avoid name collision in case
                                that a separate session handling mechanism is used.

                                Options related to session handling:

use_nsr_session Set nsr_session on or off

avail_nsr_session_handlers Low level functions that perform the real action. See below for details

nsr_session_handler The one handler currently selected

                                Methods related to session handling:

addSessionHandler(function, function_name) Add your own function to the list of session handlers

setSessionHandler(func_name_or_ordinal) Tell NSR which of the available handlers to use (defaults to 0, 'memory_store').

getSession(request, callback) Get the current request.nsr_session.

setSession(request, session_object, callback) Set the current request.nsr_session with the provided session_object.

updateSession(request, session_object, callback) Update the current request.nsr_session with the provided session_object, keeping not included keys and adding-updating keys present in session_object.

                                    The three latter methods are convenience wrappers to access the low level method that handles nsr_session
                                    which is responsible for the real implementation of the session mechanism.

                                    The 3 are asynchronous, having the nsr_session returned as the only argument to the callback function.

                                    Two low level handlers are provided built in: memory_store (default) and text_store (serializes each session to a file named by the session ID)

                                    If you don't need/want to construct your own implementation, you don't need to know a thing
                                    about it, but if you want to roll your own (for instance, if you want to save sessions to a database or a remote server)
                                    here are a couple of things that you should keey in mind:

                                  Function signature: var db_store = function(request, opcode, sess_obj, callback);

                                  Having a look at the source code used in memory_store and text_store should provide a fairly good idea of how things should work

                                  In order to put your brand new session handler to work, you have to

                                  1) Register it with NSR by means of addSessionHandler

                                  2) Put it to use with setSessionHandler

                                You can see the session machinery in action in the Session Handling section of this demo site.

                                By all means, review the code that makes it work in test/server.js or test/server.coffee if you are so inclined.

Utilities

                There are a bunch of utilities that can make your job easier, such as mk-server, the standalone tool
                that will generate a NSR driven web server ready to go, cookie handling, uuid
                generation, built-in async and promises (flow-control routines), but these are - rather, will be - fully commented in
                utilities section of
                NSR wiki

Real time

            Beginning with v0.9.0 NSR becomes real time. Now not only http requests routing is enabled,
            but also the ws protocol (WebSockets) is implemented.

            See all the juicy details at WebSocket section of
            NSR wiki or see it in action at the demo site.

Added goodies

           Really? Need more goodies?

           Ok, here we go...

                Default favicon If your app doesn't have a favicon, NSR provides one for you.
                I REALLY suggest you provide yours...

Default '404 - Not found' page. Once again, you're advised to provide your own.

Default '500 - Server Error' page. Same applies here.


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

import org.camunda.bpm.engine.impl.ProcessEngineLogger;

/**
 * @author Daniel Meyer
 *
 */
public class MetricsLogger extends ProcessEngineLogger {

  public void couldNotDetermineIp(Exception e) {
    logWarn(
        "001", "Could not determine local IP address for generating an engine id", e);
  }

  /**
   * @param e
   */
  public void couldNotCollectAndLogMetrics(Exception e) {
    logWarn(
        "002", "Could not collect and log metrics", e);
  }

}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Philipp. J. Sci. , C, Bot. 13: 364 (1918)

#### Original name
Meliola banahaensis H.S. Yates

### Remarks
null


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Trans. Albany Inst. 7: 215 (1872)

#### Original name
Uncinula macrospora Peck

### Remarks
null


text:
require 'ruboto/widget'
require 'ruboto/util/toast'

ruboto_import_widgets :Button, :LinearLayout, :TextView

# http://xkcd.com/378/

class SampleActivity
  def onCreate(bundle)
    super
    set_title 'Domo arigato, Mr Ruboto!'

    self.content_view =
        linear_layout :orientation => :vertical do
          @text_view = text_view :text => 'What hath Matz wrought?', :id => 42,
                                 :layout => {:width => :match_parent},
                                 :gravity => :center, :text_size => 48.0
          button :text => 'M-x butterfly',
                 :layout => {:width => :match_parent},
                 :id => 43, :on_click_listener => proc { butterfly }
        end
  rescue Exception
    puts "Exception creating activity: #{$!}"
    puts $!.backtrace.join("\n")
  end

  private

  def butterfly
    @text_view.text = 'What hath Matz wrought!'
    toast 'Flipped a bit via butterfly'
  end

end


text:
title: PlantUML
---

### Format

    @startuml
    Car : drive()
    Dog : bark()
    @enduml

    # plantuml file.uml && open file.png

## Classes

 * http://plantuml.sourceforge.net/classes.html

### Methods

    Car : drive()

### Methods (alt)

    class Car {
      String make
      year : Integer
      void drive()

      -private()
      #protected()
      ~package private()
      +public()

      {static} String id
      {abstract} void methods()
    }

### Lines

    class Car {
      These are separated by lines.
      The next line is a dotted line
      ..
      Next is a double-stroke
      ==
      Next is a plain line
      --
      Next is a strong line
      __
      You can make headers with it
      .. header ..
    }

### Associations

    Car <|-- SmallCar      # extension
    Car *-- Engine         # composition
    Cars o-- Car           # aggregation
    Car <|.. SmallCar      # dotted line (use .. instead of --)
    Car <|--* Car

    -left->
    -right->

### Relations

    Driver - Car : drives >
    Car -- Owner : < owns
    Car *-- Wheel : has 4 >

### Notes

    class Car {
    }
    note left: Something something

    note top of Car : This is a car.

### Namespaces

    namespace Client {
      class Driver {
      }
    }

    Car -- Client.Driver : owns >

## Activities

    (*) --> "First Activity"
    -->[You can put also labels] "Second Activity"
    --> (*)


text:
import { ANY_STATE as ANY_STATE_, DEFAULT_STATE as DEFAULT_STATE_, EMPTY_STATE as EMPTY_STATE_, FILL_STYLE_FLAG as FILL_STYLE_FLAG_ } from './animation/animation_constants';
import { AnimationGroupPlayer as AnimationGroupPlayer_ } from './animation/animation_group_player';
import { AnimationKeyframe as AnimationKeyframe_ } from './animation/animation_keyframe';
import { AnimationOutput as AnimationOutput_ } from './animation/animation_output';
import { AnimationPlayer as AnimationPlayer_, NoOpAnimationPlayer as NoOpAnimationPlayer_ } from './animation/animation_player';
import { AnimationSequencePlayer as AnimationSequencePlayer_ } from './animation/animation_sequence_player';
import * as animationUtils from './animation/animation_style_util';
import { AnimationStyles as AnimationStyles_ } from './animation/animation_styles';
import * as change_detection_util from './change_detection/change_detection_util';
import * as constants from './change_detection/constants';
import * as console from './console';
import * as debug from './debug/debug_renderer';
import * as reflective_provider from './di/reflective_provider';
import { ComponentStillLoadingError } from './linker/compiler';
import * as component_factory_resolver from './linker/component_factory_resolver';
import * as debug_context from './linker/debug_context';
import * as element from './linker/element';
import * as ng_module_factory from './linker/ng_module_factory';
import * as template_ref from './linker/template_ref';
import * as view from './linker/view';
import * as view_type from './linker/view_type';
import * as view_utils from './linker/view_utils';
import * as lifecycle_hooks from './metadata/lifecycle_hooks';
import * as metadata_view from './metadata/view';
import * as reflection from './reflection/reflection';
import * as reflection_capabilities from './reflection/reflection_capabilities';
import * as reflector_reader from './reflection/reflector_reader';
import * as api from './render/api';
import * as decorators from './util/decorators';
export var __core_private__ = {
    isDefaultChangeDetectionStrategy: constants.isDefaultChangeDetectionStrategy,
    ChangeDetectorStatus: constants.ChangeDetectorStatus,
    CHANGE_DETECTION_STRATEGY_VALUES: constants.CHANGE_DETECTION_STRATEGY_VALUES,
    constructDependencies: reflective_provider.constructDependencies,
    LifecycleHooks: lifecycle_hooks.LifecycleHooks,
    LIFECYCLE_HOOKS_VALUES: lifecycle_hooks.LIFECYCLE_HOOKS_VALUES,
    ReflectorReader: reflector_reader.ReflectorReader,
    CodegenComponentFactoryResolver: component_factory_resolver.CodegenComponentFactoryResolver,
    AppElement: element.AppElement,
    AppView: view.AppView,
    DebugAppView: view.DebugAppView,
    NgModuleInjector: ng_module_factory.NgModuleInjector,
    ViewType: view_type.ViewType,
    MAX_INTERPOLATION_VALUES: view_utils.MAX_INTERPOLATION_VALUES,
    checkBinding: view_utils.checkBinding,
    flattenNestedViewRenderNodes: view_utils.flattenNestedViewRenderNodes,
    interpolate: view_utils.interpolate,
    ViewUtils: view_utils.ViewUtils,
    VIEW_ENCAPSULATION_VALUES: metadata_view.VIEW_ENCAPSULATION_VALUES,
    ViewMetadata: metadata_view.ViewMetadata,
    DebugContext: debug_context.DebugContext,
    StaticNodeDebugInfo: debug_context.StaticNodeDebugInfo,
    devModeEqual: change_detection_util.devModeEqual,
    UNINITIALIZED: change_detection_util.UNINITIALIZED,
    ValueUnwrapper: change_detection_util.ValueUnwrapper,
    RenderDebugInfo: api.RenderDebugInfo,
    TemplateRef_: template_ref.TemplateRef_,
    ReflectionCapabilities: reflection_capabilities.ReflectionCapabilities,
    makeDecorator: decorators.makeDecorator,
    DebugDomRootRenderer: debug.DebugDomRootRenderer,
    EMPTY_ARRAY: view_utils.EMPTY_ARRAY,
    EMPTY_MAP: view_utils.EMPTY_MAP,
    pureProxy1: view_utils.pureProxy1,
    pureProxy2: view_utils.pureProxy2,
    pureProxy3: view_utils.pureProxy3,
    pureProxy4: view_utils.pureProxy4,
    pureProxy5: view_utils.pureProxy5,
    pureProxy6: view_utils.pureProxy6,
    pureProxy7: view_utils.pureProxy7,
    pureProxy8: view_utils.pureProxy8,
    pureProxy9: view_utils.pureProxy9,
    pureProxy10: view_utils.pureProxy10,
    castByValue: view_utils.castByValue,
    Console: console.Console,
    reflector: reflection.reflector,
    Reflector: reflection.Reflector,
    NoOpAnimationPlayer: NoOpAnimationPlayer_,
    AnimationPlayer: AnimationPlayer_,
    AnimationSequencePlayer: AnimationSequencePlayer_,
    AnimationGroupPlayer: AnimationGroupPlayer_,
    AnimationKeyframe: AnimationKeyframe_,
    prepareFinalAnimationStyles: animationUtils.prepareFinalAnimationStyles,
    balanceAnimationKeyframes: animationUtils.balanceAnimationKeyframes,
    flattenStyles: animationUtils.flattenStyles,
    clearStyles: animationUtils.clearStyles,
    renderStyles: animationUtils.renderStyles,
    collectAndResolveStyles: animationUtils.collectAndResolveStyles,
    AnimationStyles: AnimationStyles_,
    AnimationOutput: AnimationOutput_,
    ANY_STATE: ANY_STATE_,
    DEFAULT_STATE: DEFAULT_STATE_,
    EMPTY_STATE: EMPTY_STATE_,
    FILL_STYLE_FLAG: FILL_STYLE_FLAG_,
    ComponentStillLoadingError: ComponentStillLoadingError
};
//# sourceMappingURL=core_private_export.js.map


text:
from django.conf.urls.defaults import patterns, include, url

urlpatterns = patterns('',
    url(r'', include('postbin.urls')),
)


text:
.class final enum Lcom/google/gson/n;
.super Lcom/google/gson/LongSerializationPolicy;

# direct methods
.method constructor <init>(Ljava/lang/String;I)V
    .locals 1

    const/4 v0, 0x0

    invoke-direct {p0, p1, p2, v0}, Lcom/google/gson/LongSerializationPolicy;-><init>(Ljava/lang/String;ILcom/google/gson/m;)V

    return-void
.end method

# virtual methods
.method public serialize(Ljava/lang/Long;)Lcom/google/gson/JsonElement;
    .locals 2

    new-instance v0, Lcom/google/gson/JsonPrimitive;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Lcom/google/gson/JsonPrimitive;-><init>(Ljava/lang/String;)V

    return-object v0
.end method