text:
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "codec.h"
#include "vorbisenc.h"

#include "codec_internal.h"

#include "os.h"
#include "misc.h"

/* careful with this; it's using static array sizing to make managing
   all the modes a little less annoying.  If we use a residue backend
   with > 12 partition types, or a different division of iteration,
   this needs to be updated. */
typedef struct {
  const static_codebook *books[12][4];
} static_bookblock;

typedef struct {
  int res_type;
  int limit_type; /* 0 lowpass limited, 1 point stereo limited */
  int grouping;
  const vorbis_info_residue0 *res;
  const static_codebook  *book_aux;
  const static_codebook  *book_aux_managed;
  const static_bookblock *books_base;
  const static_bookblock *books_base_managed;
} vorbis_residue_template;

typedef struct {
  const vorbis_info_mapping0    *map;
  const vorbis_residue_template *res;
} vorbis_mapping_template;

typedef struct vp_adjblock{
  int block[P_BANDS];
} vp_adjblock;

typedef struct {
  int data[NOISE_COMPAND_LEVELS];
} compandblock;

/* high level configuration information for setting things up
   step-by-step with the detailed vorbis_encode_ctl interface.
   There's a fair amount of redundancy such that interactive setup
   does not directly deal with any vorbis_info or codec_setup_info
   initialization; it's all stored (until full init) in this highlevel
   setup, then flushed out to the real codec setup structs later. */

typedef struct {
  int att[P_NOISECURVES];
  float boost;
  float decay;
} att3;
typedef struct { int data[P_NOISECURVES]; } adj3;

typedef struct {
  int   pre[PACKETBLOBS];
  int   post[PACKETBLOBS];
  float kHz[PACKETBLOBS];
  float lowpasskHz[PACKETBLOBS];
} adj_stereo;

typedef struct {
  int lo;
  int hi;
  int fixed;
} noiseguard;
typedef struct {
  int data[P_NOISECURVES][17];
} noise3;

typedef struct {
  int      mappings;
  const double  *rate_mapping;
  const double  *quality_mapping;
  int      coupling_restriction;
  long     samplerate_min_restriction;
  long     samplerate_max_restriction;

  const int     *blocksize_short;
  const int     *blocksize_long;

  const att3    *psy_tone_masteratt;
  const int     *psy_tone_0dB;
  const int     *psy_tone_dBsuppress;

  const vp_adjblock *psy_tone_adj_impulse;
  const vp_adjblock *psy_tone_adj_long;
  const vp_adjblock *psy_tone_adj_other;

  const noiseguard  *psy_noiseguards;
  const noise3      *psy_noise_bias_impulse;
  const noise3      *psy_noise_bias_padding;
  const noise3      *psy_noise_bias_trans;
  const noise3      *psy_noise_bias_long;
  const int         *psy_noise_dBsuppress;

  const compandblock  *psy_noise_compand;
  const double        *psy_noise_compand_short_mapping;
  const double        *psy_noise_compand_long_mapping;

  const int      *psy_noise_normal_start[2];
  const int      *psy_noise_normal_partition[2];
  const double   *psy_noise_normal_thresh;

  const int      *psy_ath_float;
  const int      *psy_ath_abs;

  const double   *psy_lowpass;

  const vorbis_info_psy_global *global_params;
  const double     *global_mapping;
  const adj_stereo *stereo_modes;

  const static_codebook *const *const *const floor_books;
  const vorbis_info_floor1 *floor_params;
  const int floor_mappings;
  const int **floor_mapping_list;

  const vorbis_mapping_template *maps;
} ve_setup_data_template;

/* a few static coder conventions */
static const vorbis_info_mode _mode_template[2]={
  {0,0,0,0},
  {1,0,0,1}
};

static const vorbis_info_mapping0 _map_nominal[2]={
  {1, {0,0}, {0}, {0}, 1,{0},{1}},
  {1, {0,0}, {1}, {1}, 1,{0},{1}}
};

#include "modes/setup_44.h"
#include "modes/setup_44u.h"
#include "modes/setup_44p51.h"
#include "modes/setup_32.h"
#include "modes/setup_8.h"
#include "modes/setup_11.h"
#include "modes/setup_16.h"
#include "modes/setup_22.h"
#include "modes/setup_X.h"

static const ve_setup_data_template *const setup_list[]={
  &ve_setup_44_stereo,
  &ve_setup_44_51,
  &ve_setup_44_uncoupled,

  &ve_setup_32_stereo,
  &ve_setup_32_uncoupled,

  &ve_setup_22_stereo,
  &ve_setup_22_uncoupled,
  &ve_setup_16_stereo,
  &ve_setup_16_uncoupled,

  &ve_setup_11_stereo,
  &ve_setup_11_uncoupled,
  &ve_setup_8_stereo,
  &ve_setup_8_uncoupled,

  &ve_setup_X_stereo,
  &ve_setup_X_uncoupled,
  &ve_setup_XX_stereo,
  &ve_setup_XX_uncoupled,
  0
};

static void vorbis_encode_floor_setup(vorbis_info *vi,int s,
                                     const static_codebook *const *const *const books,
                                     const vorbis_info_floor1 *in,
                                     const int *x){
  int i,k,is=s;
  vorbis_info_floor1 *f=_ogg_calloc(1,sizeof(*f));
  codec_setup_info *ci=vi->codec_setup;

  memcpy(f,in+x[is],sizeof(*f));

  /* books */
  {
    int partitions=f->partitions;
    int maxclass=-1;
    int maxbook=-1;
    for(i=0;i<partitions;i++)
      if(f->partitionclass[i]>maxclass)maxclass=f->partitionclass[i];
    for(i=0;i<=maxclass;i++){
      if(f->class_book[i]>maxbook)maxbook=f->class_book[i];
      f->class_book[i]+=ci->books;
      for(k=0;k<(1<<f->class_subs[i]);k++){
        if(f->class_subbook[i][k]>maxbook)maxbook=f->class_subbook[i][k];
        if(f->class_subbook[i][k]>=0)f->class_subbook[i][k]+=ci->books;
      }
    }

    for(i=0;i<=maxbook;i++)
      ci->book_param[ci->books++]=(static_codebook *)books[x[is]][i];
  }

  /* for now, we're only using floor 1 */
  ci->floor_type[ci->floors]=1;
  ci->floor_param[ci->floors]=f;
  ci->floors++;

  return;
}

static void vorbis_encode_global_psych_setup(vorbis_info *vi,double s,
                                            const vorbis_info_psy_global *in,
                                            const double *x){
  int i,is=s;
  double ds=s-is;
  codec_setup_info *ci=vi->codec_setup;
  vorbis_info_psy_global *g=&ci->psy_g_param;

  memcpy(g,in+(int)x[is],sizeof(*g));

  ds=x[is]*(1.-ds)+x[is+1]*ds;
  is=(int)ds;
  ds-=is;
  if(ds==0 && is>0){
    is--;
    ds=1.;
  }

  /* interpolate the trigger threshholds */
  for(i=0;i<4;i++){
    g->preecho_thresh[i]=in[is].preecho_thresh[i]*(1.-ds)+in[is+1].preecho_thresh[i]*ds;
    g->postecho_thresh[i]=in[is].postecho_thresh[i]*(1.-ds)+in[is+1].postecho_thresh[i]*ds;
  }
  g->ampmax_att_per_sec=ci->hi.amplitude_track_dBpersec;
  return;
}

static void vorbis_encode_global_stereo(vorbis_info *vi,
                                        const highlevel_encode_setup *const hi,
                                        const adj_stereo *p){
  float s=hi->stereo_point_setting;
  int i,is=s;
  double ds=s-is;
  codec_setup_info *ci=vi->codec_setup;
  vorbis_info_psy_global *g=&ci->psy_g_param;

  if(p){
    memcpy(g->coupling_prepointamp,p[is].pre,sizeof(*p[is].pre)*PACKETBLOBS);
    memcpy(g->coupling_postpointamp,p[is].post,sizeof(*p[is].post)*PACKETBLOBS);

    if(hi->managed){
      /* interpolate the kHz threshholds */
      for(i=0;i<PACKETBLOBS;i++){
        float kHz=p[is].kHz[i]*(1.-ds)+p[is+1].kHz[i]*ds;
        g->coupling_pointlimit[0][i]=kHz*1000./vi->rate*ci->blocksizes[0];
        g->coupling_pointlimit[1][i]=kHz*1000./vi->rate*ci->blocksizes[1];
        g->coupling_pkHz[i]=kHz;

        kHz=p[is].lowpasskHz[i]*(1.-ds)+p[is+1].lowpasskHz[i]*ds;
        g->sliding_lowpass[0][i]=kHz*1000./vi->rate*ci->blocksizes[0];
        g->sliding_lowpass[1][i]=kHz*1000./vi->rate*ci->blocksizes[1];

      }
    }else{
      float kHz=p[is].kHz[PACKETBLOBS/2]*(1.-ds)+p[is+1].kHz[PACKETBLOBS/2]*ds;
      for(i=0;i<PACKETBLOBS;i++){
        g->coupling_pointlimit[0][i]=kHz*1000./vi->rate*ci->blocksizes[0];
        g->coupling_pointlimit[1][i]=kHz*1000./vi->rate*ci->blocksizes[1];
        g->coupling_pkHz[i]=kHz;
      }

      kHz=p[is].lowpasskHz[PACKETBLOBS/2]*(1.-ds)+p[is+1].lowpasskHz[PACKETBLOBS/2]*ds;
      for(i=0;i<PACKETBLOBS;i++){
        g->sliding_lowpass[0][i]=kHz*1000./vi->rate*ci->blocksizes[0];
        g->sliding_lowpass[1][i]=kHz*1000./vi->rate*ci->blocksizes[1];
      }
    }
  }else{
    for(i=0;i<PACKETBLOBS;i++){
      g->sliding_lowpass[0][i]=ci->blocksizes[0];
      g->sliding_lowpass[1][i]=ci->blocksizes[1];
    }
  }
  return;
}

static void vorbis_encode_psyset_setup(vorbis_info *vi,double s,
                                       const int *nn_start,
                                       const int *nn_partition,
                                       const double *nn_thresh,
                                       int block){
  codec_setup_info *ci=vi->codec_setup;
  vorbis_info_psy *p=ci->psy_param[block];
  highlevel_encode_setup *hi=&ci->hi;
  int is=s;

  if(block>=ci->psys)
    ci->psys=block+1;
  if(!p){
    p=_ogg_calloc(1,sizeof(*p));
    ci->psy_param[block]=p;
  }

  memcpy(p,&_psy_info_template,sizeof(*p));
  p->blockflag=block>>1;

  if(hi->noise_normalize_p){
    p->normal_p=1;
    p->normal_start=nn_start[is];
    p->normal_partition=nn_partition[is];
    p->normal_thresh=nn_thresh[is];
  }

  return;
}

static void vorbis_encode_tonemask_setup(vorbis_info *vi,double s,int block,
                                         const att3 *att,
                                         const int  *max,
                                         const vp_adjblock *in){
  int i,is=s;
  double ds=s-is;
  codec_setup_info *ci=vi->codec_setup;
  vorbis_info_psy *p=ci->psy_param[block];

  /* 0 and 2 are only used by bitmanagement, but there's no harm to always
     filling the values in here */
  p->tone_masteratt[0]=att[is].att[0]*(1.-ds)+att[is+1].att[0]*ds;
  p->tone_masteratt[1]=att[is].att[1]*(1.-ds)+att[is+1].att[1]*ds;
  p->tone_masteratt[2]=att[is].att[2]*(1.-ds)+att[is+1].att[2]*ds;
  p->tone_centerboost=att[is].boost*(1.-ds)+att[is+1].boost*ds;
  p->tone_decay=att[is].decay*(1.-ds)+att[is+1].decay*ds;

  p->max_curve_dB=max[is]*(1.-ds)+max[is+1]*ds;

  for(i=0;i<P_BANDS;i++)
    p->toneatt[i]=in[is].block[i]*(1.-ds)+in[is+1].block[i]*ds;
  return;
}

static void vorbis_encode_compand_setup(vorbis_info *vi,double s,int block,
                                        const compandblock *in,
                                        const double *x){
  int i,is=s;
  double ds=s-is;
  codec_setup_info *ci=vi->codec_setup;
  vorbis_info_psy *p=ci->psy_param[block];

  ds=x[is]*(1.-ds)+x[is+1]*ds;
  is=(int)ds;
  ds-=is;
  if(ds==0 && is>0){
    is--;
    ds=1.;
  }

  /* interpolate the compander settings */
  for(i=0;i<NOISE_COMPAND_LEVELS;i++)
    p->noisecompand[i]=in[is].data[i]*(1.-ds)+in[is+1].data[i]*ds;
  return;
}

static void vorbis_encode_peak_setup(vorbis_info *vi,double s,int block,
                                    const int *suppress){
  int is=s;
  double ds=s-is;
  codec_setup_info *ci=vi->codec_setup;
  vorbis_info_psy *p=ci->psy_param[block];

  p->tone_abs_limit=suppress[is]*(1.-ds)+suppress[is+1]*ds;

  return;
}

