Implements the formatSkeleton method.
503911
private MethodSpec buildSkeletonFormatter(List<Skeleton> skeletons) {
    MethodSpec.Builder method = MethodSpec.methodBuilder("formatSkeleton")
        .addAnnotation(Override.class)
        .addModifiers(PUBLIC)
        .addParameter(String.class, "skeleton")
        .addParameter(ZonedDateTime.class, "d")
        .addParameter(StringBuilder.class, "b")
        .returns(boolean.class);

    method.beginControlFlow("if (skeleton == null)");
    method.addStatement("return false");
    method.endControlFlow();
    
    method.beginControlFlow("switch (skeleton)");

    // Skeleton patterns.
    for (Skeleton skeleton : skeletons) {
      method.beginControlFlow("case $S:", skeleton.skeleton)
        .addComment("Pattern: $S", skeleton.pattern);

      addPattern(method, skeleton.pattern);

      method.addStatement("break");
      method.endControlFlow();
    }

    method.beginControlFlow("default:");
    method.addStatement("return false");
    method.endControlFlow();

    method.endControlFlow();
    method.addStatement("return true");
    
    return method.build();
  }
1187676
public static synchronized FormatSet getFormatSet() {
        if (svNumberCached == 0)
            return new FormatSet();
        else {
            FormatSet fs = svInstances.remove(0);
            --svNumberCached;
            return fs;
        }
    }
467027
private void appendHourFormat(MethodSpec.Builder method, List<Node> fmt) {
    for (Node n : fmt) {
      if (n instanceof Text) {
        String t = ((Text)n).text();
        boolean minute = t.equals(":") || t.equals(".");
        if (minute) {
          method.beginControlFlow("if (emitMins)");
        }
        method.addStatement("b.append($S)", t);
        if (minute) {
          method.endControlFlow();
        }
      } else {
        Field f = (Field)n;
        if (f.ch() == 'H') {
          if (f.width() == 1) {
            method.addStatement("zeroPad2(b, hours, 1)");
          } else {
            method.addStatement("zeroPad2(b, hours, _short ? 1 : $L)", f.width());
          }
        } else {
          method.beginControlFlow("if (emitMins)");
          method.addStatement("zeroPad2(b, mins, $L)", f.width());
          method.endControlFlow();
        }
      }
    }
  }
837898
private void writeMethods(Definition def, Writer out, int indent) throws IOException
   {
      if (def.getMcfDefs().get(0).isDefineMethodInConnection())
      {
         if (def.getMcfDefs().get(0).getMethods().size() > 0)
         {
            for (MethodForConnection method : def.getMcfDefs().get(0).getMethods())
            {
               writeMethodSignature(out, indent, method);

               writeLeftCurlyBracket(out, indent);
               writeIndent(out, indent + 1);
               if (!method.getReturnType().equals("void"))
               {
                  out.write("return ");
               }
               out.write("getConnection()." + method.getMethodName() + "(");
               int paramSize = method.getParams().size();
               for (int i = 0; i < paramSize; i++)
               {
                  MethodParam param = method.getParams().get(i);
                  out.write(param.getName());
                  if (i + 1 < paramSize)
                     out.write(", ");
               }
               out.write(");\n");

               writeRightCurlyBracket(out, indent);
            }
         }
      }
      else
      {
         writeSimpleMethodSignature(out, indent, " * Call me", "public void callMe()");
         writeLeftCurlyBracket(out, indent);
         writeWithIndent(out, indent + 1, "try");
         writeLeftCurlyBracket(out, indent + 1);
         writeWithIndent(out, indent + 2, "getConnection().callMe();");
         writeRightCurlyBracket(out, indent + 1);
         writeWithIndent(out, indent + 1, "catch (Exception e)");
         writeLeftCurlyBracket(out, indent + 1);
         writeRightCurlyBracket(out, indent + 1);
         writeRightCurlyBracket(out, indent);
      }
   }
345583
def getSkeletalBoneData(self, action, eTransformSpace, eMotionRange, unTransformArrayCount):
        """"""

        fn = self.function_table.getSkeletalBoneData
        pTransformArray = VRBoneTransform_t()
        result = fn(action, eTransformSpace, eMotionRange, byref(pTransformArray), unTransformArrayCount)
        return result, pTransformArray
804719
public void setInputFormatClass(Class<? extends InputFormat> cls
                                  ) throws IllegalStateException {
    ensureState(JobState.DEFINE);
    conf.setClass(INPUT_FORMAT_CLASS_ATTR, cls, InputFormat.class);
  }
