_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q25200
FloatUtils.computeAutoGeneratedAxisValues
train
public static void computeAutoGeneratedAxisValues(float start, float stop, int steps, AxisAutoValues outValues) { double range = stop - start; if (steps == 0 || range <= 0) { outValues.values = new float[]{}; outValues.valuesNumber = 0; return; } doub...
java
{ "resource": "" }
q25201
ChartComputator.setContentRect
train
public void setContentRect(int width, int height, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) { chartWidth = width; chartHeight = height; maxContentRect.set(paddingLeft, paddingTop, width - paddingRight, height - paddingBottom); co...
java
{ "resource": "" }
q25202
ChartComputator.constrainViewport
train
public void constrainViewport(float left, float top, float right, float bottom) { if (right - left < minViewportWidth) { // Minimum width - constrain horizontal zoom! right = left + minViewportWidth; if (left < maxViewport.left) { left = maxViewport.left; ...
java
{ "resource": "" }
q25203
ChartComputator.computeRawX
train
public float computeRawX(float valueX) { // TODO: (contentRectMinusAllMargins.width() / currentViewport.width()) can be recalculated only when viewport // change. final float pixelOffset = (valueX - currentViewport.left) * (contentRectMinusAllMargins.width() / currentViewport.wid...
java
{ "resource": "" }
q25204
ChartComputator.computeRawY
train
public float computeRawY(float valueY) { final float pixelOffset = (valueY - currentViewport.bottom) * (contentRectMinusAllMargins.height() / currentViewport.height()); return contentRectMinusAllMargins.bottom - pixelOffset; }
java
{ "resource": "" }
q25205
ChartComputator.isWithinContentRect
train
public boolean isWithinContentRect(float x, float y, float precision) { if (x >= contentRectMinusAllMargins.left - precision && x <= contentRectMinusAllMargins.right + precision) { if (y <= contentRectMinusAllMargins.bottom + precision && y >= contentRectMinusAllMargins.top - pre...
java
{ "resource": "" }
q25206
ChartComputator.setCurrentViewport
train
public void setCurrentViewport(Viewport viewport) { constrainViewport(viewport.left, viewport.top, viewport.right, viewport.bottom); }
java
{ "resource": "" }
q25207
ChartComputator.setCurrentViewport
train
public void setCurrentViewport(float left, float top, float right, float bottom) { constrainViewport(left, top, right, bottom); }
java
{ "resource": "" }
q25208
ChartComputator.setMaxViewport
train
public void setMaxViewport(Viewport maxViewport) { setMaxViewport(maxViewport.left, maxViewport.top, maxViewport.right, maxViewport.bottom); }
java
{ "resource": "" }
q25209
ChartComputator.setMaxViewport
train
public void setMaxViewport(float left, float top, float right, float bottom) { this.maxViewport.set(left, top, right, bottom); computeMinimumWidthAndHeight(); }
java
{ "resource": "" }
q25210
ZoomerCompat.computeZoom
train
public boolean computeZoom() { if (mFinished) { return false; } long tRTC = SystemClock.elapsedRealtime() - mStartRTC; if (tRTC >= mAnimationDurationMillis) { mFinished = true; mCurrentZoom = mEndZoom; return false; } floa...
java
{ "resource": "" }
q25211
Axis.generateAxisFromRange
train
public static Axis generateAxisFromRange(float start, float stop, float step) { List<AxisValue> values = new ArrayList<AxisValue>(); for (float value = start; value <= stop; value += step) { AxisValue axisValue = new AxisValue(value); values.add(axisValue); } Ax...
java
{ "resource": "" }
q25212
Axis.generateAxisFromCollection
train
public static Axis generateAxisFromCollection(List<Float> axisValues) { List<AxisValue> values = new ArrayList<AxisValue>(); int index = 0; for (float value : axisValues) { AxisValue axisValue = new AxisValue(value); values.add(axisValue); ++index; } ...
java
{ "resource": "" }
q25213
Axis.generateAxisFromCollection
train
public static Axis generateAxisFromCollection(List<Float> axisValues, List<String> axisValuesLabels) { if (axisValues.size() != axisValuesLabels.size()) { throw new IllegalArgumentException("Values and labels lists must have the same size!"); } List<AxisValue> values = new ArrayList...
java
{ "resource": "" }
q25214
AbstractChartRenderer.drawLabelTextAndBackground
train
protected void drawLabelTextAndBackground(Canvas canvas, char[] labelBuffer, int startIndex, int numChars, int autoBackgroundColor) { final float textX; final float textY; if (isValueLabelBackgroundEnabled) { if (isValueLabelBackgroundA...
java
{ "resource": "" }
q25215
Viewport.set
train
public void set(Viewport src) { this.left = src.left; this.top = src.top; this.right = src.right; this.bottom = src.bottom; }
java
{ "resource": "" }
q25216
Viewport.contains
train
public boolean contains(Viewport v) { // check for empty first return this.left < this.right && this.bottom < this.top // now check for containment && left <= v.left && top >= v.top && right >= v.right && bottom <= v.bottom; }
java
{ "resource": "" }
q25217
AxesRenderer.drawInForeground
train
public void drawInForeground(Canvas canvas) { Axis axis = chart.getChartData().getAxisYLeft(); if (null != axis) { drawAxisLabelsAndName(canvas, axis, LEFT); } axis = chart.getChartData().getAxisYRight(); if (null != axis) { drawAxisLabelsAndName(canvas, ...
java
{ "resource": "" }
q25218
LineChartRenderer.drawPoints
train
private void drawPoints(Canvas canvas, Line line, int lineIndex, int mode) { pointPaint.setColor(line.getPointColor()); int valueIndex = 0; for (PointValue pointValue : line.getValues()) { int pointRadius = ChartUtils.dp2px(density, line.getPointRadius()); final float raw...
java
{ "resource": "" }
q25219
AbstractChartView.canScrollHorizontally
train
@Override public boolean canScrollHorizontally(int direction) { if (getZoomLevel() <= 1.0) { return false; } final Viewport currentViewport = getCurrentViewport(); final Viewport maximumViewport = getMaximumViewport(); if (direction < 0) { return curre...
java
{ "resource": "" }
q25220
PieChartRenderer.pointToAngle
train
private float pointToAngle(float x, float y, float centerX, float centerY) { double diffX = x - centerX; double diffY = y - centerY; // Pass -diffX to get clockwise degrees order. double radian = Math.atan2(-diffX, diffY); float angle = ((float) Math.toDegrees(radian) + 360) % 3...
java
{ "resource": "" }
q25221
PieChartRenderer.calculateMaxViewport
train
private void calculateMaxViewport() { tempMaximumViewport.set(0, MAX_WIDTH_HEIGHT, MAX_WIDTH_HEIGHT, 0); maxSum = 0.0f; for (SliceValue sliceValue : dataProvider.getPieChartData().getValues()) { maxSum += Math.abs(sliceValue.getValue()); } }
java
{ "resource": "" }
q25222
AbstractWebController.translate
train
protected String translate(String key, Object... objects) { return messageSource.getMessage(key, objects, null); }
java
{ "resource": "" }
q25223
AbstractWebController.buildOKResponse
train
protected <T extends AbstractBase> ResponseEntity<Response<T>> buildOKResponse(T... params) { return buildResponse(HttpStatus.OK, "", "", params); }
java
{ "resource": "" }
q25224
AbstractWebController.getLocationForCreatedResource
train
protected String getLocationForCreatedResource(HttpServletRequest req, String objId) { StringBuffer url = req.getRequestURL(); UriTemplate template = new UriTemplate(url.append("/{objId}/").toString()); return template.expand(objId).toASCIIString(); }
java
{ "resource": "" }
q25225
DefaultDockerClientConfig.overrideDockerPropertiesWithSystemProperties
train
private static Properties overrideDockerPropertiesWithSystemProperties(Properties p, Properties systemProperties) { Properties overriddenProperties = new Properties(); overriddenProperties.putAll(p); for (String key : CONFIG_KEYS) { if (systemProperties.containsKey(key)) { ...
java
{ "resource": "" }
q25226
DefaultDockerClientConfig.createDefaultConfigBuilder
train
static Builder createDefaultConfigBuilder(Map<String, String> env, Properties systemProperties) { Properties properties = loadIncludedDockerProperties(systemProperties); properties = overrideDockerPropertiesWithSettingsFromUserHome(properties, systemProperties); properties = overrideDockerProper...
java
{ "resource": "" }
q25227
KeystoreSSLConfig.getSSLContext
train
@Override public SSLContext getSSLContext() throws KeyManagementException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException { final SSLContext context = SSLContext.getInstance("TLS"); String httpProtocols = System.getProperty("https.protocols"); System.set...
java
{ "resource": "" }
q25228
WaitContainerResultCallback.awaitStatusCode
train
public Integer awaitStatusCode(long timeout, TimeUnit timeUnit) { try { if (!awaitCompletion(timeout, timeUnit)) { throw new DockerClientException("Awaiting status code timeout."); } } catch (InterruptedException e) { throw new DockerClientException("A...
java
{ "resource": "" }
q25229
CertificateUtils.loadCertificates
train
public static List<Certificate> loadCertificates(final String certpem) throws IOException, CertificateException { final StringReader certReader = new StringReader(certpem); try (BufferedReader reader = new BufferedReader(certReader)) { return loadCertificates(reader); } ...
java
{ "resource": "" }
q25230
CertificateUtils.loadCertificates
train
public static List<Certificate> loadCertificates(final Reader reader) throws IOException, CertificateException { try (PEMParser pemParser = new PEMParser(reader)) { List<Certificate> certificates = new ArrayList<>(); JcaX509CertificateConverter certificateConverter = new Jca...
java
{ "resource": "" }
q25231
CertificateUtils.getPrivateKeyInfoOrNull
train
@CheckForNull private static PrivateKeyInfo getPrivateKeyInfoOrNull(Object pemObject) throws NoSuchAlgorithmException { PrivateKeyInfo privateKeyInfo = null; if (pemObject instanceof PEMKeyPair) { PEMKeyPair pemKeyPair = (PEMKeyPair) pemObject; privateKeyInfo = pemKeyPair.get...
java
{ "resource": "" }
q25232
CertificateUtils.loadPrivateKey
train
@CheckForNull public static PrivateKey loadPrivateKey(final String keypem) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException { try (StringReader certReader = new StringReader(keypem); BufferedReader reader = new BufferedReader(certReader)) { return lo...
java
{ "resource": "" }
q25233
CertificateUtils.createTrustStore
train
public static KeyStore createTrustStore(String capem) throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException { try (Reader certReader = new StringReader(capem)) { return createTrustStore(certReader); } }
java
{ "resource": "" }
q25234
CertificateUtils.createTrustStore
train
public static KeyStore createTrustStore(final Reader certReader) throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException { try (PEMParser pemParser = new PEMParser(certReader)) { KeyStore trustStore = KeyStore.getInstance("JKS"); trustStore.load...
java
{ "resource": "" }
q25235
FiltersBuilder.withLabels
train
public FiltersBuilder withLabels(Map<String, String> labels) { withFilter("label", labelsMapToList(labels).toArray(new String[labels.size()])); return this; }
java
{ "resource": "" }
q25236
PullResponseItem.isPullSuccessIndicated
train
@JsonIgnore public boolean isPullSuccessIndicated() { if (isErrorIndicated() || getStatus() == null) { return false; } return (getStatus().contains(DOWNLOAD_COMPLETE) || getStatus().contains(IMAGE_UP_TO_DATE) || getStatus().contains(DOWNLOADED_NEW...
java
{ "resource": "" }
q25237
CompressArchiveUtil.tar
train
public static void tar(Path inputPath, Path outputPath, boolean gZipped, boolean childrenOnly) throws IOException { if (!Files.exists(inputPath)) { throw new FileNotFoundException("File not found " + inputPath); } FileUtils.touch(outputPath.toFile()); try (TarArchiveOutputSt...
java
{ "resource": "" }
q25238
ChunkedInputStream.parseTrailerHeaders
train
private void parseTrailerHeaders() throws IOException { try { this.footers = AbstractMessageParser.parseHeaders(in, constraints.getMaxHeaderCount(), constraints.getMaxLineLength(), null); } catch (final HttpException ex) { ...
java
{ "resource": "" }
q25239
DockerfileStatement.createFromLine
train
public static Optional<? extends DockerfileStatement> createFromLine(String cmd) { if (cmd.trim().isEmpty() || cmd.startsWith("#")) { return Optional.absent(); } Optional<? extends DockerfileStatement> line; line = Add.create(cmd); if (line.isPresent()) { ...
java
{ "resource": "" }
q25240
GoLangFileMatch.match
train
public static List<String> match(List<String> patterns, String name) { List<String> matches = new ArrayList<String>(); for (String pattern : patterns) { if (match(pattern, name)) { matches.add(pattern); } } return matches; }
java
{ "resource": "" }
q25241
BuildImageResultCallback.awaitImageId
train
public String awaitImageId(long timeout, TimeUnit timeUnit) { try { awaitCompletion(timeout, timeUnit); } catch (InterruptedException e) { throw new DockerClientException("Awaiting image id interrupted: ", e); } return getImageId(); }
java
{ "resource": "" }
q25242
CPI.setColumnsMap
train
public static void setColumnsMap(Record record, Map<String, Object> columns) { record.setColumnsMap(columns); }
java
{ "resource": "" }
q25243
Routes.add
train
public Routes add(String controllerKey, Class<? extends Controller> controllerClass) { return add(controllerKey, controllerClass, controllerKey); }
java
{ "resource": "" }
q25244
Routes.addInterceptor
train
public Routes addInterceptor(Interceptor interceptor) { if (com.jfinal.aop.AopManager.me().isInjectDependency()) { com.jfinal.aop.Aop.inject(interceptor); } injectInters.add(interceptor); return this; }
java
{ "resource": "" }
q25245
Routes.setBaseViewPath
train
public Routes setBaseViewPath(String baseViewPath) { if (StrKit.isBlank(baseViewPath)) { throw new IllegalArgumentException("baseViewPath can not be blank"); } baseViewPath = baseViewPath.trim(); if (! baseViewPath.startsWith("/")) { // add prefix "/" baseViewPath = "/" + baseViewPath; } ...
java
{ "resource": "" }
q25246
InvocationWrapper.invoke
train
@Override public final void invoke() { if (index < inters.length) inters[index++].intercept(this); else if (index++ == inters.length) invocation.invoke(); }
java
{ "resource": "" }
q25247
EngineConfig.addSharedFunction
train
public void addSharedFunction(String fileName) { fileName = fileName.replace("\\", "/"); // FileSource fileSource = new FileSource(baseTemplatePath, fileName, encoding); ISource source = sourceFactory.getSource(baseTemplatePath, fileName, encoding); doAddSharedFunction(source, fileName); }
java
{ "resource": "" }
q25248
EngineConfig.addSharedFunctionByString
train
public void addSharedFunctionByString(String content) { // content 中的内容被解析后会存放在 Env 之中,而 StringSource 所对应的 // Template 对象 isModified() 始终返回 false,所以没有必要对其缓存 StringSource stringSource = new StringSource(content, false); doAddSharedFunction(stringSource, null); }
java
{ "resource": "" }
q25249
EngineConfig.addSharedFunction
train
public void addSharedFunction(ISource source) { String fileName = source instanceof FileSource ? ((FileSource)source).getFileName() : null; doAddSharedFunction(source, fileName); }
java
{ "resource": "" }
q25250
EngineConfig.getSharedFunction
train
Define getSharedFunction(String functionName) { Define func = sharedFunctionMap.get(functionName); if (func == null) { /** * 如果 func 最初未定义,但后续在共享模板文件中又被添加进来 * 此时在本 if 分支中无法被感知,仍然返回了 null * * 但共享模板文件会在后续其它的 func 调用时被感知修改并 reload * 所以本 if 分支不考虑处理模板文件中追加 #define 的情况 * * 如果要处理...
java
{ "resource": "" }
q25251
EngineConfig.reloadSharedFunctionSourceList
train
private synchronized void reloadSharedFunctionSourceList() { Map<String, Define> newMap = createSharedFunctionMap(); for (int i = 0, size = sharedFunctionSourceList.size(); i < size; i++) { ISource source = sharedFunctionSourceList.get(i); String fileName = source instanceof FileSource ? ((FileSource)sour...
java
{ "resource": "" }
q25252
Config.getConnection
train
public Connection getConnection() throws SQLException { Connection conn = threadLocal.get(); if (conn != null) return conn; return showSql ? new SqlReporter(dataSource.getConnection()).getConnection() : dataSource.getConnection(); }
java
{ "resource": "" }
q25253
Interceptors.add
train
public Interceptors add(Interceptor globalActionInterceptor) { if (globalActionInterceptor == null) { throw new IllegalArgumentException("globalActionInterceptor can not be null."); } InterceptorManager.me().addGlobalActionInterceptor(globalActionInterceptor); return this; }
java
{ "resource": "" }
q25254
Interceptors.addGlobalServiceInterceptor
train
public Interceptors addGlobalServiceInterceptor(Interceptor globalServiceInterceptor) { if (globalServiceInterceptor == null) { throw new IllegalArgumentException("globalServiceInterceptor can not be null."); } InterceptorManager.me().addGlobalServiceInterceptor(globalServiceInterceptor); return this; ...
java
{ "resource": "" }
q25255
TokenManager.createToken
train
public static void createToken(Controller controller, String tokenName, int secondsOfTimeOut) { if (tokenCache == null) { String tokenId = String.valueOf(random.nextLong()); controller.setAttr(tokenName, tokenId); controller.setSessionAttr(tokenName, tokenId); createTokenHiddenField(controller, token...
java
{ "resource": "" }
q25256
TokenManager.validateToken
train
public static boolean validateToken(Controller controller, String tokenName) { String clientTokenId = controller.getPara(tokenName); if (tokenCache == null) { String serverTokenId = controller.getSessionAttr(tokenName); controller.removeSessionAttr(tokenName); // important! return StrKit.notBlank(cli...
java
{ "resource": "" }
q25257
Record.getColumns
train
@SuppressWarnings("unchecked") public Map<String, Object> getColumns() { if (columns == null) { if (DbKit.config == null) columns = DbKit.brokenConfig.containerFactory.getColumnsMap(); else columns = DbKit.config.containerFactory.getColumnsMap(); } return columns; }
java
{ "resource": "" }
q25258
Record.remove
train
public Record remove(String... columns) { if (columns != null) for (String c : columns) this.getColumns().remove(c); return this; }
java
{ "resource": "" }
q25259
Record.removeNullValueColumns
train
public Record removeNullValueColumns() { for (java.util.Iterator<Entry<String, Object>> it = getColumns().entrySet().iterator(); it.hasNext();) { Entry<String, Object> e = it.next(); if (e.getValue() == null) { it.remove(); } } return this; }
java
{ "resource": "" }
q25260
Record.keep
train
public Record keep(String... columns) { if (columns != null && columns.length > 0) { Map<String, Object> newColumns = new HashMap<String, Object>(columns.length); // getConfig().containerFactory.getColumnsMap(); for (String c : columns) if (this.getColumns().containsKey(c)) // prevent put null value to ...
java
{ "resource": "" }
q25261
Record.keep
train
public Record keep(String column) { if (getColumns().containsKey(column)) { // prevent put null value to the newColumns Object keepIt = getColumns().get(column); getColumns().clear(); getColumns().put(column, keepIt); } else getColumns().clear(); return this; }
java
{ "resource": "" }
q25262
Record.set
train
public Record set(String column, Object value) { getColumns().put(column, value); return this; }
java
{ "resource": "" }
q25263
Record.get
train
@SuppressWarnings("unchecked") public <T> T get(String column) { return (T)getColumns().get(column); }
java
{ "resource": "" }
q25264
Record.get
train
@SuppressWarnings("unchecked") public <T> T get(String column, Object defaultValue) { Object result = getColumns().get(column); return (T)(result != null ? result : defaultValue); }
java
{ "resource": "" }
q25265
Record.getColumnNames
train
public String[] getColumnNames() { Set<String> attrNameSet = getColumns().keySet(); return attrNameSet.toArray(new String[attrNameSet.size()]); }
java
{ "resource": "" }
q25266
Record.getColumnValues
train
public Object[] getColumnValues() { java.util.Collection<Object> attrValueCollection = getColumns().values(); return attrValueCollection.toArray(new Object[attrValueCollection.size()]); }
java
{ "resource": "" }
q25267
Controller.setAttr
train
public Controller setAttr(String name, Object value) { request.setAttribute(name, value); return this; }
java
{ "resource": "" }
q25268
Controller.setAttrs
train
public Controller setAttrs(Map<String, Object> attrMap) { for (Map.Entry<String, Object> entry : attrMap.entrySet()) request.setAttribute(entry.getKey(), entry.getValue()); return this; }
java
{ "resource": "" }
q25269
Controller.getPara
train
public String getPara(String name, String defaultValue) { String result = request.getParameter(name); return result != null && !"".equals(result) ? result : defaultValue; }
java
{ "resource": "" }
q25270
Controller.getParaValuesToInt
train
public Integer[] getParaValuesToInt(String name) { String[] values = request.getParameterValues(name); if (values == null || values.length == 0) { return null; } Integer[] result = new Integer[values.length]; for (int i=0; i<result.length; i++) { result[i] = StrKit.isBlank(values[i]) ? null : Int...
java
{ "resource": "" }
q25271
Controller.getParaToInt
train
public Integer getParaToInt(String name, Integer defaultValue) { return toInt(request.getParameter(name), defaultValue); }
java
{ "resource": "" }
q25272
Controller.getParaToLong
train
public Long getParaToLong(String name, Long defaultValue) { return toLong(request.getParameter(name), defaultValue); }
java
{ "resource": "" }
q25273
Controller.getParaToBoolean
train
public Boolean getParaToBoolean(String name, Boolean defaultValue) { return toBoolean(request.getParameter(name), defaultValue); }
java
{ "resource": "" }
q25274
Controller.getParaToDate
train
public Date getParaToDate(String name, Date defaultValue) { return toDate(request.getParameter(name), defaultValue); }
java
{ "resource": "" }
q25275
Controller.getSessionAttr
train
public <T> T getSessionAttr(String key) { HttpSession session = request.getSession(false); return session != null ? (T)session.getAttribute(key) : null; }
java
{ "resource": "" }
q25276
Controller.removeSessionAttr
train
public Controller removeSessionAttr(String key) { HttpSession session = request.getSession(false); if (session != null) session.removeAttribute(key); return this; }
java
{ "resource": "" }
q25277
Controller.getCookie
train
public String getCookie(String name, String defaultValue) { Cookie cookie = getCookieObject(name); return cookie != null ? cookie.getValue() : defaultValue; }
java
{ "resource": "" }
q25278
Controller.getCookieToInt
train
public Integer getCookieToInt(String name, Integer defaultValue) { String result = getCookie(name); return result != null ? Integer.parseInt(result) : defaultValue; }
java
{ "resource": "" }
q25279
Controller.getCookieToLong
train
public Long getCookieToLong(String name) { String result = getCookie(name); return result != null ? Long.parseLong(result) : null; }
java
{ "resource": "" }
q25280
Controller.getCookieObject
train
public Cookie getCookieObject(String name) { Cookie[] cookies = request.getCookies(); if (cookies != null) for (Cookie cookie : cookies) if (cookie.getName().equals(name)) return cookie; return null; }
java
{ "resource": "" }
q25281
Controller.getCookieObjects
train
public Cookie[] getCookieObjects() { Cookie[] result = request.getCookies(); return result != null ? result : new Cookie[0]; }
java
{ "resource": "" }
q25282
Controller.setCookie
train
public Controller setCookie(String name, String value, int maxAgeInSeconds, String path, boolean isHttpOnly) { return doSetCookie(name, value, maxAgeInSeconds, path, null, isHttpOnly); }
java
{ "resource": "" }
q25283
Controller.getPara
train
public String getPara(int index) { if (index < 0) return getPara(); if (urlParaArray == null) { if (urlPara == null || "".equals(urlPara)) // urlPara maybe is "" see ActionMapping.getAction(String) urlParaArray = NULL_URL_PARA_ARRAY; else urlParaArray = urlPara.split(URL_PARA_SEPARATOR);...
java
{ "resource": "" }
q25284
Controller.getPara
train
public String getPara(int index, String defaultValue) { String result = getPara(index); return result != null && !"".equals(result) ? result : defaultValue; }
java
{ "resource": "" }
q25285
Controller.getModel
train
public <T> T getModel(Class<T> modelClass) { return (T)Injector.injectModel(modelClass, request, false); }
java
{ "resource": "" }
q25286
Controller.getFiles
train
public List<UploadFile> getFiles(String uploadPath, Integer maxPostSize, String encoding) { if (request instanceof MultipartRequest == false) request = new MultipartRequest(request, uploadPath, maxPostSize, encoding); return ((MultipartRequest)request).getFiles(); }
java
{ "resource": "" }
q25287
Controller.keepPara
train
public Controller keepPara() { Map<String, String[]> map = request.getParameterMap(); for (Entry<String, String[]> e: map.entrySet()) { String[] values = e.getValue(); if (values.length == 1) request.setAttribute(e.getKey(), values[0]); else request.setAttribute(e.getKey(), values); } ...
java
{ "resource": "" }
q25288
Controller.keepPara
train
public Controller keepPara(String... names) { for (String name : names) { String[] values = request.getParameterValues(name); if (values != null) { if (values.length == 1) request.setAttribute(name, values[0]); else request.setAttribute(name, values); } } return this; }
java
{ "resource": "" }
q25289
Controller.keepPara
train
public Controller keepPara(Class type, String name) { String[] values = request.getParameterValues(name); if (values != null) { if (values.length == 1) try {request.setAttribute(name, TypeConverter.me().convert(type, values[0]));} catch (ParseException e) {com.jfinal.kit.LogKit.logNothing(e);} else ...
java
{ "resource": "" }
q25290
Env.addFunction
train
public void addFunction(Define function) { String fn = function.getFunctionName(); if (functionMap.containsKey(fn)) { Define previous = functionMap.get(fn); throw new ParseException( "Template function \"" + fn + "\" already defined in " + getAlreadyDefinedLocation(previous.getLocation()), ...
java
{ "resource": "" }
q25291
Env.getFunction
train
public Define getFunction(String functionName) { Define func = functionMap.get(functionName); return func != null ? func : engineConfig.getSharedFunction(functionName); }
java
{ "resource": "" }
q25292
Engine.create
train
public synchronized static Engine create(String engineName) { if (StrKit.isBlank(engineName)) { throw new IllegalArgumentException("Engine name can not be blank"); } engineName = engineName.trim(); if (engineMap.containsKey(engineName)) { throw new IllegalArgumentException("Engine already exists : "...
java
{ "resource": "" }
q25293
Engine.remove
train
public synchronized static Engine remove(String engineName) { Engine removed = engineMap.remove(engineName); if (removed != null && MAIN_ENGINE_NAME.equals(removed.name)) { Engine.MAIN_ENGINE = null; } return removed; }
java
{ "resource": "" }
q25294
Engine.setMainEngine
train
public synchronized static void setMainEngine(Engine engine) { if (engine == null) { throw new IllegalArgumentException("Engine can not be null"); } engine.name = Engine.MAIN_ENGINE_NAME; engineMap.put(Engine.MAIN_ENGINE_NAME, engine); Engine.MAIN_ENGINE = engine; }
java
{ "resource": "" }
q25295
Engine.getTemplate
train
public Template getTemplate(String fileName) { if (fileName.charAt(0) != '/') { char[] arr = new char[fileName.length() + 1]; fileName.getChars(0, fileName.length(), arr, 1); arr[0] = '/'; fileName = new String(arr); } Template template = templateCache.get(fileName); if (template == null...
java
{ "resource": "" }
q25296
Engine.getTemplateByString
train
public Template getTemplateByString(String content, boolean cache) { if (!cache) { return buildTemplateBySource(new StringSource(content, cache)); } String cacheKey = HashKit.md5(content); Template template = templateCache.get(cacheKey); if (template == null) { template = buildTemplateBySourc...
java
{ "resource": "" }
q25297
Engine.getTemplate
train
public Template getTemplate(ISource source) { String cacheKey = source.getCacheKey(); if (cacheKey == null) { // cacheKey 为 null 则不缓存,详见 ISource.getCacheKey() 注释 return buildTemplateBySource(source); } Template template = templateCache.get(cacheKey); if (template == null) { template = buildTe...
java
{ "resource": "" }
q25298
Engine.addSharedObject
train
public Engine addSharedObject(String name, Object object) { config.addSharedObject(name, object); return this; }
java
{ "resource": "" }
q25299
DbKit.addConfig
train
public static void addConfig(Config config) { if (config == null) { throw new IllegalArgumentException("Config can not be null"); } if (configNameToConfig.containsKey(config.getName())) { throw new IllegalArgumentException("Config already exists: " + config.getName()); } configNameToConfig.pu...
java
{ "resource": "" }