static void vorbis_encode_noisebias_setup(vorbis_info *vi,double s,int block,
                                         const int *suppress,
                                         const noise3 *in,
                                         const noiseguard *guard,
                                         double userbias){
  int i,is=s,j;
  double ds=s-is;
  codec_setup_info *ci=vi->codec_setup;
  vorbis_info_psy *p=ci->psy_param[block];

  p->noisemaxsupp=suppress[is]*(1.-ds)+suppress[is+1]*ds;
  p->noisewindowlomin=guard[block].lo;
  p->noisewindowhimin=guard[block].hi;
  p->noisewindowfixed=guard[block].fixed;

  for(j=0;j<P_NOISECURVES;j++)
    for(i=0;i<P_BANDS;i++)
      p->noiseoff[j][i]=in[is].data[j][i]*(1.-ds)+in[is+1].data[j][i]*ds;

  /* impulse blocks may take a user specified bias to boost the
     nominal/high noise encoding depth */
  for(j=0;j<P_NOISECURVES;j++){
    float min=p->noiseoff[j][0]+6; /* the lowest it can go */
    for(i=0;i<P_BANDS;i++){
      p->noiseoff[j][i]+=userbias;
      if(p->noiseoff[j][i]<min)p->noiseoff[j][i]=min;
    }
  }

  return;
}

static void vorbis_encode_ath_setup(vorbis_info *vi,int block){
  codec_setup_info *ci=vi->codec_setup;
  vorbis_info_psy *p=ci->psy_param[block];

  p->ath_adjatt=ci->hi.ath_floating_dB;
  p->ath_maxatt=ci->hi.ath_absolute_dB;
  return;
}

static int book_dup_or_new(codec_setup_info *ci,const static_codebook *book){
  int i;
  for(i=0;i<ci->books;i++)
    if(ci->book_param[i]==book)return(i);

  return(ci->books++);
}

static void vorbis_encode_blocksize_setup(vorbis_info *vi,double s,
                                         const int *shortb,const int *longb){

  codec_setup_info *ci=vi->codec_setup;
  int is=s;

  int blockshort=shortb[is];
  int blocklong=longb[is];
  ci->blocksizes[0]=blockshort;
  ci->blocksizes[1]=blocklong;

}

static void vorbis_encode_residue_setup(vorbis_info *vi,
                                        int number, int block,
                                        const vorbis_residue_template *res){

  codec_setup_info *ci=vi->codec_setup;
  int i;

  vorbis_info_residue0 *r=ci->residue_param[number]=
    _ogg_malloc(sizeof(*r));

  memcpy(r,res->res,sizeof(*r));
  if(ci->residues<=number)ci->residues=number+1;

  r->grouping=res->grouping;
  ci->residue_type[number]=res->res_type;

  /* fill in all the books */
  {
    int booklist=0,k;

    if(ci->hi.managed){
      for(i=0;i<r->partitions;i++)
        for(k=0;k<4;k++)
          if(res->books_base_managed->books[i][k])
            r->secondstages[i]|=(1<<k);

      r->groupbook=book_dup_or_new(ci,res->book_aux_managed);
      ci->book_param[r->groupbook]=(static_codebook *)res->book_aux_managed;

      for(i=0;i<r->partitions;i++){
        for(k=0;k<4;k++){
          if(res->books_base_managed->books[i][k]){
            int bookid=book_dup_or_new(ci,res->books_base_managed->books[i][k]);
            r->booklist[booklist++]=bookid;
            ci->book_param[bookid]=(static_codebook *)res->books_base_managed->books[i][k];
          }
        }
      }

    }else{

      for(i=0;i<r->partitions;i++)
        for(k=0;k<4;k++)
          if(res->books_base->books[i][k])
            r->secondstages[i]|=(1<<k);

      r->groupbook=book_dup_or_new(ci,res->book_aux);
      ci->book_param[r->groupbook]=(static_codebook *)res->book_aux;

      for(i=0;i<r->partitions;i++){
        for(k=0;k<4;k++){
          if(res->books_base->books[i][k]){
            int bookid=book_dup_or_new(ci,res->books_base->books[i][k]);
            r->booklist[booklist++]=bookid;
            ci->book_param[bookid]=(static_codebook *)res->books_base->books[i][k];
          }
        }
      }
    }
  }

  /* lowpass setup/pointlimit */
  {
    double freq=ci->hi.lowpass_kHz*1000.;
    vorbis_info_floor1 *f=ci->floor_param[block]; /* by convention */
    double nyq=vi->rate/2.;
    long blocksize=ci->blocksizes[block]>>1;

    /* lowpass needs to be set in the floor and the residue. */
    if(freq>nyq)freq=nyq;
    /* in the floor, the granularity can be very fine; it doesn't alter
       the encoding structure, only the samples used to fit the floor
       approximation */
    f->n=freq/nyq*blocksize;

    /* this res may by limited by the maximum pointlimit of the mode,
       not the lowpass. the floor is always lowpass limited. */
    switch(res->limit_type){
    case 1: /* point stereo limited */
      if(ci->hi.managed)
        freq=ci->psy_g_param.coupling_pkHz[PACKETBLOBS-1]*1000.;
      else
        freq=ci->psy_g_param.coupling_pkHz[PACKETBLOBS/2]*1000.;
      if(freq>nyq)freq=nyq;
      break;
    case 2: /* LFE channel; lowpass at ~ 250Hz */
      freq=250;
      break;
    default:
      /* already set */
      break;
    }

    /* in the residue, we're constrained, physically, by partition
       boundaries.  We still lowpass 'wherever', but we have to round up
       here to next boundary, or the vorbis spec will round it *down* to
       previous boundary in encode/decode */
    if(ci->residue_type[number]==2){
      /* residue 2 bundles together multiple channels; used by stereo
         and surround.  Count the channels in use */
      /* Multiple maps/submaps can point to the same residue.  In the case
         of residue 2, they all better have the same number of
         channels/samples. */
      int j,k,ch=0;
      for(i=0;i<ci->maps&&ch==0;i++){
        vorbis_info_mapping0 *mi=(vorbis_info_mapping0 *)ci->map_param[i];
        for(j=0;j<mi->submaps && ch==0;j++)
          if(mi->residuesubmap[j]==number) /* we found a submap referencing theis residue backend */
            for(k=0;k<vi->channels;k++)
              if(mi->chmuxlist[k]==j) /* this channel belongs to the submap */
                ch++;
      }

      r->end=(int)((freq/nyq*blocksize*ch)/r->grouping+.9)* /* round up only if we're well past */
        r->grouping;
      /* the blocksize and grouping may disagree at the end */
      if(r->end>blocksize*ch)r->end=blocksize*ch/r->grouping*r->grouping;

    }else{

      r->end=(int)((freq/nyq*blocksize)/r->grouping+.9)* /* round up only if we're well past */
        r->grouping;
      /* the blocksize and grouping may disagree at the end */
      if(r->end>blocksize)r->end=blocksize/r->grouping*r->grouping;

    }

    if(r->end==0)r->end=r->grouping; /* LFE channel */

  }
}

/* we assume two maps in this encoder */
static void vorbis_encode_map_n_res_setup(vorbis_info *vi,double s,
                                          const vorbis_mapping_template *maps){

  codec_setup_info *ci=vi->codec_setup;
  int i,j,is=s,modes=2;
  const vorbis_info_mapping0 *map=maps[is].map;
  const vorbis_info_mode *mode=_mode_template;
  const vorbis_residue_template *res=maps[is].res;

  if(ci->blocksizes[0]==ci->blocksizes[1])modes=1;

  for(i=0;i<modes;i++){

    ci->map_param[i]=_ogg_calloc(1,sizeof(*map));
    ci->mode_param[i]=_ogg_calloc(1,sizeof(*mode));

    memcpy(ci->mode_param[i],mode+i,sizeof(*_mode_template));
    if(i>=ci->modes)ci->modes=i+1;

    ci->map_type[i]=0;
    memcpy(ci->map_param[i],map+i,sizeof(*map));
    if(i>=ci->maps)ci->maps=i+1;

    for(j=0;j<map[i].submaps;j++)
      vorbis_encode_residue_setup(vi,map[i].residuesubmap[j],i
                                  ,res+map[i].residuesubmap[j]);
  }
}

static double setting_to_approx_bitrate(vorbis_info *vi){
  codec_setup_info *ci=vi->codec_setup;
  highlevel_encode_setup *hi=&ci->hi;
  ve_setup_data_template *setup=(ve_setup_data_template *)hi->setup;
  int is=hi->base_setting;
  double ds=hi->base_setting-is;
  int ch=vi->channels;
  const double *r=setup->rate_mapping;

  if(r==NULL)
    return(-1);

  return((r[is]*(1.-ds)+r[is+1]*ds)*ch);
}

static const void *get_setup_template(long ch,long srate,
                                      double req,int q_or_bitrate,
                                      double *base_setting){
  int i=0,j;
  if(q_or_bitrate)req/=ch;

  while(setup_list[i]){
    if(setup_list[i]->coupling_restriction==-1 ||
       setup_list[i]->coupling_restriction==ch){
      if(srate>=setup_list[i]->samplerate_min_restriction &&
         srate<=setup_list[i]->samplerate_max_restriction){
        int mappings=setup_list[i]->mappings;
        const double *map=(q_or_bitrate?
                     setup_list[i]->rate_mapping:
                     setup_list[i]->quality_mapping);

        /* the template matches.  Does the requested quality mode
           fall within this template's modes? */
        if(req<map[0]){++i;continue;}
        if(req>map[setup_list[i]->mappings]){++i;continue;}
        for(j=0;j<mappings;j++)
          if(req>=map[j] && req<map[j+1])break;
        /* an all-points match */
        if(j==mappings)
          *base_setting=j-.001;
        else{
          float low=map[j];
          float high=map[j+1];
          float del=(req-low)/(high-low);
          *base_setting=j+del;
        }

        return(setup_list[i]);
      }
    }
    i++;
  }

  return NULL;
}

/* encoders will need to use vorbis_info_init beforehand and call
   vorbis_info clear when all done */

/* two interfaces; this, more detailed one, and later a convenience
   layer on top */