383215
private MethodSpec buildTypedPatternMethod(String methodName, ClassName type, Format format) {
    MethodSpec.Builder method = MethodSpec.methodBuilder(methodName)
        .addAnnotation(Override.class)
        .addModifiers(PUBLIC)
        .addParameter(CALENDAR_FORMAT, "type")
        .addParameter(ZonedDateTime.class, "d")
        .addParameter(StringBuilder.class, "b");

    method.beginControlFlow("if (type == null)");
    method.addStatement("return");
    method.endControlFlow();
    
    method.beginControlFlow("switch (type)", type);
    addTypedPattern(method, "SHORT", format.short_);
    addTypedPattern(method, "MEDIUM", format.medium);
    addTypedPattern(method, "LONG", format.long_);
    addTypedPattern(method, "FULL", format.full);
    method.endControlFlow();
    
    return method.build();
  }
717014
private void subFormat(int patternCharIndex, int count,
                           FieldDelegate delegate, StringBuffer buffer,
                           boolean useDateFormatSymbols)
    {
        int     maxIntCount = Integer.MAX_VALUE;
        String  current = null;
        int     beginOffset = buffer.length();

        int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex];
        int value;
        if (field == CalendarBuilder.WEEK_YEAR) {
            if (calendar.isWeekDateSupported()) {
                value = calendar.getWeekYear();
            } else {
                // use calendar year 'y' instead
                patternCharIndex = PATTERN_YEAR;
                field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex];
                value = calendar.get(field);
            }
        } else if (field == CalendarBuilder.ISO_DAY_OF_WEEK) {
            value = CalendarBuilder.toISODayOfWeek(calendar.get(Calendar.DAY_OF_WEEK));
        } else {
            value = calendar.get(field);
        }

        int style = (count >= 4) ? Calendar.LONG : Calendar.SHORT;
        if (!useDateFormatSymbols && field != CalendarBuilder.ISO_DAY_OF_WEEK) {
            current = calendar.getDisplayName(field, style, locale);
        }

        // Note: zeroPaddingNumber() assumes that maxDigits is either
        // 2 or maxIntCount. If we make any changes to this,
        // zeroPaddingNumber() must be fixed.

        switch (patternCharIndex) {
        case PATTERN_ERA: // 'G'
            if (useDateFormatSymbols) {
                String[] eras = formatData.getEras();
                if (value < eras.length)
                    current = eras[value];
            }
            if (current == null)
                current = "";
            break;

        case PATTERN_WEEK_YEAR: // 'Y'
        case PATTERN_YEAR:      // 'y'
            if (calendar instanceof GregorianCalendar) {
                if (count != 2)
                    zeroPaddingNumber(value, count, maxIntCount, buffer);
                else // count == 2
                    zeroPaddingNumber(value, 2, 2, buffer); // clip 1996 to 96
            } else {
                if (current == null) {
                    zeroPaddingNumber(value, style == Calendar.LONG ? 1 : count,
                                      maxIntCount, buffer);
                }
            }
            break;

        case PATTERN_STANDALONE_MONTH: // 'L'
        {
            current = formatMonth(count, value, maxIntCount, buffer, useDateFormatSymbols,
                    true /* standalone */);
            break;
        }

        case PATTERN_MONTH: // 'M'
        {
            current = formatMonth(count, value, maxIntCount, buffer, useDateFormatSymbols,
                    false /* standalone */);
            break;
        }

        case PATTERN_HOUR_OF_DAY1: // 'k' 1-based.  eg, 23:59 + 1 hour =>> 24:59
            if (current == null) {
                if (value == 0)
                    zeroPaddingNumber(calendar.getMaximum(Calendar.HOUR_OF_DAY)+1,
                                      count, maxIntCount, buffer);
                else
                    zeroPaddingNumber(value, count, maxIntCount, buffer);
            }
            break;

        case PATTERN_STANDALONE_DAY_OF_WEEK: // 'c'
        {
            current = formatWeekday(count, value, useDateFormatSymbols, true /* standalone */);
            break;
        }

        case PATTERN_DAY_OF_WEEK: // 'E'
        {
            current = formatWeekday(count, value, useDateFormatSymbols, false /* standalone */);
            break;
        }

        case PATTERN_AM_PM:    // 'a'
            if (useDateFormatSymbols) {
                String[] ampm = formatData.getAmPmStrings();
                current = ampm[value];
            }
            break;

        // Android-added: Ignore 'b' and 'B' introduced in CLDR 32+ pattern data. http://b/68139386
        // Not currently supported here.
        case PATTERN_DAY_PERIOD:
        case PATTERN_FLEXIBLE_DAY_PERIOD:
            current = "";
            break;

        case PATTERN_HOUR1:    // 'h' 1-based.  eg, 11PM + 1 hour =>> 12 AM
            if (current == null) {
                if (value == 0)
                    zeroPaddingNumber(calendar.getLeastMaximum(Calendar.HOUR)+1,
                                      count, maxIntCount, buffer);
                else
                    zeroPaddingNumber(value, count, maxIntCount, buffer);
            }
            break;

        case PATTERN_ZONE_NAME: // 'z'
            if (current == null) {
                TimeZone tz = calendar.getTimeZone();
                boolean daylight = (calendar.get(Calendar.DST_OFFSET) != 0);
                int tzstyle = count < 4 ? TimeZone.SHORT : TimeZone.LONG;
                String zoneString = tz.getDisplayName(daylight, tzstyle, formatData.locale);
                if (zoneString != null) {
                    buffer.append(zoneString);
                } else {
                    int offsetMillis = calendar.get(Calendar.ZONE_OFFSET) +
                        calendar.get(Calendar.DST_OFFSET);
                    buffer.append(TimeZone.createGmtOffsetString(true, true, offsetMillis));
                }
            }
            break;

        case PATTERN_ZONE_VALUE: // 'Z' ("-/+hhmm" form)
        {
            value = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
            final boolean includeSeparator = (count >= 4);
            final boolean includeGmt = (count == 4);
            buffer.append(TimeZone.createGmtOffsetString(includeGmt, includeSeparator, value));

            break;
        }

        case PATTERN_ISO_ZONE:   // 'X'
            value = calendar.get(Calendar.ZONE_OFFSET)
                    + calendar.get(Calendar.DST_OFFSET);

            if (value == 0) {
                buffer.append('Z');
                break;
            }

            value /=  60000;
            if (value >= 0) {
                buffer.append('+');
            } else {
                buffer.append('-');
                value = -value;
            }

            CalendarUtils.sprintf0d(buffer, value / 60, 2);
            if (count == 1) {
                break;
            }

            if (count == 3) {
                buffer.append(':');
            }
            CalendarUtils.sprintf0d(buffer, value % 60, 2);
            break;
        case PATTERN_MILLISECOND: // 'S'
            // Fractional seconds must be treated specially. We must always convert the parsed
            // value into a fractional second [0, 1) and then widen it out to the appropriate
            // formatted size. For example, an initial value of 789 will be converted
            // 0.789 and then become ".7" (S) or ".78" (SS) or "0.789" (SSS) or "0.7890" (SSSS)
            // in the resulting formatted output.
            if (current == null) {
                value = (int) (((double) value / 1000) * Math.pow(10, count));
                zeroPaddingNumber(value, count, count, buffer);
            }
            break;

        default:
     // case PATTERN_DAY_OF_MONTH:         // 'd'
     // case PATTERN_HOUR_OF_DAY0:         // 'H' 0-based.  eg, 23:59 + 1 hour =>> 00:59
     // case PATTERN_MINUTE:               // 'm'
     // case PATTERN_SECOND:               // 's'
     // case PATTERN_DAY_OF_YEAR:          // 'D'
     // case PATTERN_DAY_OF_WEEK_IN_MONTH: // 'F'
     // case PATTERN_WEEK_OF_YEAR:         // 'w'
     // case PATTERN_WEEK_OF_MONTH:        // 'W'
     // case PATTERN_HOUR0:                // 'K' eg, 11PM + 1 hour =>> 0 AM
     // case PATTERN_ISO_DAY_OF_WEEK:      // 'u' pseudo field, Monday = 1, ..., Sunday = 7
            if (current == null) {
                zeroPaddingNumber(value, count, maxIntCount, buffer);
            }
            break;
        } // switch (patternCharIndex)

        if (current != null) {
            buffer.append(current);
        }

        int fieldID = PATTERN_INDEX_TO_DATE_FORMAT_FIELD[patternCharIndex];
        Field f = PATTERN_INDEX_TO_DATE_FORMAT_FIELD_ID[patternCharIndex];

        delegate.formatted(fieldID, f, f, beginOffset, buffer.length(), buffer);
    }
