Constructs a new TimeItem from a String previously gotten from the {@link #toString()} method.
@param code The string to parse from.
@return A new TimeItem, or null if there was an error.
765474
public static TimeItem fromString(String code) {
        String[] items = code.split("\n");
        if(items.length != 5) return null;
        int hour, minute, id;
        try {
            hour = Integer.parseInt(items[2]);
            minute = Integer.parseInt(items[3]);
            id = Integer.parseInt(items[4]);
        }
        catch (NumberFormatException e) {
            e.printStackTrace();
            return null;
        }
        return new TimeItem(emptyToNull(items[0]), emptyToNull(items[1]), hour, minute, id);
    }
1212205
public List
getOptions(int code) {
	if (options == null)
		return Collections.EMPTY_LIST;
	List list = null;
	for (Iterator it = options.iterator(); it.hasNext(); ) {
		Option opt = (Option) it.next();
		if (opt.code == code) {
			if (list == null)
				list = new ArrayList();
			list.add(opt.data);
		}
	}
	if (list == null)
		return Collections.EMPTY_LIST;
	return list;
}
1348428
public static Timecode valueOf(String timecode) throws IllegalArgumentException
    {
        Timecode tc = new Timecode();
        return (Timecode) tc.parse(timecode);
    }
539494
def get_dict(self, time, code):
        '''
        
        '''
        try:
            return self.dicts[(QA_util_to_datetime(time), str(code))]
        except Exception as e:
            raise e
144375
protected MessageFormat resolveCode(String code, Locale locale) {
        MessageFormat result = null;

        if (cachedMilliSecond == 0
                || ((result = cachedMessages.get(new CacheKey(
                        code, locale))) == null)
                || lastQuery + cachedMilliSecond < System.currentTimeMillis()) {
            result = resolveCodeInternal(code, locale);
            cachedMessages.put(new CacheKey(code, locale), result);
        }

        if (result != null)
            return result;

        return resolveCodeInternal(code, locale);
    }
263289
@Override
	public void error(final String code) {
		WMessages instance = getWMessageInstance();

		if (instance != null) {
			instance.error(code);
		}
	}
345794
public RequestContext renderJSON(final int code) {
        final JsonRenderer jsonRenderer = new JsonRenderer();
        final JSONObject ret = new JSONObject().put(Keys.CODE, code);
        jsonRenderer.setJSONObject(ret);

        this.renderer = jsonRenderer;

        return this;
    }
1055542
public static String validate(String code) {
        try {
            toCurrency(code);
        } catch (IllegalArgumentException ex) {
            throw new InvalidValueException(code, "currency");
        }
        return code;
    }
203877
public static String format(final String code, final Properties options, final LineEnding lineEnding) {
		Check.notEmpty(code, "code");
		Check.notEmpty(options, "options");
		Check.notNull(lineEnding, "lineEnding");

		final CodeFormatter formatter = ToolFactory.createCodeFormatter(options);
		final String lineSeparator = LineEnding.find(lineEnding, code);
		TextEdit te = null;
		try {
			te = formatter.format(CodeFormatter.K_COMPILATION_UNIT, code, 0, code.length(), 0, lineSeparator);
		} catch (final Exception formatFailed) {
			LOG.warn("Formatting failed", formatFailed);
		}

		String formattedCode = code;
		if (te == null) {
			LOG.info("Code cannot be formatted. Possible cause is unmatched source/target/compliance version.");
		} else {

			final IDocument doc = new Document(code);
			try {
				te.apply(doc);
			} catch (final Exception e) {
				LOG.warn(e.getLocalizedMessage(), e);
			}
			formattedCode = doc.get();
		}
		return formattedCode;
	}
68461
@SuppressWarnings({"ThrowableInstanceNeverThrown"})
    public static HttpResponseException error(int code, String errorMessage) {
        return error(code,new Exception(errorMessage));
    }
1344020
public static MutableTimecode valueOf(String timecode) throws IllegalArgumentException
    {
        MutableTimecode tc = new MutableTimecode();
        return (MutableTimecode) tc.parse(timecode);
    }
284846
public RetResult<String> getMPOpenidByCode(String code) throws IOException {
        if (code != null) code = code.replace("\"", "").replace("'", "");
        String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + appsecret + "&code=" + code + "&grant_type=authorization_code";
        String json = getHttpContent(url);
        if (finest) logger.finest(url + "--->" + json);
        Map<String, String> jsonmap = convert.convertFrom(TYPE_MAP_STRING_STRING, json);
        return new RetResult<>(jsonmap.get("openid"));
    }
481172
private ImageFormat getImageFormatForCode(String code) {
        if (code == null || imageFormats == null) {
            return null;
        }
        for (ImageFormat oneImageFormat : imageFormats) {
            if (code.equalsIgnoreCase(oneImageFormat.getCode())) {
                return oneImageFormat;
            }
        }
        return null;
    }
69264
public static Time parseTime(String time) {
        Assert.assertTrue("time is required, but value is empty", Checker.isNotEmpty(time));
        String[] times = time.split(ValueConsts.COLON);
        String timeStr = formatTimeString(times[0]) + ":" + (times.length > 1 ? formatTimeString(times[1]) : "00") +
                ":" + (times.length > 2 ? formatTimeString(times[2]) : "00");
        return new Time(DateUtil.parseTime(timeStr).getTime());
    }
991037
public static String getDateTimeFormatString(ULocale loc, String calType, int dateStyle,
            int timeStyle) {
        if (timeStyle < DateFormat.NONE || timeStyle > DateFormat.SHORT) {
            throw new IllegalArgumentException("Illegal time style " + timeStyle);
        }
        if (dateStyle < DateFormat.NONE || dateStyle > DateFormat.SHORT) {
            throw new IllegalArgumentException("Illegal date style " + dateStyle);
        }

        PatternData patternData = PatternData.make(loc, calType);

        // Resolve a pattern for the date/time style
        String pattern = null;
        if ((timeStyle >= 0) && (dateStyle >= 0)) {
            pattern = SimpleFormatterImpl.formatRawPattern(
                    patternData.getDateTimePattern(dateStyle), 2, 2,
                    patternData.patterns[timeStyle],
                    patternData.patterns[dateStyle + 4]);
        } else if (timeStyle >= 0) {
            pattern = patternData.patterns[timeStyle];
        } else if (dateStyle >= 0) {
            pattern = patternData.patterns[dateStyle + 4];
        } else {
            throw new IllegalArgumentException("No date or time style specified");
        }
        return pattern;
    }
281472
public List
getOptions(int code) {
	if (options == null)
		return Collections.EMPTY_LIST;
	List list = Collections.EMPTY_LIST;
	for (Iterator it = options.iterator(); it.hasNext(); ) {
		EDNSOption opt = (EDNSOption) it.next();
		if (opt.getCode() == code) {
			if (list == Collections.EMPTY_LIST)
				list = new ArrayList();
			list.add(opt);
		}
	}
	return list;
}
858586
private Code parseCode(Element codeElement, Map<String, Scope> scopes) {
        // Code name
        Code code = new Code(nodeAttribute(codeElement, TAG_CODE_ATTR_NAME, Utils.generateRandomName()));

        // Code priority
        code.setPriority(nodeAttribute(codeElement, TAG_CODE_ATTR_PRIORITY, Code.DEFAULT_PRIORITY));

        // Do show variables outside the code?
        code.setTransparent(nodeAttribute(codeElement, TAG_CODE_ATTR_TRANSPARENT, true));

        // Template to building
        NodeList templateElements = codeElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_TEMPLATE);
        if (templateElements.getLength() > 0) {
            code.setTemplate(parseTemplate(templateElements.item(0)));
        } else {
            throw new TextProcessorFactoryException("Illegal configuration. Can't find template of code.");
        }

        // Pattern to parsing
        NodeList patternElements = codeElement.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_PATTERN);
        if (patternElements.getLength() > 0) {
            for (int i = 0; i < patternElements.getLength(); i++) {
                code.addPattern(parsePattern(patternElements.item(i), scopes));
            }
        } else {
            throw new TextProcessorFactoryException("Illegal configuration. Can't find pattern of code.");
        }

        // return code
        return code;
    }