/* the final setup call */
int vorbis_encode_setup_init(vorbis_info *vi){
  int i,i0=0,singleblock=0;
  codec_setup_info *ci=vi->codec_setup;
  ve_setup_data_template *setup=NULL;
  highlevel_encode_setup *hi=&ci->hi;

  if(ci==NULL)return(OV_EINVAL);
  if(!hi->impulse_block_p)i0=1;

  /* too low/high an ATH floater is nonsensical, but doesn't break anything */
  if(hi->ath_floating_dB>-80)hi->ath_floating_dB=-80;
  if(hi->ath_floating_dB<-200)hi->ath_floating_dB=-200;

  /* again, bound this to avoid the app shooting itself int he foot
     too badly */
  if(hi->amplitude_track_dBpersec>0.)hi->amplitude_track_dBpersec=0.;
  if(hi->amplitude_track_dBpersec<-99999.)hi->amplitude_track_dBpersec=-99999.;

  /* get the appropriate setup template; matches the fetch in previous
     stages */
  setup=(ve_setup_data_template *)hi->setup;
  if(setup==NULL)return(OV_EINVAL);

  hi->set_in_stone=1;
  /* choose block sizes from configured sizes as well as paying
     attention to long_block_p and short_block_p.  If the configured
     short and long blocks are the same length, we set long_block_p
     and unset short_block_p */
  vorbis_encode_blocksize_setup(vi,hi->base_setting,
                                setup->blocksize_short,
                                setup->blocksize_long);
  if(ci->blocksizes[0]==ci->blocksizes[1])singleblock=1;

  /* floor setup; choose proper floor params.  Allocated on the floor
     stack in order; if we alloc only a single long floor, it's 0 */
  for(i=0;i<setup->floor_mappings;i++)
    vorbis_encode_floor_setup(vi,hi->base_setting,
                              setup->floor_books,
                              setup->floor_params,
                              setup->floor_mapping_list[i]);

  /* setup of [mostly] short block detection and stereo*/
  vorbis_encode_global_psych_setup(vi,hi->trigger_setting,
                                   setup->global_params,
                                   setup->global_mapping);
  vorbis_encode_global_stereo(vi,hi,setup->stereo_modes);

  /* basic psych setup and noise normalization */
  vorbis_encode_psyset_setup(vi,hi->base_setting,
                             setup->psy_noise_normal_start[0],
                             setup->psy_noise_normal_partition[0],
                             setup->psy_noise_normal_thresh,
                             0);
  vorbis_encode_psyset_setup(vi,hi->base_setting,
                             setup->psy_noise_normal_start[0],
                             setup->psy_noise_normal_partition[0],
                             setup->psy_noise_normal_thresh,
                             1);
  if(!singleblock){
    vorbis_encode_psyset_setup(vi,hi->base_setting,
                               setup->psy_noise_normal_start[1],
                               setup->psy_noise_normal_partition[1],
                                    setup->psy_noise_normal_thresh,
                               2);
    vorbis_encode_psyset_setup(vi,hi->base_setting,
                               setup->psy_noise_normal_start[1],
                               setup->psy_noise_normal_partition[1],
                               setup->psy_noise_normal_thresh,
                               3);
  }

  /* tone masking setup */
  vorbis_encode_tonemask_setup(vi,hi->block[i0].tone_mask_setting,0,
                               setup->psy_tone_masteratt,
                               setup->psy_tone_0dB,
                               setup->psy_tone_adj_impulse);
  vorbis_encode_tonemask_setup(vi,hi->block[1].tone_mask_setting,1,
                               setup->psy_tone_masteratt,
                               setup->psy_tone_0dB,
                               setup->psy_tone_adj_other);
  if(!singleblock){
    vorbis_encode_tonemask_setup(vi,hi->block[2].tone_mask_setting,2,
                                 setup->psy_tone_masteratt,
                                 setup->psy_tone_0dB,
                                 setup->psy_tone_adj_other);
    vorbis_encode_tonemask_setup(vi,hi->block[3].tone_mask_setting,3,
                                 setup->psy_tone_masteratt,
                                 setup->psy_tone_0dB,
                                 setup->psy_tone_adj_long);
  }

  /* noise companding setup */
  vorbis_encode_compand_setup(vi,hi->block[i0].noise_compand_setting,0,
                              setup->psy_noise_compand,
                              setup->psy_noise_compand_short_mapping);
  vorbis_encode_compand_setup(vi,hi->block[1].noise_compand_setting,1,
                              setup->psy_noise_compand,
                              setup->psy_noise_compand_short_mapping);
  if(!singleblock){
    vorbis_encode_compand_setup(vi,hi->block[2].noise_compand_setting,2,
                                setup->psy_noise_compand,
                                setup->psy_noise_compand_long_mapping);
    vorbis_encode_compand_setup(vi,hi->block[3].noise_compand_setting,3,
                                setup->psy_noise_compand,
                                setup->psy_noise_compand_long_mapping);
  }

  /* peak guarding setup  */
  vorbis_encode_peak_setup(vi,hi->block[i0].tone_peaklimit_setting,0,
                           setup->psy_tone_dBsuppress);
  vorbis_encode_peak_setup(vi,hi->block[1].tone_peaklimit_setting,1,
                           setup->psy_tone_dBsuppress);
  if(!singleblock){
    vorbis_encode_peak_setup(vi,hi->block[2].tone_peaklimit_setting,2,
                             setup->psy_tone_dBsuppress);
    vorbis_encode_peak_setup(vi,hi->block[3].tone_peaklimit_setting,3,
                             setup->psy_tone_dBsuppress);
  }

  /* noise bias setup */
  vorbis_encode_noisebias_setup(vi,hi->block[i0].noise_bias_setting,0,
                                setup->psy_noise_dBsuppress,
                                setup->psy_noise_bias_impulse,
                                setup->psy_noiseguards,
                                (i0==0?hi->impulse_noisetune:0.));
  vorbis_encode_noisebias_setup(vi,hi->block[1].noise_bias_setting,1,
                                setup->psy_noise_dBsuppress,
                                setup->psy_noise_bias_padding,
                                setup->psy_noiseguards,0.);
  if(!singleblock){
    vorbis_encode_noisebias_setup(vi,hi->block[2].noise_bias_setting,2,
                                  setup->psy_noise_dBsuppress,
                                  setup->psy_noise_bias_trans,
                                  setup->psy_noiseguards,0.);
    vorbis_encode_noisebias_setup(vi,hi->block[3].noise_bias_setting,3,
                                  setup->psy_noise_dBsuppress,
                                  setup->psy_noise_bias_long,
                                  setup->psy_noiseguards,0.);
  }

  vorbis_encode_ath_setup(vi,0);
  vorbis_encode_ath_setup(vi,1);
  if(!singleblock){
    vorbis_encode_ath_setup(vi,2);
    vorbis_encode_ath_setup(vi,3);
  }

  vorbis_encode_map_n_res_setup(vi,hi->base_setting,setup->maps);

  /* set bitrate readonlies and management */
  if(hi->bitrate_av>0)
    vi->bitrate_nominal=hi->bitrate_av;
  else{
    vi->bitrate_nominal=setting_to_approx_bitrate(vi);
  }

  vi->bitrate_lower=hi->bitrate_min;
  vi->bitrate_upper=hi->bitrate_max;
  if(hi->bitrate_av)
    vi->bitrate_window=(double)hi->bitrate_reservoir/hi->bitrate_av;
  else
    vi->bitrate_window=0.;

  if(hi->managed){
    ci->bi.avg_rate=hi->bitrate_av;
    ci->bi.min_rate=hi->bitrate_min;
    ci->bi.max_rate=hi->bitrate_max;

    ci->bi.reservoir_bits=hi->bitrate_reservoir;
    ci->bi.reservoir_bias=
      hi->bitrate_reservoir_bias;

    ci->bi.slew_damp=hi->bitrate_av_damp;

  }

  return(0);

}

static void vorbis_encode_setup_setting(vorbis_info *vi,
                                       long  channels,
                                       long  rate){
  int i,is;
  codec_setup_info *ci=vi->codec_setup;
  highlevel_encode_setup *hi=&ci->hi;
  const ve_setup_data_template *setup=hi->setup;
  double ds;

  vi->version=0;
  vi->channels=channels;
  vi->rate=rate;

  hi->impulse_block_p=1;
  hi->noise_normalize_p=1;

  is=hi->base_setting;
  ds=hi->base_setting-is;

  hi->stereo_point_setting=hi->base_setting;

  if(!hi->lowpass_altered)
    hi->lowpass_kHz=
      setup->psy_lowpass[is]*(1.-ds)+setup->psy_lowpass[is+1]*ds;

  hi->ath_floating_dB=setup->psy_ath_float[is]*(1.-ds)+
    setup->psy_ath_float[is+1]*ds;
  hi->ath_absolute_dB=setup->psy_ath_abs[is]*(1.-ds)+
    setup->psy_ath_abs[is+1]*ds;

  hi->amplitude_track_dBpersec=-6.;
  hi->trigger_setting=hi->base_setting;

  for(i=0;i<4;i++){
    hi->block[i].tone_mask_setting=hi->base_setting;
    hi->block[i].tone_peaklimit_setting=hi->base_setting;
    hi->block[i].noise_bias_setting=hi->base_setting;
    hi->block[i].noise_compand_setting=hi->base_setting;
  }
}

int vorbis_encode_setup_vbr(vorbis_info *vi,
                            long  channels,
                            long  rate,
                            float quality){
  codec_setup_info *ci=vi->codec_setup;
  highlevel_encode_setup *hi=&ci->hi;

  quality+=.0000001;
  if(quality>=1.)quality=.9999;

  hi->req=quality;
  hi->setup=get_setup_template(channels,rate,quality,0,&hi->base_setting);
  if(!hi->setup)return OV_EIMPL;

  vorbis_encode_setup_setting(vi,channels,rate);
  hi->managed=0;
  hi->coupling_p=1;

  return 0;
}

int vorbis_encode_init_vbr(vorbis_info *vi,
                           long channels,
                           long rate,

                           float base_quality /* 0. to 1. */
                           ){
  int ret=0;

  ret=vorbis_encode_setup_vbr(vi,channels,rate,base_quality);

  if(ret){
    vorbis_info_clear(vi);
    return ret;
  }
  ret=vorbis_encode_setup_init(vi);
  if(ret)
    vorbis_info_clear(vi);
  return(ret);
}

int vorbis_encode_setup_managed(vorbis_info *vi,
                                long channels,
                                long rate,

                                long max_bitrate,
                                long nominal_bitrate,
                                long min_bitrate){

  codec_setup_info *ci=vi->codec_setup;
  highlevel_encode_setup *hi=&ci->hi;
  double tnominal=nominal_bitrate;

  if(nominal_bitrate<=0.){
    if(max_bitrate>0.){
      if(min_bitrate>0.)
        nominal_bitrate=(max_bitrate+min_bitrate)*.5;
      else
        nominal_bitrate=max_bitrate*.875;
    }else{
      if(min_bitrate>0.){
        nominal_bitrate=min_bitrate;
      }else{
        return(OV_EINVAL);
      }
    }
  }

  hi->req=nominal_bitrate;
  hi->setup=get_setup_template(channels,rate,nominal_bitrate,1,&hi->base_setting);
  if(!hi->setup)return OV_EIMPL;

  vorbis_encode_setup_setting(vi,channels,rate);

  /* initialize management with sane defaults */
  hi->coupling_p=1;
  hi->managed=1;
  hi->bitrate_min=min_bitrate;
  hi->bitrate_max=max_bitrate;
  hi->bitrate_av=tnominal;
  hi->bitrate_av_damp=1.5f; /* full range in no less than 1.5 second */
  hi->bitrate_reservoir=nominal_bitrate*2;
  hi->bitrate_reservoir_bias=.1; /* bias toward hoarding bits */

  return(0);

}

int vorbis_encode_init(vorbis_info *vi,
                       long channels,
                       long rate,

                       long max_bitrate,
                       long nominal_bitrate,
                       long min_bitrate){

  int ret=vorbis_encode_setup_managed(vi,channels,rate,
                                      max_bitrate,
                                      nominal_bitrate,
                                      min_bitrate);
  if(ret){
    vorbis_info_clear(vi);
    return(ret);
  }

  ret=vorbis_encode_setup_init(vi);
  if(ret)
    vorbis_info_clear(vi);
  return(ret);
}