808687
private void addWrapper(MethodSpec.Builder method, String pattern) {
    method.addComment("$S", pattern);
    for (Node node : WRAPPER_PARSER.parseWrapper(pattern)) {
      if (node instanceof Text) {
        method.addStatement("b.append($S)", ((Text)node).text());

      } else if (node instanceof Field) {
        Field field = (Field)node;
        switch (field.ch()) {
          case '0':
            method.beginControlFlow("if (timeType != null)");
            method.addStatement("formatTime(timeType, d, b)");
            method.nextControlFlow("else");
            method.addStatement("formatSkeleton(timeSkel, d, b)");
            method.endControlFlow();
            break;

          case '1':
            method.beginControlFlow("if (dateType != null)");
            method.addStatement("formatDate(dateType, d, b)");
            method.nextControlFlow("else");
            method.addStatement("formatSkeleton(dateSkel, d, b)");
            method.endControlFlow();
            break;
        }
      }
    }
  }
659342
def _register_formats(cls):
        """"""
        for fmt in cls.OUTPUT_FORMATS:
            clean_fmt = fmt.replace('+', '_')
            setattr(cls, clean_fmt, property(
                (lambda x, fmt=fmt: cls._output(x, fmt)), # fget
                (lambda x, y, fmt=fmt: cls._input(x, y, fmt))))