int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg){
  if(vi){
    codec_setup_info *ci=vi->codec_setup;
    highlevel_encode_setup *hi=&ci->hi;
    int setp=(number&0xf); /* a read request has a low nibble of 0 */

    if(setp && hi->set_in_stone)return(OV_EINVAL);

    switch(number){

    /* now deprecated *****************/
    case OV_ECTL_RATEMANAGE_GET:
      {

        struct ovectl_ratemanage_arg *ai=
          (struct ovectl_ratemanage_arg *)arg;

        ai->management_active=hi->managed;
        ai->bitrate_hard_window=ai->bitrate_av_window=
          (double)hi->bitrate_reservoir/vi->rate;
        ai->bitrate_av_window_center=1.;
        ai->bitrate_hard_min=hi->bitrate_min;
        ai->bitrate_hard_max=hi->bitrate_max;
        ai->bitrate_av_lo=hi->bitrate_av;
        ai->bitrate_av_hi=hi->bitrate_av;

      }
      return(0);

    /* now deprecated *****************/
    case OV_ECTL_RATEMANAGE_SET:
      {
        struct ovectl_ratemanage_arg *ai=
          (struct ovectl_ratemanage_arg *)arg;
        if(ai==NULL){
          hi->managed=0;
        }else{
          hi->managed=ai->management_active;
          vorbis_encode_ctl(vi,OV_ECTL_RATEMANAGE_AVG,arg);
          vorbis_encode_ctl(vi,OV_ECTL_RATEMANAGE_HARD,arg);
        }
      }
      return 0;

    /* now deprecated *****************/
    case OV_ECTL_RATEMANAGE_AVG:
      {
        struct ovectl_ratemanage_arg *ai=
          (struct ovectl_ratemanage_arg *)arg;
        if(ai==NULL){
          hi->bitrate_av=0;
        }else{
          hi->bitrate_av=(ai->bitrate_av_lo+ai->bitrate_av_hi)*.5;
        }
      }
      return(0);
    /* now deprecated *****************/
    case OV_ECTL_RATEMANAGE_HARD:
      {
        struct ovectl_ratemanage_arg *ai=
          (struct ovectl_ratemanage_arg *)arg;
        if(ai==NULL){
          hi->bitrate_min=0;
          hi->bitrate_max=0;
        }else{
          hi->bitrate_min=ai->bitrate_hard_min;
          hi->bitrate_max=ai->bitrate_hard_max;
          hi->bitrate_reservoir=ai->bitrate_hard_window*
            (hi->bitrate_max+hi->bitrate_min)*.5;
        }
        if(hi->bitrate_reservoir<128.)
          hi->bitrate_reservoir=128.;
      }
      return(0);

      /* replacement ratemanage interface */
    case OV_ECTL_RATEMANAGE2_GET:
      {
        struct ovectl_ratemanage2_arg *ai=
          (struct ovectl_ratemanage2_arg *)arg;
        if(ai==NULL)return OV_EINVAL;

        ai->management_active=hi->managed;
        ai->bitrate_limit_min_kbps=hi->bitrate_min/1000;
        ai->bitrate_limit_max_kbps=hi->bitrate_max/1000;
        ai->bitrate_average_kbps=hi->bitrate_av/1000;
        ai->bitrate_average_damping=hi->bitrate_av_damp;
        ai->bitrate_limit_reservoir_bits=hi->bitrate_reservoir;
        ai->bitrate_limit_reservoir_bias=hi->bitrate_reservoir_bias;
      }
      return (0);
    case OV_ECTL_RATEMANAGE2_SET:
      {
        struct ovectl_ratemanage2_arg *ai=
          (struct ovectl_ratemanage2_arg *)arg;
        if(ai==NULL){
          hi->managed=0;
        }else{
          /* sanity check; only catch invariant violations */
          if(ai->bitrate_limit_min_kbps>0 &&
             ai->bitrate_average_kbps>0 &&
             ai->bitrate_limit_min_kbps>ai->bitrate_average_kbps)
            return OV_EINVAL;

          if(ai->bitrate_limit_max_kbps>0 &&
             ai->bitrate_average_kbps>0 &&
             ai->bitrate_limit_max_kbps<ai->bitrate_average_kbps)
            return OV_EINVAL;

          if(ai->bitrate_limit_min_kbps>0 &&
             ai->bitrate_limit_max_kbps>0 &&
             ai->bitrate_limit_min_kbps>ai->bitrate_limit_max_kbps)
            return OV_EINVAL;

          if(ai->bitrate_average_damping <= 0.)
            return OV_EINVAL;

          if(ai->bitrate_limit_reservoir_bits < 0)
            return OV_EINVAL;

          if(ai->bitrate_limit_reservoir_bias < 0.)
            return OV_EINVAL;

          if(ai->bitrate_limit_reservoir_bias > 1.)
            return OV_EINVAL;

          hi->managed=ai->management_active;
          hi->bitrate_min=ai->bitrate_limit_min_kbps * 1000;
          hi->bitrate_max=ai->bitrate_limit_max_kbps * 1000;
          hi->bitrate_av=ai->bitrate_average_kbps * 1000;
          hi->bitrate_av_damp=ai->bitrate_average_damping;
          hi->bitrate_reservoir=ai->bitrate_limit_reservoir_bits;
          hi->bitrate_reservoir_bias=ai->bitrate_limit_reservoir_bias;
        }
      }
      return 0;

    case OV_ECTL_LOWPASS_GET:
      {
        double *farg=(double *)arg;
        *farg=hi->lowpass_kHz;
      }
      return(0);
    case OV_ECTL_LOWPASS_SET:
      {
        double *farg=(double *)arg;
        hi->lowpass_kHz=*farg;

        if(hi->lowpass_kHz<2.)hi->lowpass_kHz=2.;
        if(hi->lowpass_kHz>99.)hi->lowpass_kHz=99.;
        hi->lowpass_altered=1;
      }
      return(0);
    case OV_ECTL_IBLOCK_GET:
      {
        double *farg=(double *)arg;
        *farg=hi->impulse_noisetune;
      }
      return(0);
    case OV_ECTL_IBLOCK_SET:
      {
        double *farg=(double *)arg;
        hi->impulse_noisetune=*farg;

        if(hi->impulse_noisetune>0.)hi->impulse_noisetune=0.;
        if(hi->impulse_noisetune<-15.)hi->impulse_noisetune=-15.;
      }
      return(0);
    case OV_ECTL_COUPLING_GET:
      {
        int *iarg=(int *)arg;
        *iarg=hi->coupling_p;
      }
      return(0);
    case OV_ECTL_COUPLING_SET:
      {
        const void *new_template;
        double new_base=0.;
        int *iarg=(int *)arg;
        hi->coupling_p=((*iarg)!=0);

        /* Fetching a new template can alter the base_setting, which
           many other parameters are based on.  Right now, the only
           parameter drawn from the base_setting that can be altered
           by an encctl is the lowpass, so that is explictly flagged
           to not be overwritten when we fetch a new template and
           recompute the dependant settings */
        new_template = get_setup_template(hi->coupling_p?vi->channels:-1,
                                          vi->rate,
                                          hi->req,
                                          hi->managed,
                                          &new_base);
        if(!hi->setup)return OV_EIMPL;
        hi->setup=new_template;
        hi->base_setting=new_base;
        vorbis_encode_setup_setting(vi,vi->channels,vi->rate);
      }
      return(0);
    }
    return(OV_EIMPL);
  }
  return(OV_EINVAL);
}


text:
package main

const Name string = "goblin"
const Version string = "0.1.0"

redpajama_set_name: RedPajamaGithub


text:
package com.jishuli.Moco.BusinessLogicLayer.dao;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;

import com.jishuli.Moco.PersistenceLayer.Subject;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
 * DAO for table "SUBJECT".
*/
public class SubjectDao extends AbstractDao<Subject, Long> {

    public static final String TABLENAME = "SUBJECT";

    /**
     * Properties of entity Subject.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property Identifier = new Property(1, Long.class, "identifier", false, "IDENTIFIER");
        public final static Property Name = new Property(2, String.class, "name", false, "NAME");
    };

    private DaoSession daoSession;

    public SubjectDao(DaoConfig config) {
        super(config);
    }

    public SubjectDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
        this.daoSession = daoSession;
    }

    /** Creates the underlying database table. */
    public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"SUBJECT\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"IDENTIFIER\" INTEGER," + // 1: identifier
                "\"NAME\" TEXT);"); // 2: name
    }

    /** Drops the underlying database table. */
    public static void dropTable(SQLiteDatabase db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"SUBJECT\"";
        db.execSQL(sql);
    }

    /** @inheritdoc */
    @Override
    protected void bindValues(SQLiteStatement stmt, Subject entity) {
        stmt.clearBindings();

        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }

        Long identifier = entity.getIdentifier();
        if (identifier != null) {
            stmt.bindLong(2, identifier);
        }

        String name = entity.getName();
        if (name != null) {
            stmt.bindString(3, name);
        }
    }

    @Override
    protected void attachEntity(Subject entity) {
        super.attachEntity(entity);
        entity.__setDaoSession(daoSession);
    }

    /** @inheritdoc */
    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }

    /** @inheritdoc */
    @Override
    public Subject readEntity(Cursor cursor, int offset) {
        Subject entity = new Subject( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // identifier
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2) // name
        );
        return entity;
    }

    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, Subject entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setIdentifier(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
     }

    /** @inheritdoc */
    @Override
    protected Long updateKeyAfterInsert(Subject entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }

    /** @inheritdoc */
    @Override
    public Long getKey(Subject entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    /** @inheritdoc */
    @Override
    protected boolean isEntityUpdateable() {
        return true;
    }

}


text:
package com.example.phone_notes.activity;

import java.util.ArrayList;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.database.Cursor;
import android.graphics.drawable.BitmapDrawable;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.phone_notes.R;
import com.example.phone_notes.adapter.NoteslistAdapter;
import com.example.phone_notes.base.BaseActivity;
import com.example.phone_notes.bean.notesItem;
import com.example.phone_notes.constant.myConstant;
import com.example.phone_notes.utils.TimeFormatUtil;
import com.example.phone_notes.utils.ToastUtils;

//主界面
public class MainActivity extends BaseActivity {
	private ImageView lock_unlock;// 加密按钮
	private EditText search;// 搜索框
	private boolean is_in_reme = false;// 判断是否开启了加密模式
	private boolean is_pass_setted = false;// 判断密码是否已设置
	private Editor editor;
	private boolean is_back_pressed = false;
	private ListView notes_list;// 笔记列表
	private ImageView notes_add;// 添加按钮
	private PopupWindow pop;// 悬浮窗控件
	private TextView add_type;// 添加分类
	private TextView add_notes;// 添加笔记
	private TextView retrieve;// 回收站
	private RelativeLayout data_null_notes;// 数据为空提示信息
	private ArrayList<notesItem> data;// 列表数据
	private NoteslistAdapter adapter;// 列表适配器
	private String CurrentType = myConstant.ParentTable;// 当前所在分类
	private String ParentTable = "";// 父列表

	@Override
	protected void initView() {
		setContentView(R.layout.activity_main);
		lock_unlock = (ImageView) findViewById(R.id.lock_unlock);
		search = (EditText) findViewById(R.id.search);
		notes_list = (ListView) findViewById(R.id.notes_list);
		notes_add = (ImageView) findViewById(R.id.btn_add);
		data_null_notes = (RelativeLayout) findViewById(R.id.data_null_notes);
		initPopView();
	}

	@Override
	protected void initData() {
		// 加密处理
		initPass();
		// 初始化列表相关数据
		data = new ArrayList<notesItem>();
		adapter = new NoteslistAdapter(mContext, data, myNotesdatabase);
		// 设置适配器
		notes_list.setAdapter(adapter);
		// 读取数据库中笔记数据,并更新列表
		readDatabaseData();
	}

	@Override
	protected void initListener() {
		// 开启和关闭加密按钮
		lock_unlock.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// 首先判断是否处于加密模式
				if (is_in_reme) {// 加密模式已开启,点击按钮关闭
					// 点击按钮关闭加密
					AlertDialog.Builder builder = new Builder(mContext);
					builder.setTitle("提示");
					builder.setMessage("开启加密更安全,确定要关闭吗?");
					builder.setPositiveButton("确定",
							new DialogInterface.OnClickListener() {

								@Override
								public void onClick(DialogInterface arg0,
										int arg1) {
									// 修改是否处于加密模式标示值
									editor = mPreferences.edit();
									editor.putBoolean(myConstant.IS_REME_PASS,
											false);
									editor.commit();
									is_in_reme = false;
									arg0.dismiss();
									lock_unlock
											.setImageResource(R.drawable.unlock);
								}
							});
					builder.setNegativeButton("取消",
							new DialogInterface.OnClickListener() {

								@Override
								public void onClick(DialogInterface arg0,
										int arg1) {
									arg0.dismiss();
								}
							});
					builder.create().show();
				} else {// 未开启加密模式,点击按钮开启
					// 首先判断是否已设置密码,未设置密码是需要首先设置密码
					is_pass_setted = mPreferences.getBoolean(
							myConstant.IS_PASS_SETED, false);
					if (is_pass_setted) {// 密码已设置
						// 点击直接开启加密,修改标示加密模式的参数值
						editor = mPreferences.edit();
						editor.putBoolean(myConstant.IS_REME_PASS, true);
						editor.commit();
						is_in_reme = true;
						// 修改解锁图标
						lock_unlock.setImageResource(R.drawable.lock);
						ToastUtils.show(mContext, "加密已开启");
					} else {// 密码未设置
						// 首先设置密码,设置后开启加密
						setAndopenPass();
					}
				}
			}
		});
		// 添加按钮点击事件
		notes_add.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				// 点击按钮提示添加分类或者添加笔记
				if (pop.isShowing()) {
					pop.dismiss();
					pop.update();
				} else {
					showPopUp(notes_add);
				}
			}
		});
		// 添加分类按钮点击事件
		add_type.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// 点击添加分类按钮弹出对话框,用户输入分类名称,操作数据库,在当前分类下添加分类
				AlertDialog.Builder builder = new Builder(mContext);
				View view = View.inflate(mContext, R.layout.dialog_addtype,
						null);
				final EditText input_typename = (EditText) view
						.findViewById(R.id.input_typename);
				Button ensure = (Button) view.findViewById(R.id.ensure);
				Button cancel = (Button) view.findViewById(R.id.cancel);
				builder.setTitle("添加分类");
				builder.setView(view);
				final Dialog dialog = builder.create();
				dialog.show();
				// 确定按钮点击事件
				ensure.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						if (TextUtils.isEmpty(input_typename.getText()
								.toString())) {
							ToastUtils.show(mContext, "输入不能为空");
						} else {
							// 执行添加分类操作,首先判断所处分类,然后设置新建分类父类为所处分类
							// 此处不改变父列表的值,只允许在页面跳转过程中改变
							handleAddType(input_typename.getText().toString(),
									dialog, ParentTable);
							// 更新列表
							notesItem item = new notesItem();
							item.setNotesType(0);
							item.setNotesName(input_typename.getText()
									.toString());
							item.setParentName(ParentTable);
							item.setNotesTime(TimeFormatUtil.format(new Date()));
							data.add(item);
							adapter.notifyDataSetChanged();
						}
					}
				});
				// 取消按钮点击事件
				cancel.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						// 隐藏对话框
						dialog.dismiss();
					}
				});
				// 点击后隐藏popwindow
				pop.dismiss();
			}
		});
		// 添加笔记点击事件
		add_notes.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// 点击添加笔记:此操作进入添加与编辑界面,传递操作类型值,在下一页面做出区分
				handleAddNotes(myConstant.AddNotesInCurrentType, ParentTable,
						null, CurrentType);
				data_null_notes.setVisibility(View.INVISIBLE);
				// 点击后隐藏popwindow
				pop.dismiss();
			}
		});
		// 回收站按钮点击事件
		retrieve.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// 点击进入回收站界面
				Intent intent = new Intent(mContext, RetrieveActivity.class);
				startActivityForResult(intent,
						myConstant.RequestCode_openretrieve);
				// 点击后隐藏popwindow
				pop.dismiss();
			}
		});
		// 为笔记列表单项点击事件
		notes_list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				// 首先判断当前项是分类还是笔记
				switch (data.get(position).getNotesType()) {
				case 0:// 当前是分类
						// 首先判断当前分类是否为空,若为空,则弹出对话框,提示新建分类或新建笔记
					handle_listitemclick_type(position);
					break;
				case 1:// 当前是笔记
					handle_listitemclick_note(position);
					break;
				default:
					break;
				}
			}
		});
		// 设置笔记列表的长按点击事件
		notes_list.setOnItemLongClickListener(new OnItemLongClickListener() {

			@Override
			public boolean onItemLongClick(AdapterView<?> parent, View view,
					final int position, long id) {
				// 长按列表项他能出对话框,提示用户删除笔记或分类,可选择放入回收站或彻底删除,放入回收站只需要将数据从原来表中删除并保存到回收站中,彻底删除需要进行递归调用,彻底删除数据
				AlertDialog.Builder builder = new Builder(mContext);
				builder.setTitle("删除操作");
				// 彻底删除操作
				builder.setPositiveButton("彻底删除",
						new DialogInterface.OnClickListener() {

							@Override
							public void onClick(DialogInterface dialog,
									int which) {
								// 处理直接删除操作,无需存入回收站,直接执行sqlite delete操作
								handleDeleteTabledirectly(position);
								dialog.dismiss();
							}
						});
				// 放入回收站操作
				builder.setNegativeButton("放入回收站",
						new DialogInterface.OnClickListener() {

							@Override
							public void onClick(DialogInterface dialog,
									int which) {
								// 处理放入回收站操作,读取当前数据,保存到回收站,并添加currenttype值到pretable属性,用于撤销删除的操作
								handleDeleteTableIntoRetrieve(position);
								dialog.dismiss();
							}
						});
				builder.create().show();
				// 返回true拦截用户操作,避免触发点击事件
				return true;
			}
		});
		// 设置搜索框点击事件
		search.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// 点击进入搜索页面
				Intent intent = new Intent(mContext, SearchActivity.class);
				startActivity(intent);
			}
		});
	}

	// 处理删除数据到回收站的操作
	private void handleDeleteTableIntoRetrieve(int position) {
		// 首先保存数据到回收站
		notesItem item = data.get(position);
		ContentValues values = new ContentValues();

		// 保存原来报所在的分类
		values.put(myConstant.NotesPreTable, CurrentType);
		// 保存数据类型
		values.put(myConstant.NotesType, item.getNotesType());
		// 保存数据名称
		values.put(myConstant.NotesName, item.getNotesName());
		// 保存数据时间
		values.put(myConstant.NotesTime, item.getNotesTime());
		// 保存数据父表
		values.put(myConstant.Parent, item.getParentName());
		if (item.getNotesType() == 1) {// 当前是笔记
			// 保存笔记内容
			values.put(myConstant.Notesmessage, item.getMessage());
			// 保存图片资源
			values.put(myConstant.Images, splicecharacter(item.getImages()));
			// 保存标签
			values.put(myConstant.NotesLabel, splicecharacter(item.getLabels()));
		}
		// 保存到回收站
		myNotesdatabase.insert(myConstant.RetrieveNotes, null, values);
		// 从当前表删除数据,并更新列表
		myNotesdatabase.delete(CurrentType, myConstant.NotesName + "=?",
				new String[] { item.getNotesName() });
		data.remove(item);
		adapter.notifyDataSetChanged();
		if (data.size() == 0) {
			data_null_notes.setVisibility(View.VISIBLE);
		}
	}

	// 处理直接删除数据操作
	private void handleDeleteTabledirectly(int position) {
		// 获取当前数据对象
		notesItem item = data.get(position);
		deleteData(item, CurrentType);
		data.remove(item);
		adapter.notifyDataSetChanged();
		if (data.size() == 0) {
			data_null_notes.setVisibility(View.VISIBLE);
		}
	}

	// 递归删除数据
	private void deleteData(notesItem item, String table_belongto) {
		if (item.getNotesType() == 1) {// 需要删除项为笔记,直接从当前表删除
			myNotesdatabase.delete(table_belongto, myConstant.NotesName + "=?",
					new String[] { item.getNotesName() });
		} else if (myNotesdatabase.query(item.getNotesName(), null, null, null,// 当前是分类
				null, null, null).getCount() == 0) {// 当前分类中无数据,直接删除
			String deleteTable = "drop  table " + item.getNotesName();
			// 删除表
			myNotesdatabase.execSQL(deleteTable);
			// 从当前表删除数据
			myNotesdatabase.delete(table_belongto, myConstant.NotesName + "=?",
					new String[] { item.getNotesName() });
		} else {// 当前分类存在数据,递归调用,依次删除
			// 获取当前分类中所有数据
			Cursor cursor = myNotesdatabase.query(item.getNotesName(), null,
					null, null, null, null, null);
			cursor.move(-1);
			while (cursor.moveToNext()) {
				notesItem item2 = new notesItem();
				// 读取父列表
				item2.setParentName(cursor.getString(cursor
						.getColumnIndex(myConstant.Parent)));
				// 读取分类名称
				item2.setNotesName(cursor.getString(cursor
						.getColumnIndex(myConstant.NotesName)));
				// 读取笔记信息,当前为空值
				item2.setMessage(cursor.getString(cursor
						.getColumnIndex(myConstant.Notesmessage)));
				// 读取数据类型数据
				item2.setNotesType(cursor.getInt(cursor
						.getColumnIndex(myConstant.NotesType)));
				// 读取创建时间
				item2.setNotesTime(cursor.getString(cursor
						.getColumnIndex(myConstant.NotesTime)));
				// 读取标签
				ArrayList<String> labels = readLabels(cursor.getString(cursor
						.getColumnIndex(myConstant.NotesLabel)));
				item2.setLabels(labels);
				// 读取图片
				ArrayList<String> images = readImages(cursor.getString(cursor
						.getColumnIndex(myConstant.Images)));
				item2.setImages(images);
				deleteData(item2, item.getNotesName());
			}
			// 最后删除分类
			String deleteTable = "drop  table " + item.getNotesName();
			// 删除表
			myNotesdatabase.execSQL(deleteTable);
			// 从当前表删除数据
			myNotesdatabase.delete(table_belongto, myConstant.NotesName + "=?",
					new String[] { item.getNotesName() });
		}
	}

	// 拼接标签或图片字符串
	private String splicecharacter(ArrayList<String> data) {
		StringBuilder builder = new StringBuilder();
		if (data.size() > 0) {
			for (int i = 0; i < data.size(); i++) {
				if (i != data.size() - 1) {
					builder.append(data.get(i) + "|");
				} else {
					builder.append(data.get(i));
				}
			}
		}
		return builder.toString();
	}

	// 处理笔记列表点击事件---点击笔记列表项
	private void handle_listitemclick_note(int position) {
		// 进入笔记详情页面
		Intent intent = new Intent(mContext, NotesDetailActivity.class);
		intent.putExtra(myConstant.NotesToShowIm_NotesDetailActivity,
				data.get(position));
		startActivity(intent);
	}

	// 处理笔记列表点击事件---点击分类列表项
	private void handle_listitemclick_type(final int position) {
		Cursor cursor = myNotesdatabase.query(
				data.get(position).getNotesName(), null, null, null, null,
				null, null);
		if (cursor.getCount() == 0) {// 当前分类无数据,点击提示添加分类或笔记
			AlertDialog.Builder builder = new Builder(mContext);
			builder.setTitle("选择操作");
			// 设置添加分类按钮点击事件
			builder.setPositiveButton("添加分类",
					new DialogInterface.OnClickListener() {

						@Override
						public void onClick(final DialogInterface dialog,
								int which) {
							// TODO Auto-generated method stub
							AlertDialog.Builder builder = new Builder(mContext);
							View view = View.inflate(mContext,
									R.layout.dialog_addtype, null);
							final EditText input_typename = (EditText) view
									.findViewById(R.id.input_typename);
							Button ensure = (Button) view
									.findViewById(R.id.ensure);
							Button cancel = (Button) view
									.findViewById(R.id.cancel);
							builder.setTitle("添加分类");
							builder.setView(view);
							final Dialog dialog1 = builder.create();
							dialog1.show();
							// 确定按钮点击事件
							ensure.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View v) {
									ParentTable = CurrentType;
									CurrentType = data.get(position)
											.getNotesName();
									handleAddType(input_typename.getText()
											.toString(), dialog1, ParentTable);
									// 添加成功后刷新当前列表,更新当前列表下数据
									adapter.notifyDataSetChanged();
									// 隐藏对话框
									dialog1.dismiss();
									dialog.dismiss();
									// 刷新数据后进入新建分类列表
									data.clear();
									// 重新读取数据库,获取更新后笔记列表
									readDatabaseData();
									// 隐藏对话框
									dialog1.dismiss();
								}
							});
							// 取消按钮点击事件
							cancel.setOnClickListener(new OnClickListener() {

								@Override
								public void onClick(View v) {
									// TODO Auto-generated method stub
									dialog1.dismiss();
									dialog.dismiss();
								}
							});
						}

					});
			// 设置添加笔记按钮点击事件
			builder.setNegativeButton("添加笔记",
					new DialogInterface.OnClickListener() {

						@Override
						public void onClick(DialogInterface dialog, int which) {
							// TODO Auto-generated method stub
							ParentTable = CurrentType;
							CurrentType = data.get(position).getNotesName();
							handleAddNotes(myConstant.AddNotesAndEnterType,
									ParentTable, (Dialog) dialog, CurrentType);
						}
					});
			builder.create().show();
		} else {// 当前分类不为空,点击刷新当前分类列表,并更新CurrentType用于在监听返回键时返回上一级列表
			ParentTable = CurrentType;
			CurrentType = data.get(position).getNotesName();
			data.clear();
			// 重新读取当数据库,刷新笔记列表
			readDatabaseData();
		}

	}

	// 初始化popwindow界面组件
	private void initPopView() {
		View view = View.inflate(mContext, R.layout.main_add_pop, null);
		// 测量popwindow
		view.measure(0, 0);
		add_type = (TextView) view.findViewById(R.id.add_type);
		add_notes = (TextView) view.findViewById(R.id.add_notes);
		retrieve = (TextView) view.findViewById(R.id.retrieve);
		pop = new PopupWindow(view, view.getMeasuredWidth(),
				view.getMeasuredHeight(), true);
		pop.setFocusable(true);
		pop.setTouchable(true);
		pop.setBackgroundDrawable(new BitmapDrawable());
	}

	// 设置密码,并开启加密
	private void setAndopenPass() {
		AlertDialog.Builder builder = new Builder(mContext);
		View view = View.inflate(mContext, R.layout.dialog_pass_setting, null);
		builder.setView(view);
		final EditText input_pass = (EditText) view
				.findViewById(R.id.input_pass);
		final EditText input_pass_again = (EditText) view
				.findViewById(R.id.input_pass_again);
		Button ensure = (Button) view.findViewById(R.id.ensure);
		Button cancel = (Button) view.findViewById(R.id.cancel);
		final Dialog dialog = builder.create();
		// 确定按钮点击事件
		ensure.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				// 判断用户输入是否合法
				if (!TextUtils.isEmpty(input_pass.getText().toString())
						&& !TextUtils.isEmpty(input_pass_again.getText()
								.toString())
						&& input_pass.getText().toString()
								.equals(input_pass_again.getText().toString())) {
					editor = mPreferences.edit();
					// 设置密码状态为已设置
					editor.putBoolean(myConstant.IS_PASS_SETED, true);
					// 设置开启加密状态
					editor.putBoolean(myConstant.IS_REME_PASS, true);
					// 保存密码
					editor.putString(myConstant.PASS, input_pass.getText()
							.toString());
					editor.commit();
					dialog.dismiss();
					lock_unlock.setImageResource(R.drawable.lock);
					// 提示密码已开启加密
					ToastUtils.show(mContext, "加密已开启");
					is_in_reme = true;
				} else {
					ToastUtils.show(mContext, "请确保两次输入一致");
				}
			}
		});
		// 取消按钮点击事件
		cancel.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// 隐藏对话框
				dialog.dismiss();
			}
		});
		// 显示对话框
		dialog.show();
	}

	// 进入主界面方法封装
	public static void enterMain(Context con, Class<MainActivity> class1) {
		Intent intent = new Intent(con, class1);
		con.startActivity(intent);
	}

	// 加密方法封装
	private void initPass() {
		// 获取是否开启了加密模式
		is_in_reme = mPreferences.getBoolean(myConstant.IS_REME_PASS, false);
		if (is_in_reme) {// 加密模式已开启
			lock_unlock.setImageResource(R.drawable.lock);
		} else {// 未加密情况
			lock_unlock.setImageResource(R.drawable.unlock);
		}
	}

	@Override
	public void onBackPressed() {
		if (CurrentType.equals(myConstant.ParentTable)) {
			if (!is_back_pressed) {
				ToastUtils.show(mContext, "再按一次退出");
				is_back_pressed = true;
				Timer timer = new Timer();
				timer.schedule(new TimerTask() {
					@Override
					public void run() {
						is_back_pressed = false;
					}
				}, 2000);
			} else {
				finish();
			}
		} else {
			CurrentType = data.get(0).getParentName();
			data.clear();
			readDatabaseData();
		}
	}

	// 设置popwindow显示在组件上方
	private void showPopUp(View v) {
		int[] location = new int[2];
		v.getLocationOnScreen(location);
		pop.showAtLocation(v, Gravity.NO_GRAVITY, location[0], location[1]
				- pop.getHeight());
	}

	// 处理添加分类操作方法封装
	private void handleAddType(String type, Dialog dialog, String parent) {
		// 添加分类操作,操作数据库,新建分类表,刷新当前列表
		// 首先用户输入是否为空
		if (TextUtils.isEmpty(type)) {
			ToastUtils.show(mContext, "不可为空,请重新输入");
		} else {
			String CreateTable = "create table " + type + "("
					+ "_id integer primary key autoincrement,"
					+ myConstant.NotesName + " text," + myConstant.NotesType
					+ " integer," + myConstant.NoteLists + " text,"
					+ myConstant.Notesmessage + " text," + myConstant.Images
					+ " text," + myConstant.NotesLabel + " text,"
					+ myConstant.Parent + " text," + myConstant.NotesTime
					+ " text" + ")";
			// 新建分类表
			myNotesdatabase.execSQL(CreateTable);
			// 为当前列表添加一列数据
			ContentValues values = new ContentValues();
			// 设置当前项为分类项
			values.put(myConstant.NotesType, 0);
			values.put(myConstant.NotesName, type);
			values.put(myConstant.Parent, parent);
			values.put(myConstant.NotesTime, TimeFormatUtil.format(new Date()));
			myNotesdatabase.insert(CurrentType, null, values);
			// 隐藏对话框
			dialog.dismiss();
			data_null_notes.setVisibility(View.INVISIBLE);
		}
	}

	// 处理添加笔记操作
	private void handleAddNotes(int addType, String parent, Dialog dialog,
			String currenttype) {
		/**
		 *
		 *
		 * 添加笔记操作氛分为两种情况 1,点击主页面添加按钮:在当前类型下添加笔记:进入笔记编辑页面,添加后返回笔记bean值,然后刷新当前列表
		 * 2,点击笔记分类单项:当此分类为空时,点击进入笔记添加页面,添加后返回笔记bean值,然后进入此分类页面
		 *
		 *
		 */
		switch (addType) {
		case myConstant.AddNotesInCurrentType:
			// 在当前分类下添加笔记,即点击右下方按钮进行相关操作
			// 传递parent属性到笔记添加页面
			Intent intent = new Intent(mContext, NotesDetailEditActivity.class);
			intent.putExtra(myConstant.Parent, parent);
			intent.putExtra(myConstant.NotesDetailEditActivity_operatetype,
					myConstant.NotesDetailEditActivity_ADD);
			intent.putExtra(myConstant.notesDetailEditActivity_CurrentType,
					currenttype);
			startActivityForResult(intent, myConstant.RequestCode_addnotes);
			break;
		case myConstant.AddNotesAndEnterType:
			// 点击数据为空的列表项,选择添加笔记按钮,添加笔记后进入该分类
			// 点击笔记列表,当为分类并且所点击分类数据为空时,点击添加笔记,进入编辑页面,然后刷新列表
			// 传递parent属性到笔记添加页面
			Intent intent2 = new Intent(mContext, NotesDetailEditActivity.class);
			intent2.putExtra(myConstant.Parent, parent);
			intent2.putExtra(myConstant.NotesDetailEditActivity_operatetype,
					myConstant.NotesDetailEditActivity_ADD);
			intent2.putExtra(myConstant.notesDetailEditActivity_CurrentType,
					currenttype);
			startActivityForResult(intent2,
					myConstant.RequestCode_addnotesEnterType);
			// 隐藏对话框
			dialog.dismiss();
			break;
		default:
			break;
		}

	}

	// 读取根列表数据库数据,并刷新列表
	private void readDatabaseData() {
		// 进行数据库操作,读取分类数据,更新列表
		Cursor cursor = myNotesdatabase.query(CurrentType, null, null, null,
				null, null, null);
		cursor.move(-1);
		while (cursor.moveToNext()) {
			// 数据不为空,显示隐藏提示信息
			data_null_notes.setVisibility(View.INVISIBLE);
			notesItem item = new notesItem();
			// 读取父列表
			item.setParentName(cursor.getString(cursor
					.getColumnIndex(myConstant.Parent)));
			// 读取分类名称
			item.setNotesName(cursor.getString(cursor
					.getColumnIndex(myConstant.NotesName)));
			// 读取笔记信息,当前为空值
			item.setMessage(cursor.getString(cursor
					.getColumnIndex(myConstant.Notesmessage)));
			// 读取数据类型数据
			item.setNotesType(cursor.getInt(cursor
					.getColumnIndex(myConstant.NotesType)));
			// 读取创建时间
			item.setNotesTime(cursor.getString(cursor
					.getColumnIndex(myConstant.NotesTime)));
			// 读取标签
			ArrayList<String> labels = readLabels(cursor.getString(cursor
					.getColumnIndex(myConstant.NotesLabel)));
			item.setLabels(labels);
			// 读取图片
			ArrayList<String> images = readImages(cursor.getString(cursor
					.getColumnIndex(myConstant.Images)));
			item.setImages(images);
			// 添加数据到数据,更新列表
			data.add(item);
			adapter.notifyDataSetChanged();
		}
	}

	// 读取标签数据
	private ArrayList<String> readLabels(String data) {
		ArrayList<String> labels = new ArrayList<String>();
		// 首先判断数据是否为空值
		if (!TextUtils.isEmpty(data)) {
			String[] l = data.split("\\|");
			for (String la : l) {
				labels.add(la);
			}
		}
		return labels;
	}

	// 读取图片数据
	private ArrayList<String> readImages(String data) {
		ArrayList<String> images = new ArrayList<String>();
		// 首先判断数据是否为空值
		if (!TextUtils.isEmpty(data)) {
			String[] ima = data.split("\\|");
			for (String i : ima) {
				images.add(i);
			}
		}
		return images;
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode,
			Intent intent) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, intent);
		switch (requestCode) {
		// 添加笔记后更新当前分类列表
		case myConstant.RequestCode_addnotes:
			if (resultCode == RESULT_OK) {
				notesItem item = (notesItem) intent
						.getSerializableExtra(myConstant.NotesReturned);
				data.add(item);
				adapter.notifyDataSetChanged();
			}
			break;
		// 添加分类后进入下一级页面
		case myConstant.RequestCode_addnotesEnterType:
			if (resultCode == RESULT_OK) {
				notesItem item2 = (notesItem) intent
						.getSerializableExtra(myConstant.NotesReturned);
				data.clear();
				readDatabaseData();
			}
			break;
		// 从回收站返回重新加载列表
		case myConstant.RequestCode_openretrieve:
			data.clear();
			readDatabaseData();
			break;
		default:
			break;
		}
	}
}