607839
private static void translate(Syntax syntax,
            int modifier, Definition source, List<Definition> targets, int[] moves, IntBitSet[] stoppers) throws GenericException {
        Path path;
        int count;

        path = new Path(syntax.getGrammar(), modifier, source, targets, moves, stoppers);
        count = path.translate();
        if (count == 0 && source.getAttribute().symbol != syntax.getGrammar().getStart()) {
            // TODO: improved error message
            throw new GenericException("dead-end path for attribute " + source.getName());
        }
    }
1168038
function walkAndFormat(node) {
  if (node) {
    if (node.append !== 'once') {
      if (node.children && node.children.length) {
        for (var i = 0, len = node.children.length; i < len; i++) {
          walkAndFormat(node.children[i])
        }
      }
    }
    else {
      format(node)
    }
  }
}
9820
def method_missing(name, &block)
      @formats.push([name, block || proc {}]) unless @formats.any? {|n,b| n == name}
    end
1038519
String formatUnits(int units) {
		switch (unitType) {
			case ENGLISH:
				return NumberFormat.getDecimalFormat().format(units) + (widthInUnitsIsMiles ? " mi" : " yd");
			case ENGLISH_FOOT:
				return NumberFormat.getDecimalFormat().format(units) + (widthInUnitsIsMiles ? " mi" : " ft");
			case METRIC:
				if (units < 10000) {
					return NumberFormat.getDecimalFormat().format(units) + " m";
				} else {
					return NumberFormat.getDecimalFormat().format((double) units / 1000) + " km";
				}

			case CRS:
				return NumberFormat.getDecimalFormat().format(units) + " u";

			default:
				throw new IllegalStateException("Unknown unit type " + unitType);
		}
	}
248778
private void setIntervalPattern(String skeleton,
                                    String lrgDiffCalUnit,
                                    PatternInfo ptnInfo) {
        Map<String, PatternInfo> patternsOfOneSkeleton = fIntervalPatterns.get(skeleton);
        patternsOfOneSkeleton.put(lrgDiffCalUnit, ptnInfo);
    }
1143317
private void initInputFormat(ClassLoader cl) {
		// instantiate the stub
		@SuppressWarnings("unchecked")
		Class<InputFormat<OT, InputSplit>> superClass = (Class<InputFormat<OT, InputSplit>>) (Class<?>) InputFormat.class;
		this.format = RegularPactTask.instantiateUserCode(this.config, cl, superClass);
		
		// configure the stub. catch exceptions here extra, to report them as originating from the user code 
		try {
			this.format.configure(this.config.getStubParameters());
		}
		catch (Throwable t) {
			throw new RuntimeException("The user defined 'configure()' method caused an error: " + t.getMessage(), t);
		}
		
		// get the factory for the type serializer
		this.serializerFactory = this.config.getOutputSerializer(cl);
	}
259844
def getSkeletalActionData(self, action, unActionDataSize):
        """"""

        fn = self.function_table.getSkeletalActionData
        pActionData = InputSkeletalActionData_t()
        result = fn(action, byref(pActionData), unActionDataSize)
        return result, pActionData