text:
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
//use yii\jui\DatePicker;
use kartik\date\DatePicker;
//use dosamigos\datepicker\DatePicker;

/* @var $this yii\web\View */
/* @var $model app\models\AccionCentralizada */
/* @var $form yii\widgets\ActiveForm */

$icons = [
    'volver'=>'',
];
?>

            DATOS BÁSICOS

            <?php $form = ActiveForm::begin(); ?>

            <?= $form->field($model, 'codigo_accion')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'codigo_accion_sne')->textInput(['maxlength' => true]) ?>

            <?= $form->field($model, 'nombre_accion')->textInput(['maxlength' => true]) ?>

        	<?= $form->field($model, 'fecha_inicio')->
        	widget(
            DatePicker::className(),
            [
            'value'=> $model->fecha_inicio,
            'readonly'=>'true',
            'language'=>'es',
            'options' => ['placeholder' => 'Select issue date ...'],
            'pluginOptions' =>
                [
                    'format' => 'dd/mm/yyyy',
                    'todayHighlight' => true
                ]
            ]);?>

            <?= $form->field($model,'fecha_fin')->
            widget(
            DatePicker::className(),
            [
            'value' =>$model->fecha_fin,
            'language'=>'es',
            'readonly'=>'true',
            'options' => ['placeholder' => 'Select issue date ...'],
            'pluginOptions' =>
                [
                    'format' => 'dd/mm/yyyy',
                    'todayHighlight' => true
                ]
            ]);?>

        <?= Html::a($icons['volver'].' Volver', ['accion-centralizada/index'], ['class' => 'btn btn-primary']) ?>
        <?= Html::submitButton($model->isNewRecord ? 'Crear' : 'Modificar', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

<?php ActiveForm::end(); ?>


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Thyridium betulae Nitschke & Rehm

### Remarks
null


text:
import isObject from './isObject';
import isArray from './isArray';
import slice from './slice';
import extend from './extend';

// Create a (shallow-cloned) duplicate of an object.
export default function clone(obj) {
	if (!isObject(obj)) return obj;
	return isArray(obj) ? slice.call(obj) : extend({}, obj);
}


text:
Then(/^a file named "(.*?)" should exist in my current directory$/) do |filename|
  # Aruba cd's to tmp/aruba before it runs things, ugh
  path = File.join(Dir.pwd, "tmp", "aruba", filename)
  expect(File.exist?(path)).to be_true
end

Then(/^the file named "(.*?)" should contain "(.*?)"$/) do |filename, content|
  # Aruba cd's to tmp/aruba before it runs things, ugh
  path = File.join(Dir.pwd, "tmp", "aruba", filename)
  expect(File.read(path)).to include(content)
end


text:
Ti=TERMS FOR PRIVATE PLACEMENT OF SERIES SEED PREFERRED STOCK OF {Company.Name.Full}

0.1.sec=The following is a summary of the principal terms with respect to the proposed Series Seed Preferred Stock financing of {Company.Name.Full}, a Delaware corporation (the "Company").  Except for the section entitled "Binding Terms," this summary of terms does not constitute a legally binding obligation.  The parties intend to enter into a legally binding obligation only pursuant to definitive agreements to be negotiated and executed by the parties.

0.2.sec=
Offering Terms

0.=[G/Z/paras/s2]

1.Ti=Securities to Issue:

1.sec=Shares of a new series of preferred stock of the Company (the "Series Seed").

2.Ti=Aggregate Proceeds:

2.sec={Seed.PricePerShare.$} in aggregate new capital. {Convert.sec}

Convert.sec=In addition, the {Convert.Share.Quantity.#} of outstanding convertible securities (convertible promissory notes and/or SAFEs) (and all accrued but unpaid interest thereon) (the "Convertible Securities") will also convert on the same terms as stated herein.

3.Ti=Purchasers:

3.sec={Purchaser.All.cl} (the "Purchasers").

4.Ti=Price Per Share:

4.sec=Price per share (the "Original Issue Price"), based on a pre-money valuation of {PremoneyValuation.$}, including an available option pool of {OptionPool.%} of the post-money fully diluted capital of the Company. {ConvertibleSecurities.Premoney.Sen}

ConvertibleSecurities.Premoney.Sen=The Convertible Securities will [not] be included in the pre-money shares for purposes of determining the Original Issue Price.

5.Ti=Liquidation Preference:

5.sec=One times the Original Issue Price plus declared but unpaid dividends on each share of Series Seed, balance of proceeds paid to Common Stock.  A merger, reorganization or similar transaction will be treated as a liquidation.

6.Ti=Conversion:

6.sec=Each shares of Series Seed is convertible into one share of Common Stock (subject to proportional adjustments for stock splits, stock dividends and the like) at any time at the option of the holder. {Conversion.DownRound.sen}

Conversion.DownRound.sen=Conversion ratio will be subject to adjustment on a broad-based, weighted average basis in the event of subsequent issuances at a price less than the Original Issue Price (as adjusted) subject to customary exceptions.

7.Ti=Voting Rights:

7.1.sec=Votes together with the Common Stock on all matters on an as-converted basis.

7.2.0.sec=Approval of a majority of the Preferred Stock required to

7.2.1.sec=adversely change rights of the Preferred Stock

7.2.2.sec=change the authorized number of shares

7.2.3.sec=authorize a new series of Preferred Stock having rights senior to or on parity with the Preferred Stock

7.2.4.sec=redeem or repurchase any shares (other than pursuant to employee or consultant agreements)

7.2.5.sec=declare or pay any dividend

7.2.6.sec=change the number of directors

7.2.7.sec=liquidate or dissolve, including any change of control

7.2.=[G/Z/ol-i/s7]

7.2.xlist={7.2.secs;or}

7.=[G/Z/ol-i/s2]

8.Ti=Documentation:

8.sec=This Term Sheet, and the related investment documents, have been prepared using industry-curated documents published at https://www.github.com/CooleyLLP/seriesseed/equity and made available via an automated document generator located at [Cooley GO Docs URL]. The final documents used will be identical to such documents, except for the modifications set forth in this Term Sheet.

9.Ti=Financial Information:

9.sec=Purchasers who have invested at least {MajorPurchaserDollarThreshold.$} ("Major Purchasers") will receive standard information and inspection rights.

10.Ti=Participation Right:

10.sec=Major Purchasers will have the right to participate on a pro rata basis in subsequent issuances of equity securities.

11.Sec={Board.Sec}

Board.Ti=Board of Directors:

Board.0.sec=The Board of Directors will consist of {TotalBoardMemberCount.#} members as follows:

Board.xlist=

{Board.Common.sec}
{Board.Seed.sec}
{Board.Blended.sec}

Board.Common.sec=Holders of Common Stock will have the right to elect {CommonBoardMemberCount.#} member[s] of the Board of Directors, initially {CommonBoardMember.IDs.cl}.

Board.Seed.sec=Holders of a majority of Series Seed will have the right to elect {SeedBoardMemberCount.#} member[s] of the Board of Directors, initially {SeedBoardMember.IDs.cl}.

Board.Blended.sec=Holders of Common Stock and Series Seed, voting together as a single class, will have the right to elect {MutualConsentBoardMemberCount.#} member[s] of the Board of Directors, initially {MutualConsentBoardMember.IDs.cl}.

Board.=[G/Z/ol/Base]

12.Ti=Expenses:

12.sec=Company to reimburse counsel to Purchasers for a flat fee of {PurchaserCounselReimbursementAmount.$}.

13.Ti=Future Rights:

13.sec=The Series Seed will be given the same rights as the next series of Preferred Stock (with appropriate adjustments for economic terms).

14.Ti=Key Holder Matters:

14.sec=Each Key Holder shall have four years vesting beginning {KeyHolderVesting.Begin.YMD}. Full acceleration upon "Double Trigger." Each Key Holder shall have assigned all relevant IP to the Company before closing.

15.Ti=Binding Terms:

15.sec=For a period of 30 days, the Company will not solicit offers from other parties for any financing.  Without the consent of Purchasers, the Company will not disclose these terms to anyone other than officers, directors, key service providers, and other potential Purchasers in this financing.

00.1.sec=Accepted and agreed as of the latest date set forth below:

00.2.sec={Company.US.Contract.By.Sec}
{LeadInvestor.By.Sec}

00.=[G/Z/paras/s2]

=[G/Z/ol/15]


text:
package scala.meta

import scala.annotation.implicitNotFound
import scala.{Seq => _}
import scala.collection.immutable.Seq
import org.scalameta.adt._
import scala.meta.dialects._
import scala.meta.internal.dialects._
import scala.language.experimental.macros
import scala.compat.Platform.EOL

// NOTE: can't put Dialect into scala.meta.Dialects
// because then implicit scope for Dialect lookups will contain members of the package object
// i.e. both Scala211 and Dotty, which is definitely not what we want
@root trait Dialect extends Serializable {
  // Canonical name for the dialect.
  // Can be used to uniquely identify the dialect, e.g. during serialization/deserialization.
  def name: String

  // What level of quoting are we at?
  // The underlying data structure captures additional information necessary for parsing.
  def metalevel: Metalevel

  // Permission to parse unquotes.
  // Necessary to support quasiquotes, e.g. `q"$x + $y"`.
  def allowUnquotes: Boolean = metalevel.isQuoted

  // Permission to tokenize repeated dots as ellipses and to parse ellipses.
  // Necessary to support quasiquotes, e.g. `q"foo(..$args)"`.
  def allowEllipses: Boolean = metalevel.isQuoted

  // The sequence of characters that's used to express a bind
  // to a sequence wildcard pattern.
  def bindToSeqWildcardDesignator: String

  // Are naked underscores allowed after $ in pattern interpolators, i.e. is `case q"$_ + $_" =>` legal or not?
  def allowSpliceUnderscore: Boolean

  // Are XML literals supported by this dialect?
  // We plan to deprecate XML literal syntax, and some dialects
  // might go ahead and drop support completely.
  def allowXmlLiterals: Boolean

  // Are inline vals and defs supported by this dialect?
  def allowInline: Boolean

  // Are terms on the top level supported by this dialect?
  // Necessary to support popular script-like DSLs.
  def allowToplevelTerms: Boolean

  // Are `|` (union types) supported by this dialect?
  def allowOrTypes: Boolean

  // What kind of separator is necessary to split top-level statements?
  // Normally none is required, but scripts may have their own rules.
  def toplevelSeparator: String

  // Are view bounds supported by this dialect?
  // Removed in Dotty.
  def allowViewBounds: Boolean

  // Are `&` intersection types supported by this dialect?
  def allowAndTypes: Boolean

  // Are `with` intersection types supported by this dialect?
  def allowWithTypes: Boolean = !allowAndTypes

  // Are trait allowed to have parameters?
  // They are in Dotty, but not in Scala 2.12 or older.
  def allowTraitParameters: Boolean
}

package object dialects {
  @leaf implicit object Scala210 extends Dialect {
    def name = "Scala210"
    def metalevel = Metalevel.Zero
    def bindToSeqWildcardDesignator = "@" // List(1, 2, 3) match { case List(xs @ _*) => ... }
    def allowXmlLiterals = true // Not even deprecated yet, so we need to support xml literals
    def allowInline = false
    def allowSpliceUnderscore = false // SI-7715, only fixed in 2.11.0-M5
    def allowToplevelTerms = false
    def allowOrTypes = false
    def toplevelSeparator = ""
    def allowViewBounds = true
    def allowAndTypes = false
    def allowTraitParameters = false
    private def writeReplace(): AnyRef = new Dialect.SerializationProxy(this)
  }

  @leaf implicit object Sbt0136 extends Dialect {
    def name = "Sbt0136"
    def metalevel = Metalevel.Zero
    def bindToSeqWildcardDesignator = Scala210.bindToSeqWildcardDesignator
    def allowXmlLiterals = Scala210.allowXmlLiterals
    def allowInline = false
    def allowSpliceUnderscore = Scala210.allowSpliceUnderscore
    def allowToplevelTerms = true
    def toplevelSeparator = EOL
    def allowViewBounds = Scala210.allowViewBounds
    def allowAndTypes = Scala210.allowAndTypes
    def allowOrTypes = Scala210.allowOrTypes
    def allowTraitParameters = Scala210.allowTraitParameters
    private def writeReplace(): AnyRef = new Dialect.SerializationProxy(this)
  }

  @leaf implicit object Sbt0137 extends Dialect {
    def name = "Sbt0137"
    def metalevel = Metalevel.Zero
    def bindToSeqWildcardDesignator = Scala210.bindToSeqWildcardDesignator
    def allowXmlLiterals = Scala210.allowXmlLiterals
    def allowInline = false
    def allowSpliceUnderscore = Scala210.allowSpliceUnderscore
    def allowToplevelTerms = true
    def toplevelSeparator = ""
    def allowViewBounds = Scala210.allowViewBounds
    def allowAndTypes = Scala210.allowAndTypes
    def allowOrTypes = Scala210.allowOrTypes
    def allowTraitParameters = Scala210.allowTraitParameters
    private def writeReplace(): AnyRef = new Dialect.SerializationProxy(this)
  }

  @leaf implicit object Scala211 extends Dialect {
    def name = "Scala211"
    def metalevel = Metalevel.Zero
    def bindToSeqWildcardDesignator = Scala210.bindToSeqWildcardDesignator
    def allowXmlLiterals = Scala210.allowXmlLiterals
    def allowInline = false
    def allowSpliceUnderscore = true // SI-7715, only fixed in 2.11.0-M5
    def allowToplevelTerms = Scala210.allowToplevelTerms
    def toplevelSeparator = Scala210.toplevelSeparator
    def allowViewBounds = Scala210.allowViewBounds
    def allowAndTypes = Scala210.allowAndTypes
    def allowOrTypes = Scala210.allowOrTypes
    def allowTraitParameters = Scala210.allowTraitParameters
    private def writeReplace(): AnyRef = new Dialect.SerializationProxy(this)
  }

  @leaf implicit object Paradise211 extends Dialect {
    def name = "Paradise211"
    def metalevel = Metalevel.Zero
    def bindToSeqWildcardDesignator = Scala211.bindToSeqWildcardDesignator
    def allowXmlLiterals = Scala211.allowXmlLiterals
    def allowInline = true
    def allowSpliceUnderscore = Scala211.allowSpliceUnderscore
    def allowToplevelTerms = Scala211.allowToplevelTerms
    def toplevelSeparator = Scala211.toplevelSeparator
    def allowViewBounds = Scala211.allowViewBounds
    def allowAndTypes = Scala211.allowAndTypes
    def allowOrTypes = Scala211.allowOrTypes
    def allowTraitParameters = Scala211.allowTraitParameters
    private def writeReplace(): AnyRef = new Dialect.SerializationProxy(this)
  }

  @leaf implicit object Scala212 extends Dialect {
    def name = "Scala212"
    def metalevel = Metalevel.Zero
    def bindToSeqWildcardDesignator = Scala211.bindToSeqWildcardDesignator
    def allowXmlLiterals = Scala211.allowXmlLiterals
    def allowInline = false
    def allowSpliceUnderscore = Scala211.allowSpliceUnderscore
    def allowToplevelTerms = Scala211.allowToplevelTerms
    def toplevelSeparator = Scala211.toplevelSeparator
    def allowViewBounds = Scala211.allowViewBounds
    def allowAndTypes = Scala211.allowAndTypes
    def allowOrTypes = Scala211.allowOrTypes
    def allowTraitParameters = Scala211.allowTraitParameters
    private def writeReplace(): AnyRef = new Dialect.SerializationProxy(this)
  }

  @leaf implicit object Paradise212 extends Dialect {
    def name = "Paradise212"
    def metalevel = Metalevel.Zero
    def bindToSeqWildcardDesignator = Scala212.bindToSeqWildcardDesignator
    def allowXmlLiterals = Scala212.allowXmlLiterals
    def allowInline = true
    def allowSpliceUnderscore = Scala212.allowSpliceUnderscore
    def allowToplevelTerms = Scala212.allowToplevelTerms
    def toplevelSeparator = Scala212.toplevelSeparator
    def allowViewBounds = Scala212.allowViewBounds
    def allowAndTypes = Scala212.allowAndTypes
    def allowOrTypes = Scala212.allowOrTypes
    def allowTraitParameters = Scala212.allowTraitParameters
    private def writeReplace(): AnyRef = new Dialect.SerializationProxy(this)
  }

  @leaf implicit object Dotty extends Dialect {
    def name = "Dotty"
    def metalevel = Metalevel.Zero
    def bindToSeqWildcardDesignator = ":" // // List(1, 2, 3) match { case List(xs: _*) => ... }
    def allowXmlLiterals = false // Dotty parser doesn't have the corresponding code, so it can't really support xml literals
    def allowInline = true
    def allowSpliceUnderscore = true
    def allowToplevelTerms = false
    def toplevelSeparator = ""
    def allowViewBounds = false // View bounds have been removed in Dotty
    def allowAndTypes = true
    def allowOrTypes = true
    def allowTraitParameters = true
    private def writeReplace(): AnyRef = new Dialect.SerializationProxy(this)
  }

  @branch private[meta] trait Quasiquote extends Dialect {
    def name = s"$qualifier(${underlying.name}, ${if (multiline) "Multi" else "Single"})"
    def multiline: Boolean
    def qualifier: String
    def underlying: Dialect
    def metalevel = Metalevel.Quoted
    def bindToSeqWildcardDesignator = underlying.bindToSeqWildcardDesignator
    def allowXmlLiterals = underlying.allowXmlLiterals
    def allowInline = underlying.allowInline
    def allowSpliceUnderscore = underlying.allowSpliceUnderscore
    def allowToplevelTerms = underlying.allowToplevelTerms
    def toplevelSeparator = underlying.toplevelSeparator
    def allowViewBounds = underlying.allowViewBounds
    def allowAndTypes = underlying.allowAndTypes
    def allowOrTypes = underlying.allowOrTypes
    def allowTraitParameters = underlying.allowTraitParameters
  }

  @leaf private[meta] class QuasiquoteTerm(underlying: Dialect, multiline: Boolean) extends Quasiquote {
    require(!underlying.isInstanceOf[Quasiquote])
    def qualifier = s"QuasiquoteTerm"
    private def writeReplace(): AnyRef = new Dialect.SerializationProxy(this)
    override def toString = name
  }

  @leaf private[meta] class QuasiquotePat(underlying: Dialect, multiline: Boolean) extends Quasiquote {
    require(!underlying.isInstanceOf[Quasiquote])
    def qualifier = s"QuasiquotePat"
    private def writeReplace(): AnyRef = new Dialect.SerializationProxy(this)
    override def toString = name
  }

  // NOTE: The syntax for nested interpolation is ugly to the point of being impractical.
  // That's why we won't implement support for it for the time being.
  // However, it'd have been reasonably simple:
  //  * For 0..nesting-1, 2^n dollars in a row drop us to a level-n unquote.
  //  * 2^nesting dollars in a row represent a dollar character itself.
  @root trait Metalevel {
    def isQuoted: Boolean = nesting > 0
    def nesting: Int
  }
  object Metalevel {
    @leaf object Zero extends Metalevel { def nesting: Int = 0 }
    @leaf object Quoted extends Metalevel { def nesting: Int = 1 }
  }
}

object Dialect {
  lazy val all: Seq[Dialect] = scala.meta.internal.dialects.all

  // NOTE: See https://github.com/scalameta/scalameta/issues/253 for discussion.
  implicit def current: Dialect = macro Macros.current

  def forName(name: String): Dialect = {
    def maybeVanilla = all.find(_.name == name)
    def maybeQuasiquote = """^Quasiquote(.+?)\((.*?)\)$""".r.unapplySeq(name).map {
      case List(qualifier, props) =>
        def failQualifier() = {
          val message = s"unexpected quasiquote qualifier: expected = Term|Pat, actual = $qualifier"
          throw new IllegalArgumentException(message)
        }
        def failProps() = {
          val expected = """QuasiquoteTerm|QuasiquotePat(.*?, Single|Multi)"""
          val message = s"unexpected quasiquote properties: expected = $expected, actual = Quasiquote$qualifier($props)"
          throw new IllegalArgumentException(message)
        }
        val (underlying, multiline) = """^\s*(.*?)\s*,\s*(Single|Multi)\s*$""".r.unapplySeq(props) match {
          case Some(List(s_underlying, s_multiline)) => (Dialect.forName(s_underlying), s_multiline == "Multi")
          case _ => failProps()
        }
        qualifier match {
          case "Term" => QuasiquoteTerm(underlying, multiline)
          case "Pat" => QuasiquotePat(underlying, multiline)
          case other => failQualifier()
        }
    }
    def fail() = throw new IllegalArgumentException(s"unknown dialect $name")
    maybeVanilla.orElse(maybeQuasiquote).getOrElse(fail())
  }

  @SerialVersionUID(1L) private[meta] class SerializationProxy(@transient private var orig: Dialect) extends Serializable {
    private def writeObject(out: java.io.ObjectOutputStream): Unit = {
      out.writeObject(orig.name)
    }
    private def readObject(in: java.io.ObjectInputStream): Unit = {
      val name = in.readObject.asInstanceOf[String]
      orig = Dialect.forName(name)
    }
    private def readResolve(): AnyRef = orig
    override def toString = s"Proxy($orig)"
  }
}


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 com.groupon.mesos.state;

import java.io.File;

import com.google.common.io.Files;

import org.apache.mesos.state.State;
import org.junit.After;
import org.junit.Before;

public class TestJLevelDBState
    extends AbstractTestState
{
    private File levelDbFolder;
    private JLevelDBState state;

    @Before
    public void setUp()
        throws Exception
    {
        levelDbFolder = Files.createTempDir();
        state = new JLevelDBState(levelDbFolder.getAbsolutePath());
    }

    @After
    public void tearDown()
        throws Exception
    {
        state.close();

        for (final File file : Files.fileTreeTraverser().postOrderTraversal(levelDbFolder)) {
            file.delete();
        }
    }

    @Override
    protected State getState()
    {
        return state;
    }
}


text:
Allows you to redirect visitors or switch language according to their country.

## About

Written by Boston Dell-Vandenberg of [Pomelo Design](http://www.pomelodesign.com). Pomelo Design is a web and mobile app development agency based in Toronto, Canada.

## Credits

Originally based on [Geo Redirect](https://wordpress.org/plugins/geographical-redirect) by [@ladrower](https://profiles.wordpress.org/ladrower/).


text:
<?php
//Form Validation
$config['error_prefix'] = '
';
$config['error_suffix'] = '
';
?>


text:
/*
 * Copyright (C) 1995-96   Silicon Graphics, Inc.
 *
 _______________________________________________________________________
 ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
 |
 |   $Revision: 1.1.1.1 $
 |
 |   Classes:
 |	SoV2AsciiText
 |
 |   Author(s)		: David Mott
 |
 ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
 _______________________________________________________________________
 */

#include "SoV2AsciiText.h"
#include <Inventor/nodes/SoAsciiText.h>
#include <Inventor/errors/SoReadError.h>

SO_NODE_SOURCE(SoV2AsciiText);

////////////////////////////////////////////////////////////////////////
//
// Description:
//    Default constructor
//
// Use: public

SoV2AsciiText::SoV2AsciiText()
//
////////////////////////////////////////////////////////////////////////
{
    SO_NODE_CONSTRUCTOR(SoV2AsciiText);

    SO_NODE_ADD_FIELD(string,	(""));
    SO_NODE_ADD_FIELD(spacing,	(1.0));
    SO_NODE_ADD_FIELD(justification,	(LEFT));
    SO_NODE_ADD_FIELD(width,	(0));
    SO_NODE_ADD_FIELD(alternateRep, (NULL));

    // Set up static info for enumerated type field
    SO_NODE_DEFINE_ENUM_VALUE(Justification,	LEFT);
    SO_NODE_DEFINE_ENUM_VALUE(Justification,	RIGHT);
    SO_NODE_DEFINE_ENUM_VALUE(Justification,	CENTER);

    // Set up info in enumerated type field
    SO_NODE_SET_SF_ENUM_TYPE(justification, Justification);
}

////////////////////////////////////////////////////////////////////////
//
// Description:
//    Destructor.
//
// Use: private

SoV2AsciiText::~SoV2AsciiText()
//
////////////////////////////////////////////////////////////////////////
{
}

////////////////////////////////////////////////////////////////////////
//
// Description:
//    Create a version 2.1 AsciiText.
//
// Use: private

SoNode *
SoV2AsciiText::createNewNode()
//
////////////////////////////////////////////////////////////////////////
{
    SoAsciiText *result = SO_UPGRADER_CREATE_NEW(SoAsciiText);

    //
    // Inventor 2.0 did not have AsciiText, When we convert 2.1 to 2.0 files,
    // the AsciiText gets written with an alternateRep. When we read that 2.0
    // file back into 2.1, we can discard the alternateRep. Programs written
    // with 2.0 will gladly use the alternateRep.
    //

    // Copy all fields as is (except alternateRep which is ignored)
    SO_UPGRADER_COPY_FIELD(string,	    result);
    SO_UPGRADER_COPY_FIELD(spacing,	    result);
    SO_UPGRADER_COPY_FIELD(justification,   result);
    SO_UPGRADER_COPY_FIELD(width,	    result);

    return result;
}
////////////////////////////////////////////////////////////////////////
//
// Description:
//   special upgrade method to read field description
//
// Use: public, internal, virtual
SbBool
SoV2AsciiText::upgrade(SoInput *in, const SbName &refName, SoBase *&result)
//
////////////////////////////////////////////////////////////////////////
{
    SbBool isBinary = in->isBinary();
    if (in->isBinary()){
	SbString unknownString;
	SbBool  readOK = in->read(unknownString);
	if (!readOK || (unknownString != "fields" )) {
	    SoReadError::post(in, "Problem upgrading vertex property ") ;
	    return FALSE;
	}
    }
    SbBool ret = SoUpgrader::upgrade(in, refName, result);

    if (in->isBinary()){
	// Read a zero, which represents the number of children here
	int dummy;
	in->read(dummy);
    }

    return ret;
}


text:
package edu.ur.ir.person.service;

import java.util.List;

import edu.ur.ir.institution.InstitutionalCollection;
import edu.ur.ir.person.PersonName;
import edu.ur.ir.person.PersonNameDAO;
import edu.ur.ir.person.PersonNameService;
import edu.ur.order.OrderType;

/**
 * Implementation of the person name service.
 *
 * @author Nathan Sarr
 *
 */
public class DefaultPersonNameService implements PersonNameService{

	/** eclipse generated id */
	private static final long serialVersionUID = 7285672671372870399L;

	/** data access for a person name  */
	private PersonNameDAO personNameDAO;

	/**
	 * @see edu.ur.ir.person.PersonNameService#getCollectionPersonNamesBetweenChar(int, int, edu.ur.ir.institution.InstitutionalCollection, char, char, edu.ur.order.OrderType)
	 */
	public List<PersonName> getCollectionPersonNamesBetweenChar(int rowStart,
			int maxResults, InstitutionalCollection collection,
			char firstChar, char lastChar, OrderType orderType) {
		return personNameDAO.getCollectionPersonNamesBetweenChar(rowStart, maxResults, collection, firstChar, lastChar, orderType);
	}

	/**
	 * @see edu.ur.ir.person.PersonNameService#getCollectionPersonNamesOrderByLastName(int, int, edu.ur.ir.institution.InstitutionalCollection, edu.ur.order.OrderType)
	 */
	public List<PersonName> getCollectionPersonNamesOrderByLastName(
			int rowStart, int rowEnd, InstitutionalCollection collection,
			OrderType orderType) {
		return personNameDAO.getCollectionPersonNamesByLastName(rowStart, rowEnd, collection, orderType);
	}

	/**
	 * @see edu.ur.ir.person.PersonNameService#getCount()
	 */
	public Long getCount() {
		return personNameDAO.getCount();
	}

	/**
	 * @see edu.ur.ir.person.PersonNameService#getCount(char)
	 */
	public Long getCount(char lastNameFirstChar) {
		return personNameDAO.getCount(lastNameFirstChar);
	}

	/**
	 * @see edu.ur.ir.person.PersonNameService#getCount(char, char)
	 */
	public Long getCount(char lastNameFirstCharRange, char lastNamelastCharRange) {
		return personNameDAO.getCount(lastNameFirstCharRange, lastNamelastCharRange);
	}

	/**
	 * @see edu.ur.ir.person.PersonNameService#getCount(edu.ur.ir.institution.InstitutionalCollection, char)
	 */
	public Long getCount(InstitutionalCollection collection,
			char lastNameFirstChar) {
		return personNameDAO.getCount(collection, lastNameFirstChar);
	}

	/**
	 * @see edu.ur.ir.person.PersonNameService#getCount(edu.ur.ir.institution.InstitutionalCollection, char, char)
	 */
	public Long getCount(InstitutionalCollection collection,
			char lastNameFirstCharRange, char nameLastCharRange) {
		return personNameDAO.getCount(collection, lastNameFirstCharRange, nameLastCharRange);
	}

	/**
	 * @see edu.ur.ir.person.PersonNameService#getPersonNamesBetweenChar(int, int, char, char, edu.ur.order.OrderType)
	 */
	public List<PersonName> getPersonNamesBetweenChar(int rowStart,
			int maxResults, char lastNamefirstChar, char lastNamelastChar,
			OrderType orderType) {
		return personNameDAO.getPersonNamesBetweenChar(rowStart, maxResults, lastNamefirstChar, lastNamelastChar, orderType);
	}

	/**
	 * @see edu.ur.ir.person.PersonNameService#getPersonNamesByChar(int, int, edu.ur.ir.institution.InstitutionalCollection, char, java.lang.String)
	 */
	public List<PersonName> getPersonNamesByChar(int rowStart, int maxResults,
			InstitutionalCollection collection, char firstChar,
			OrderType orderType) {
		return personNameDAO.getCollectionPersonNamesByChar(rowStart, maxResults, collection, firstChar, orderType);
	}

	/**
	 * @see edu.ur.ir.person.PersonNameService#getPersonNamesByLastNameChar(int, int, char, edu.ur.order.OrderType)
	 */
	public List<PersonName> getPersonNamesByLastNameChar(int rowStart,
			int maxResults, char firstChar, OrderType orderType) {
		return personNameDAO.getPersonNamesByChar(rowStart, maxResults, firstChar, orderType);
	}

	/**
	 * @see edu.ur.ir.person.PersonNameService#getPersonNamesOrderByLastName(int, int, edu.ur.order.OrderType)
	 */
	public List<PersonName> getPersonNamesOrderByLastName(int rowStart,
			int maxResults, OrderType orderType) {
		return personNameDAO.getPersonNamesByLastName(rowStart, maxResults, orderType);
	}

	public PersonNameDAO getPersonNameDAO() {
		return personNameDAO;
	}

	public void setPersonNameDAO(PersonNameDAO personNameDAO) {
		this.personNameDAO = personNameDAO;
	}

	public Long getCount(InstitutionalCollection collection) {
		return personNameDAO.getCount(collection);
	}

}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Chiodecton amyloplacoides Vain.

### Remarks
null


text:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.acoshDependencies = void 0;

var _dependenciesComplexClass = require("./dependenciesComplexClass.generated");

var _dependenciesTyped = require("./dependenciesTyped.generated");

var _factoriesAny = require("../../factoriesAny.js");

/**
 * THIS FILE IS AUTO-GENERATED
 * DON'T MAKE CHANGES HERE
 */
var acoshDependencies = {
  ComplexDependencies: _dependenciesComplexClass.ComplexDependencies,
  typedDependencies: _dependenciesTyped.typedDependencies,
  createAcosh: _factoriesAny.createAcosh
};
exports.acoshDependencies = acoshDependencies;