id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
31,100 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/command/WaitContainerResultCallback.java | WaitContainerResultCallback.awaitStatusCode | 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("Awaiting status code interrupted: ", e);
}
return getStatusCode();
} | java | 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("Awaiting status code interrupted: ", e);
}
return getStatusCode();
} | [
"public",
"Integer",
"awaitStatusCode",
"(",
"long",
"timeout",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"awaitCompletion",
"(",
"timeout",
",",
"timeUnit",
")",
")",
"{",
"throw",
"new",
"DockerClientException",
"(",
"\"Awaiting stat... | Awaits the status code from the container.
@throws DockerClientException
if the wait operation fails. | [
"Awaits",
"the",
"status",
"code",
"from",
"the",
"container",
"."
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/command/WaitContainerResultCallback.java#L57-L67 |
31,101 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/util/CertificateUtils.java | CertificateUtils.loadCertificates | 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 | 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);
}
} | [
"public",
"static",
"List",
"<",
"Certificate",
">",
"loadCertificates",
"(",
"final",
"String",
"certpem",
")",
"throws",
"IOException",
",",
"CertificateException",
"{",
"final",
"StringReader",
"certReader",
"=",
"new",
"StringReader",
"(",
"certpem",
")",
";",... | from "cert.pem" String | [
"from",
"cert",
".",
"pem",
"String"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/util/CertificateUtils.java#L74-L80 |
31,102 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/util/CertificateUtils.java | CertificateUtils.loadCertificates | 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 JcaX509CertificateConverter()
.setProvider(BouncyCastleProvider.PROVIDER_NAME);
Object certObj = pemParser.readObject();
if (certObj instanceof X509CertificateHolder) {
X509CertificateHolder certificateHolder = (X509CertificateHolder) certObj;
certificates.add(certificateConverter.getCertificate(certificateHolder));
}
return certificates;
}
} | java | 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 JcaX509CertificateConverter()
.setProvider(BouncyCastleProvider.PROVIDER_NAME);
Object certObj = pemParser.readObject();
if (certObj instanceof X509CertificateHolder) {
X509CertificateHolder certificateHolder = (X509CertificateHolder) certObj;
certificates.add(certificateConverter.getCertificate(certificateHolder));
}
return certificates;
}
} | [
"public",
"static",
"List",
"<",
"Certificate",
">",
"loadCertificates",
"(",
"final",
"Reader",
"reader",
")",
"throws",
"IOException",
",",
"CertificateException",
"{",
"try",
"(",
"PEMParser",
"pemParser",
"=",
"new",
"PEMParser",
"(",
"reader",
")",
")",
"... | "cert.pem" from reader | [
"cert",
".",
"pem",
"from",
"reader"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/util/CertificateUtils.java#L85-L101 |
31,103 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/util/CertificateUtils.java | CertificateUtils.getPrivateKeyInfoOrNull | @CheckForNull
private static PrivateKeyInfo getPrivateKeyInfoOrNull(Object pemObject) throws NoSuchAlgorithmException {
PrivateKeyInfo privateKeyInfo = null;
if (pemObject instanceof PEMKeyPair) {
PEMKeyPair pemKeyPair = (PEMKeyPair) pemObject;
privateKeyInfo = pemKeyPair.getPrivateKeyInfo();
} else if (pemObject instanceof PrivateKeyInfo) {
privateKeyInfo = (PrivateKeyInfo) pemObject;
} else if (pemObject instanceof ASN1ObjectIdentifier) {
// no idea how it can be used
final ASN1ObjectIdentifier asn1ObjectIdentifier = (ASN1ObjectIdentifier) pemObject;
LOG.trace("Ignoring asn1ObjectIdentifier {}", asn1ObjectIdentifier);
} else {
LOG.warn("Unknown object '{}' from PEMParser", pemObject);
}
return privateKeyInfo;
} | java | @CheckForNull
private static PrivateKeyInfo getPrivateKeyInfoOrNull(Object pemObject) throws NoSuchAlgorithmException {
PrivateKeyInfo privateKeyInfo = null;
if (pemObject instanceof PEMKeyPair) {
PEMKeyPair pemKeyPair = (PEMKeyPair) pemObject;
privateKeyInfo = pemKeyPair.getPrivateKeyInfo();
} else if (pemObject instanceof PrivateKeyInfo) {
privateKeyInfo = (PrivateKeyInfo) pemObject;
} else if (pemObject instanceof ASN1ObjectIdentifier) {
// no idea how it can be used
final ASN1ObjectIdentifier asn1ObjectIdentifier = (ASN1ObjectIdentifier) pemObject;
LOG.trace("Ignoring asn1ObjectIdentifier {}", asn1ObjectIdentifier);
} else {
LOG.warn("Unknown object '{}' from PEMParser", pemObject);
}
return privateKeyInfo;
} | [
"@",
"CheckForNull",
"private",
"static",
"PrivateKeyInfo",
"getPrivateKeyInfoOrNull",
"(",
"Object",
"pemObject",
")",
"throws",
"NoSuchAlgorithmException",
"{",
"PrivateKeyInfo",
"privateKeyInfo",
"=",
"null",
";",
"if",
"(",
"pemObject",
"instanceof",
"PEMKeyPair",
"... | Find a PrivateKeyInfo in the PEM object details. Returns null if the PEM object type is unknown. | [
"Find",
"a",
"PrivateKeyInfo",
"in",
"the",
"PEM",
"object",
"details",
".",
"Returns",
"null",
"if",
"the",
"PEM",
"object",
"type",
"is",
"unknown",
"."
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/util/CertificateUtils.java#L127-L143 |
31,104 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/util/CertificateUtils.java | CertificateUtils.loadPrivateKey | @CheckForNull
public static PrivateKey loadPrivateKey(final String keypem) throws IOException, NoSuchAlgorithmException,
InvalidKeySpecException {
try (StringReader certReader = new StringReader(keypem);
BufferedReader reader = new BufferedReader(certReader)) {
return loadPrivateKey(reader);
}
} | java | @CheckForNull
public static PrivateKey loadPrivateKey(final String keypem) throws IOException, NoSuchAlgorithmException,
InvalidKeySpecException {
try (StringReader certReader = new StringReader(keypem);
BufferedReader reader = new BufferedReader(certReader)) {
return loadPrivateKey(reader);
}
} | [
"@",
"CheckForNull",
"public",
"static",
"PrivateKey",
"loadPrivateKey",
"(",
"final",
"String",
"keypem",
")",
"throws",
"IOException",
",",
"NoSuchAlgorithmException",
",",
"InvalidKeySpecException",
"{",
"try",
"(",
"StringReader",
"certReader",
"=",
"new",
"String... | Return KeyPair from "key.pem" | [
"Return",
"KeyPair",
"from",
"key",
".",
"pem"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/util/CertificateUtils.java#L148-L155 |
31,105 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/util/CertificateUtils.java | CertificateUtils.createTrustStore | public static KeyStore createTrustStore(String capem) throws IOException, CertificateException,
KeyStoreException, NoSuchAlgorithmException {
try (Reader certReader = new StringReader(capem)) {
return createTrustStore(certReader);
}
} | java | public static KeyStore createTrustStore(String capem) throws IOException, CertificateException,
KeyStoreException, NoSuchAlgorithmException {
try (Reader certReader = new StringReader(capem)) {
return createTrustStore(certReader);
}
} | [
"public",
"static",
"KeyStore",
"createTrustStore",
"(",
"String",
"capem",
")",
"throws",
"IOException",
",",
"CertificateException",
",",
"KeyStoreException",
",",
"NoSuchAlgorithmException",
"{",
"try",
"(",
"Reader",
"certReader",
"=",
"new",
"StringReader",
"(",
... | "ca.pem" from String | [
"ca",
".",
"pem",
"from",
"String"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/util/CertificateUtils.java#L160-L165 |
31,106 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/util/CertificateUtils.java | CertificateUtils.createTrustStore | 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(null);
int index = 1;
Object pemCert;
while ((pemCert = pemParser.readObject()) != null) {
Certificate caCertificate = new JcaX509CertificateConverter()
.setProvider(BouncyCastleProvider.PROVIDER_NAME)
.getCertificate((X509CertificateHolder) pemCert);
trustStore.setCertificateEntry("ca-" + index, caCertificate);
index++;
}
return trustStore;
}
} | java | 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(null);
int index = 1;
Object pemCert;
while ((pemCert = pemParser.readObject()) != null) {
Certificate caCertificate = new JcaX509CertificateConverter()
.setProvider(BouncyCastleProvider.PROVIDER_NAME)
.getCertificate((X509CertificateHolder) pemCert);
trustStore.setCertificateEntry("ca-" + index, caCertificate);
index++;
}
return trustStore;
}
} | [
"public",
"static",
"KeyStore",
"createTrustStore",
"(",
"final",
"Reader",
"certReader",
")",
"throws",
"IOException",
",",
"CertificateException",
",",
"KeyStoreException",
",",
"NoSuchAlgorithmException",
"{",
"try",
"(",
"PEMParser",
"pemParser",
"=",
"new",
"PEMP... | "ca.pem" from Reader | [
"ca",
".",
"pem",
"from",
"Reader"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/util/CertificateUtils.java#L170-L190 |
31,107 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java | FiltersBuilder.withLabels | public FiltersBuilder withLabels(Map<String, String> labels) {
withFilter("label", labelsMapToList(labels).toArray(new String[labels.size()]));
return this;
} | java | public FiltersBuilder withLabels(Map<String, String> labels) {
withFilter("label", labelsMapToList(labels).toArray(new String[labels.size()]));
return this;
} | [
"public",
"FiltersBuilder",
"withLabels",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"labels",
")",
"{",
"withFilter",
"(",
"\"label\"",
",",
"labelsMapToList",
"(",
"labels",
")",
".",
"toArray",
"(",
"new",
"String",
"[",
"labels",
".",
"size",
"(",
... | Filter by labels
@param labels
{@link Map} of labels that contains label keys and values | [
"Filter",
"by",
"labels"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java#L84-L87 |
31,108 | docker-java/docker-java | src/main/java/com/github/dockerjava/api/model/PullResponseItem.java | PullResponseItem.isPullSuccessIndicated | @JsonIgnore
public boolean isPullSuccessIndicated() {
if (isErrorIndicated() || getStatus() == null) {
return false;
}
return (getStatus().contains(DOWNLOAD_COMPLETE) ||
getStatus().contains(IMAGE_UP_TO_DATE) ||
getStatus().contains(DOWNLOADED_NEWER_IMAGE) ||
getStatus().contains(LEGACY_REGISTRY) ||
getStatus().contains(DOWNLOADED_SWARM)
);
} | java | @JsonIgnore
public boolean isPullSuccessIndicated() {
if (isErrorIndicated() || getStatus() == null) {
return false;
}
return (getStatus().contains(DOWNLOAD_COMPLETE) ||
getStatus().contains(IMAGE_UP_TO_DATE) ||
getStatus().contains(DOWNLOADED_NEWER_IMAGE) ||
getStatus().contains(LEGACY_REGISTRY) ||
getStatus().contains(DOWNLOADED_SWARM)
);
} | [
"@",
"JsonIgnore",
"public",
"boolean",
"isPullSuccessIndicated",
"(",
")",
"{",
"if",
"(",
"isErrorIndicated",
"(",
")",
"||",
"getStatus",
"(",
")",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"getStatus",
"(",
")",
".",
"contai... | Returns whether the status indicates a successful pull operation
@returns true: status indicates that pull was successful, false: status doesn't indicate a successful pull | [
"Returns",
"whether",
"the",
"status",
"indicates",
"a",
"successful",
"pull",
"operation"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/api/model/PullResponseItem.java#L29-L41 |
31,109 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/util/CompressArchiveUtil.java | CompressArchiveUtil.tar | 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 (TarArchiveOutputStream tarArchiveOutputStream = buildTarStream(outputPath, gZipped)) {
if (!Files.isDirectory(inputPath)) {
TarArchiveEntry tarEntry = new TarArchiveEntry(inputPath.getFileName().toString());
if (inputPath.toFile().canExecute()) {
tarEntry.setMode(tarEntry.getMode() | 0755);
}
putTarEntry(tarArchiveOutputStream, tarEntry, inputPath);
} else {
Path sourcePath = inputPath;
if (!childrenOnly) {
// In order to have the dossier as the root entry
sourcePath = inputPath.getParent();
}
Files.walkFileTree(inputPath, EnumSet.of(FOLLOW_LINKS), Integer.MAX_VALUE,
new TarDirWalker(sourcePath, tarArchiveOutputStream));
}
tarArchiveOutputStream.flush();
}
} | java | 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 (TarArchiveOutputStream tarArchiveOutputStream = buildTarStream(outputPath, gZipped)) {
if (!Files.isDirectory(inputPath)) {
TarArchiveEntry tarEntry = new TarArchiveEntry(inputPath.getFileName().toString());
if (inputPath.toFile().canExecute()) {
tarEntry.setMode(tarEntry.getMode() | 0755);
}
putTarEntry(tarArchiveOutputStream, tarEntry, inputPath);
} else {
Path sourcePath = inputPath;
if (!childrenOnly) {
// In order to have the dossier as the root entry
sourcePath = inputPath.getParent();
}
Files.walkFileTree(inputPath, EnumSet.of(FOLLOW_LINKS), Integer.MAX_VALUE,
new TarDirWalker(sourcePath, tarArchiveOutputStream));
}
tarArchiveOutputStream.flush();
}
} | [
"public",
"static",
"void",
"tar",
"(",
"Path",
"inputPath",
",",
"Path",
"outputPath",
",",
"boolean",
"gZipped",
",",
"boolean",
"childrenOnly",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"Files",
".",
"exists",
"(",
"inputPath",
")",
")",
"{",
... | Recursively tar file
@param inputPath
file path can be directory
@param outputPath
where to put the archived file
@param childrenOnly
if inputPath is directory and if childrenOnly is true, the archive will contain all of its children, else the archive
contains unique entry which is the inputPath itself
@param gZipped
compress with gzip algorithm | [
"Recursively",
"tar",
"file"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/util/CompressArchiveUtil.java#L64-L88 |
31,110 | docker-java/docker-java | src/main/java/org/apache/http/impl/io/ChunkedInputStream.java | ChunkedInputStream.parseTrailerHeaders | private void parseTrailerHeaders() throws IOException {
try {
this.footers = AbstractMessageParser.parseHeaders(in,
constraints.getMaxHeaderCount(),
constraints.getMaxLineLength(),
null);
} catch (final HttpException ex) {
final IOException ioe = new MalformedChunkCodingException("Invalid footer: "
+ ex.getMessage());
ioe.initCause(ex);
throw ioe;
}
} | java | private void parseTrailerHeaders() throws IOException {
try {
this.footers = AbstractMessageParser.parseHeaders(in,
constraints.getMaxHeaderCount(),
constraints.getMaxLineLength(),
null);
} catch (final HttpException ex) {
final IOException ioe = new MalformedChunkCodingException("Invalid footer: "
+ ex.getMessage());
ioe.initCause(ex);
throw ioe;
}
} | [
"private",
"void",
"parseTrailerHeaders",
"(",
")",
"throws",
"IOException",
"{",
"try",
"{",
"this",
".",
"footers",
"=",
"AbstractMessageParser",
".",
"parseHeaders",
"(",
"in",
",",
"constraints",
".",
"getMaxHeaderCount",
"(",
")",
",",
"constraints",
".",
... | Reads and stores the Trailer headers.
@throws IOException in case of an I/O error | [
"Reads",
"and",
"stores",
"the",
"Trailer",
"headers",
"."
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java#L289-L301 |
31,111 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/dockerfile/DockerfileStatement.java | DockerfileStatement.createFromLine | 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()) {
return line;
}
line = Env.create(cmd);
if (line.isPresent()) {
return line;
}
return Optional.of(new OtherLine(cmd));
} | java | 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()) {
return line;
}
line = Env.create(cmd);
if (line.isPresent()) {
return line;
}
return Optional.of(new OtherLine(cmd));
} | [
"public",
"static",
"Optional",
"<",
"?",
"extends",
"DockerfileStatement",
">",
"createFromLine",
"(",
"String",
"cmd",
")",
"{",
"if",
"(",
"cmd",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
"||",
"cmd",
".",
"startsWith",
"(",
"\"#\"",
")",
")"... | Return a dockerfile statement | [
"Return",
"a",
"dockerfile",
"statement"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/dockerfile/DockerfileStatement.java#L202-L223 |
31,112 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/GoLangFileMatch.java | GoLangFileMatch.match | 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 | 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;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"match",
"(",
"List",
"<",
"String",
">",
"patterns",
",",
"String",
"name",
")",
"{",
"List",
"<",
"String",
">",
"matches",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"S... | Returns the matching patterns for the given string | [
"Returns",
"the",
"matching",
"patterns",
"for",
"the",
"given",
"string"
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/GoLangFileMatch.java#L66-L74 |
31,113 | docker-java/docker-java | src/main/java/com/github/dockerjava/core/command/BuildImageResultCallback.java | BuildImageResultCallback.awaitImageId | 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 | public String awaitImageId(long timeout, TimeUnit timeUnit) {
try {
awaitCompletion(timeout, timeUnit);
} catch (InterruptedException e) {
throw new DockerClientException("Awaiting image id interrupted: ", e);
}
return getImageId();
} | [
"public",
"String",
"awaitImageId",
"(",
"long",
"timeout",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"try",
"{",
"awaitCompletion",
"(",
"timeout",
",",
"timeUnit",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"DockerClie... | Awaits the image id from the response stream.
@throws DockerClientException
if the build fails or the timeout occurs. | [
"Awaits",
"the",
"image",
"id",
"from",
"the",
"response",
"stream",
"."
] | c5c89327108abdc50aa41d7711d4743b8bac75fe | https://github.com/docker-java/docker-java/blob/c5c89327108abdc50aa41d7711d4743b8bac75fe/src/main/java/com/github/dockerjava/core/command/BuildImageResultCallback.java#L60-L68 |
31,114 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/CPI.java | CPI.setColumnsMap | public static void setColumnsMap(Record record, Map<String, Object> columns) {
record.setColumnsMap(columns);
} | java | public static void setColumnsMap(Record record, Map<String, Object> columns) {
record.setColumnsMap(columns);
} | [
"public",
"static",
"void",
"setColumnsMap",
"(",
"Record",
"record",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"columns",
")",
"{",
"record",
".",
"setColumnsMap",
"(",
"columns",
")",
";",
"}"
] | Return the columns map of the record
@param record the Record object
@return the columns map of the record
public static final Map<String, Object> getColumns(Record record) {
return record.getColumns();
} | [
"Return",
"the",
"columns",
"map",
"of",
"the",
"record"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/CPI.java#L79-L81 |
31,115 | jfinal/jfinal | src/main/java/com/jfinal/config/Routes.java | Routes.add | public Routes add(String controllerKey, Class<? extends Controller> controllerClass) {
return add(controllerKey, controllerClass, controllerKey);
} | java | public Routes add(String controllerKey, Class<? extends Controller> controllerClass) {
return add(controllerKey, controllerClass, controllerKey);
} | [
"public",
"Routes",
"add",
"(",
"String",
"controllerKey",
",",
"Class",
"<",
"?",
"extends",
"Controller",
">",
"controllerClass",
")",
"{",
"return",
"add",
"(",
"controllerKey",
",",
"controllerClass",
",",
"controllerKey",
")",
";",
"}"
] | Add route. The viewPath is controllerKey
@param controllerKey A key can find controller
@param controllerClass Controller Class | [
"Add",
"route",
".",
"The",
"viewPath",
"is",
"controllerKey"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/config/Routes.java#L100-L102 |
31,116 | jfinal/jfinal | src/main/java/com/jfinal/config/Routes.java | Routes.addInterceptor | public Routes addInterceptor(Interceptor interceptor) {
if (com.jfinal.aop.AopManager.me().isInjectDependency()) {
com.jfinal.aop.Aop.inject(interceptor);
}
injectInters.add(interceptor);
return this;
} | java | public Routes addInterceptor(Interceptor interceptor) {
if (com.jfinal.aop.AopManager.me().isInjectDependency()) {
com.jfinal.aop.Aop.inject(interceptor);
}
injectInters.add(interceptor);
return this;
} | [
"public",
"Routes",
"addInterceptor",
"(",
"Interceptor",
"interceptor",
")",
"{",
"if",
"(",
"com",
".",
"jfinal",
".",
"aop",
".",
"AopManager",
".",
"me",
"(",
")",
".",
"isInjectDependency",
"(",
")",
")",
"{",
"com",
".",
"jfinal",
".",
"aop",
"."... | Add inject interceptor for controller in this Routes | [
"Add",
"inject",
"interceptor",
"for",
"controller",
"in",
"this",
"Routes"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/config/Routes.java#L107-L113 |
31,117 | jfinal/jfinal | src/main/java/com/jfinal/config/Routes.java | Routes.setBaseViewPath | 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;
}
if (baseViewPath.endsWith("/")) { // remove "/" in the end of baseViewPath
baseViewPath = baseViewPath.substring(0, baseViewPath.length() - 1);
}
this.baseViewPath = baseViewPath;
return this;
} | java | 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;
}
if (baseViewPath.endsWith("/")) { // remove "/" in the end of baseViewPath
baseViewPath = baseViewPath.substring(0, baseViewPath.length() - 1);
}
this.baseViewPath = baseViewPath;
return this;
} | [
"public",
"Routes",
"setBaseViewPath",
"(",
"String",
"baseViewPath",
")",
"{",
"if",
"(",
"StrKit",
".",
"isBlank",
"(",
"baseViewPath",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"baseViewPath can not be blank\"",
")",
";",
"}",
"baseViewP... | Set base view path for controller in this routes | [
"Set",
"base",
"view",
"path",
"for",
"controller",
"in",
"this",
"routes"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/config/Routes.java#L118-L133 |
31,118 | jfinal/jfinal | src/main/java/com/jfinal/aop/InvocationWrapper.java | InvocationWrapper.invoke | @Override
public final void invoke() {
if (index < inters.length)
inters[index++].intercept(this);
else if (index++ == inters.length)
invocation.invoke();
} | java | @Override
public final void invoke() {
if (index < inters.length)
inters[index++].intercept(this);
else if (index++ == inters.length)
invocation.invoke();
} | [
"@",
"Override",
"public",
"final",
"void",
"invoke",
"(",
")",
"{",
"if",
"(",
"index",
"<",
"inters",
".",
"length",
")",
"inters",
"[",
"index",
"++",
"]",
".",
"intercept",
"(",
"this",
")",
";",
"else",
"if",
"(",
"index",
"++",
"==",
"inters"... | Invoke the action | [
"Invoke",
"the",
"action"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/aop/InvocationWrapper.java#L39-L45 |
31,119 | jfinal/jfinal | src/main/java/com/jfinal/template/EngineConfig.java | EngineConfig.addSharedFunction | 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 | 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);
} | [
"public",
"void",
"addSharedFunction",
"(",
"String",
"fileName",
")",
"{",
"fileName",
"=",
"fileName",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
")",
";",
"// FileSource fileSource = new FileSource(baseTemplatePath, fileName, encoding);\r",
"ISource",
"source",
"="... | Add shared function with file | [
"Add",
"shared",
"function",
"with",
"file"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/EngineConfig.java#L85-L90 |
31,120 | jfinal/jfinal | src/main/java/com/jfinal/template/EngineConfig.java | EngineConfig.addSharedFunctionByString | public void addSharedFunctionByString(String content) {
// content 中的内容被解析后会存放在 Env 之中,而 StringSource 所对应的
// Template 对象 isModified() 始终返回 false,所以没有必要对其缓存
StringSource stringSource = new StringSource(content, false);
doAddSharedFunction(stringSource, null);
} | java | public void addSharedFunctionByString(String content) {
// content 中的内容被解析后会存放在 Env 之中,而 StringSource 所对应的
// Template 对象 isModified() 始终返回 false,所以没有必要对其缓存
StringSource stringSource = new StringSource(content, false);
doAddSharedFunction(stringSource, null);
} | [
"public",
"void",
"addSharedFunctionByString",
"(",
"String",
"content",
")",
"{",
"// content 中的内容被解析后会存放在 Env 之中,而 StringSource 所对应的\r",
"// Template 对象 isModified() 始终返回 false,所以没有必要对其缓存\r",
"StringSource",
"stringSource",
"=",
"new",
"StringSource",
"(",
"content",
",",
"fals... | Add shared function by string content | [
"Add",
"shared",
"function",
"by",
"string",
"content"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/EngineConfig.java#L114-L119 |
31,121 | jfinal/jfinal | src/main/java/com/jfinal/template/EngineConfig.java | EngineConfig.addSharedFunction | public void addSharedFunction(ISource source) {
String fileName = source instanceof FileSource ? ((FileSource)source).getFileName() : null;
doAddSharedFunction(source, fileName);
} | java | public void addSharedFunction(ISource source) {
String fileName = source instanceof FileSource ? ((FileSource)source).getFileName() : null;
doAddSharedFunction(source, fileName);
} | [
"public",
"void",
"addSharedFunction",
"(",
"ISource",
"source",
")",
"{",
"String",
"fileName",
"=",
"source",
"instanceof",
"FileSource",
"?",
"(",
"(",
"FileSource",
")",
"source",
")",
".",
"getFileName",
"(",
")",
":",
"null",
";",
"doAddSharedFunction",
... | Add shared function by ISource | [
"Add",
"shared",
"function",
"by",
"ISource"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/EngineConfig.java#L124-L127 |
31,122 | jfinal/jfinal | src/main/java/com/jfinal/template/EngineConfig.java | EngineConfig.getSharedFunction | Define getSharedFunction(String functionName) {
Define func = sharedFunctionMap.get(functionName);
if (func == null) {
/**
* 如果 func 最初未定义,但后续在共享模板文件中又被添加进来
* 此时在本 if 分支中无法被感知,仍然返回了 null
*
* 但共享模板文件会在后续其它的 func 调用时被感知修改并 reload
* 所以本 if 分支不考虑处理模板文件中追加 #define 的情况
*
* 如果要处理,只能是每次在 func 为 null 时,判断 sharedFunctionSourceList
* 中的模板是否被修改过,再重新加载,不优雅
*/
return null;
}
if (devMode && reloadModifiedSharedFunctionInDevMode) {
if (func.isSourceModifiedForDevMode()) {
synchronized (this) {
func = sharedFunctionMap.get(functionName);
if (func.isSourceModifiedForDevMode()) {
reloadSharedFunctionSourceList();
func = sharedFunctionMap.get(functionName);
}
}
}
}
return func;
} | java | Define getSharedFunction(String functionName) {
Define func = sharedFunctionMap.get(functionName);
if (func == null) {
/**
* 如果 func 最初未定义,但后续在共享模板文件中又被添加进来
* 此时在本 if 分支中无法被感知,仍然返回了 null
*
* 但共享模板文件会在后续其它的 func 调用时被感知修改并 reload
* 所以本 if 分支不考虑处理模板文件中追加 #define 的情况
*
* 如果要处理,只能是每次在 func 为 null 时,判断 sharedFunctionSourceList
* 中的模板是否被修改过,再重新加载,不优雅
*/
return null;
}
if (devMode && reloadModifiedSharedFunctionInDevMode) {
if (func.isSourceModifiedForDevMode()) {
synchronized (this) {
func = sharedFunctionMap.get(functionName);
if (func.isSourceModifiedForDevMode()) {
reloadSharedFunctionSourceList();
func = sharedFunctionMap.get(functionName);
}
}
}
}
return func;
} | [
"Define",
"getSharedFunction",
"(",
"String",
"functionName",
")",
"{",
"Define",
"func",
"=",
"sharedFunctionMap",
".",
"get",
"(",
"functionName",
")",
";",
"if",
"(",
"func",
"==",
"null",
")",
"{",
"/**\r\n\t\t\t * 如果 func 最初未定义,但后续在共享模板文件中又被添加进来\r\n\t\t\t * 此时在本 ... | Get shared function by Env | [
"Get",
"shared",
"function",
"by",
"Env"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/EngineConfig.java#L146-L174 |
31,123 | jfinal/jfinal | src/main/java/com/jfinal/template/EngineConfig.java | EngineConfig.reloadSharedFunctionSourceList | 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)source).getFileName() : null;
Env env = new Env(this);
new Parser(env, source.getContent(), fileName).parse();
addToSharedFunctionMap(newMap, env);
if (devMode) {
env.addSource(source);
}
}
this.sharedFunctionMap = newMap;
} | java | 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)source).getFileName() : null;
Env env = new Env(this);
new Parser(env, source.getContent(), fileName).parse();
addToSharedFunctionMap(newMap, env);
if (devMode) {
env.addSource(source);
}
}
this.sharedFunctionMap = newMap;
} | [
"private",
"synchronized",
"void",
"reloadSharedFunctionSourceList",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Define",
">",
"newMap",
"=",
"createSharedFunctionMap",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"size",
"=",
"sharedFunctionSourceList... | Reload shared function source list
devMode 要照顾到 sharedFunctionFiles,所以暂不提供
removeSharedFunction(String functionName) 功能
开发者可直接使用模板注释功能将不需要的 function 直接注释掉 | [
"Reload",
"shared",
"function",
"source",
"list"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/EngineConfig.java#L183-L197 |
31,124 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Config.java | Config.getConnection | public Connection getConnection() throws SQLException {
Connection conn = threadLocal.get();
if (conn != null)
return conn;
return showSql ? new SqlReporter(dataSource.getConnection()).getConnection() : dataSource.getConnection();
} | java | public Connection getConnection() throws SQLException {
Connection conn = threadLocal.get();
if (conn != null)
return conn;
return showSql ? new SqlReporter(dataSource.getConnection()).getConnection() : dataSource.getConnection();
} | [
"public",
"Connection",
"getConnection",
"(",
")",
"throws",
"SQLException",
"{",
"Connection",
"conn",
"=",
"threadLocal",
".",
"get",
"(",
")",
";",
"if",
"(",
"conn",
"!=",
"null",
")",
"return",
"conn",
";",
"return",
"showSql",
"?",
"new",
"SqlReporte... | Get Connection. Support transaction if Connection in ThreadLocal | [
"Get",
"Connection",
".",
"Support",
"transaction",
"if",
"Connection",
"in",
"ThreadLocal"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Config.java#L199-L204 |
31,125 | jfinal/jfinal | src/main/java/com/jfinal/config/Interceptors.java | Interceptors.add | public Interceptors add(Interceptor globalActionInterceptor) {
if (globalActionInterceptor == null) {
throw new IllegalArgumentException("globalActionInterceptor can not be null.");
}
InterceptorManager.me().addGlobalActionInterceptor(globalActionInterceptor);
return this;
} | java | public Interceptors add(Interceptor globalActionInterceptor) {
if (globalActionInterceptor == null) {
throw new IllegalArgumentException("globalActionInterceptor can not be null.");
}
InterceptorManager.me().addGlobalActionInterceptor(globalActionInterceptor);
return this;
} | [
"public",
"Interceptors",
"add",
"(",
"Interceptor",
"globalActionInterceptor",
")",
"{",
"if",
"(",
"globalActionInterceptor",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"globalActionInterceptor can not be null.\"",
")",
";",
"}",
"Inter... | The same as addGlobalActionInterceptor. It is used to compatible with earlier version of jfinal | [
"The",
"same",
"as",
"addGlobalActionInterceptor",
".",
"It",
"is",
"used",
"to",
"compatible",
"with",
"earlier",
"version",
"of",
"jfinal"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/config/Interceptors.java#L30-L36 |
31,126 | jfinal/jfinal | src/main/java/com/jfinal/config/Interceptors.java | Interceptors.addGlobalServiceInterceptor | public Interceptors addGlobalServiceInterceptor(Interceptor globalServiceInterceptor) {
if (globalServiceInterceptor == null) {
throw new IllegalArgumentException("globalServiceInterceptor can not be null.");
}
InterceptorManager.me().addGlobalServiceInterceptor(globalServiceInterceptor);
return this;
} | java | public Interceptors addGlobalServiceInterceptor(Interceptor globalServiceInterceptor) {
if (globalServiceInterceptor == null) {
throw new IllegalArgumentException("globalServiceInterceptor can not be null.");
}
InterceptorManager.me().addGlobalServiceInterceptor(globalServiceInterceptor);
return this;
} | [
"public",
"Interceptors",
"addGlobalServiceInterceptor",
"(",
"Interceptor",
"globalServiceInterceptor",
")",
"{",
"if",
"(",
"globalServiceInterceptor",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"globalServiceInterceptor can not be null.\"",
... | Add the global service interceptor to intercept all the method enhanced by aop Enhancer. | [
"Add",
"the",
"global",
"service",
"interceptor",
"to",
"intercept",
"all",
"the",
"method",
"enhanced",
"by",
"aop",
"Enhancer",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/config/Interceptors.java#L52-L58 |
31,127 | jfinal/jfinal | src/main/java/com/jfinal/token/TokenManager.java | TokenManager.createToken | 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, tokenName, tokenId);
}
else {
createTokenUseTokenIdGenerator(controller, tokenName, secondsOfTimeOut);
}
} | java | 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, tokenName, tokenId);
}
else {
createTokenUseTokenIdGenerator(controller, tokenName, secondsOfTimeOut);
}
} | [
"public",
"static",
"void",
"createToken",
"(",
"Controller",
"controller",
",",
"String",
"tokenName",
",",
"int",
"secondsOfTimeOut",
")",
"{",
"if",
"(",
"tokenCache",
"==",
"null",
")",
"{",
"String",
"tokenId",
"=",
"String",
".",
"valueOf",
"(",
"rando... | Create Token.
@param Controller
@param tokenName token name
@param secondsOfTimeOut seconds of time out, for ITokenCache only. | [
"Create",
"Token",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/token/TokenManager.java#L59-L69 |
31,128 | jfinal/jfinal | src/main/java/com/jfinal/token/TokenManager.java | TokenManager.validateToken | 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(clientTokenId) && clientTokenId.equals(serverTokenId);
}
else {
Token token = new Token(clientTokenId);
boolean result = tokenCache.contains(token);
tokenCache.remove(token);
return result;
}
} | java | 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(clientTokenId) && clientTokenId.equals(serverTokenId);
}
else {
Token token = new Token(clientTokenId);
boolean result = tokenCache.contains(token);
tokenCache.remove(token);
return result;
}
} | [
"public",
"static",
"boolean",
"validateToken",
"(",
"Controller",
"controller",
",",
"String",
"tokenName",
")",
"{",
"String",
"clientTokenId",
"=",
"controller",
".",
"getPara",
"(",
"tokenName",
")",
";",
"if",
"(",
"tokenCache",
"==",
"null",
")",
"{",
... | Check token to prevent resubmit.
@param tokenName the token name used in view's form
@return true if token is correct | [
"Check",
"token",
"to",
"prevent",
"resubmit",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/token/TokenManager.java#L106-L119 |
31,129 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Record.java | Record.getColumns | @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 | @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;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"getColumns",
"(",
")",
"{",
"if",
"(",
"columns",
"==",
"null",
")",
"{",
"if",
"(",
"DbKit",
".",
"config",
"==",
"null",
")",
"columns",
"=",
"... | Return columns map. | [
"Return",
"columns",
"map",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Record.java#L67-L76 |
31,130 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Record.java | Record.remove | public Record remove(String... columns) {
if (columns != null)
for (String c : columns)
this.getColumns().remove(c);
return this;
} | java | public Record remove(String... columns) {
if (columns != null)
for (String c : columns)
this.getColumns().remove(c);
return this;
} | [
"public",
"Record",
"remove",
"(",
"String",
"...",
"columns",
")",
"{",
"if",
"(",
"columns",
"!=",
"null",
")",
"for",
"(",
"String",
"c",
":",
"columns",
")",
"this",
".",
"getColumns",
"(",
")",
".",
"remove",
"(",
")",
";",
"return",
"this",
"... | Remove columns of this record.
@param columns the column names of the record | [
"Remove",
"columns",
"of",
"this",
"record",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Record.java#L118-L123 |
31,131 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Record.java | Record.removeNullValueColumns | 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 | 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;
} | [
"public",
"Record",
"removeNullValueColumns",
"(",
")",
"{",
"for",
"(",
"java",
".",
"util",
".",
"Iterator",
"<",
"Entry",
"<",
"String",
",",
"Object",
">",
">",
"it",
"=",
"getColumns",
"(",
")",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
"... | Remove columns if it is null. | [
"Remove",
"columns",
"if",
"it",
"is",
"null",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Record.java#L128-L136 |
31,132 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Record.java | Record.keep | 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 the newColumns
newColumns.put(c, this.getColumns().get(c));
this.getColumns().clear();
this.getColumns().putAll(newColumns);
}
else
this.getColumns().clear();
return this;
} | java | 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 the newColumns
newColumns.put(c, this.getColumns().get(c));
this.getColumns().clear();
this.getColumns().putAll(newColumns);
}
else
this.getColumns().clear();
return this;
} | [
"public",
"Record",
"keep",
"(",
"String",
"...",
"columns",
")",
"{",
"if",
"(",
"columns",
"!=",
"null",
"&&",
"columns",
".",
"length",
">",
"0",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"newColumns",
"=",
"new",
"HashMap",
"<",
"String... | Keep columns of this record and remove other columns.
@param columns the column names of the record | [
"Keep",
"columns",
"of",
"this",
"record",
"and",
"remove",
"other",
"columns",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Record.java#L142-L155 |
31,133 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Record.java | Record.keep | 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 | 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;
} | [
"public",
"Record",
"keep",
"(",
"String",
"column",
")",
"{",
"if",
"(",
"getColumns",
"(",
")",
".",
"containsKey",
"(",
"column",
")",
")",
"{",
"// prevent put null value to the newColumns\r",
"Object",
"keepIt",
"=",
"getColumns",
"(",
")",
".",
"get",
... | Keep column of this record and remove other columns.
@param column the column names of the record | [
"Keep",
"column",
"of",
"this",
"record",
"and",
"remove",
"other",
"columns",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Record.java#L161-L170 |
31,134 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Record.java | Record.set | public Record set(String column, Object value) {
getColumns().put(column, value);
return this;
} | java | public Record set(String column, Object value) {
getColumns().put(column, value);
return this;
} | [
"public",
"Record",
"set",
"(",
"String",
"column",
",",
"Object",
"value",
")",
"{",
"getColumns",
"(",
")",
".",
"put",
"(",
"column",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Set column to record.
@param column the column name
@param value the value of the column | [
"Set",
"column",
"to",
"record",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Record.java#L185-L188 |
31,135 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Record.java | Record.get | @SuppressWarnings("unchecked")
public <T> T get(String column) {
return (T)getColumns().get(column);
} | java | @SuppressWarnings("unchecked")
public <T> T get(String column) {
return (T)getColumns().get(column);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"get",
"(",
"String",
"column",
")",
"{",
"return",
"(",
"T",
")",
"getColumns",
"(",
")",
".",
"get",
"(",
"column",
")",
";",
"}"
] | Get column of any mysql type | [
"Get",
"column",
"of",
"any",
"mysql",
"type"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Record.java#L193-L196 |
31,136 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Record.java | Record.get | @SuppressWarnings("unchecked")
public <T> T get(String column, Object defaultValue) {
Object result = getColumns().get(column);
return (T)(result != null ? result : defaultValue);
} | java | @SuppressWarnings("unchecked")
public <T> T get(String column, Object defaultValue) {
Object result = getColumns().get(column);
return (T)(result != null ? result : defaultValue);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"get",
"(",
"String",
"column",
",",
"Object",
"defaultValue",
")",
"{",
"Object",
"result",
"=",
"getColumns",
"(",
")",
".",
"get",
"(",
"column",
")",
";",
"return",
"... | Get column of any mysql type. Returns defaultValue if null. | [
"Get",
"column",
"of",
"any",
"mysql",
"type",
".",
"Returns",
"defaultValue",
"if",
"null",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Record.java#L201-L205 |
31,137 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Record.java | Record.getColumnNames | public String[] getColumnNames() {
Set<String> attrNameSet = getColumns().keySet();
return attrNameSet.toArray(new String[attrNameSet.size()]);
} | java | public String[] getColumnNames() {
Set<String> attrNameSet = getColumns().keySet();
return attrNameSet.toArray(new String[attrNameSet.size()]);
} | [
"public",
"String",
"[",
"]",
"getColumnNames",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"attrNameSet",
"=",
"getColumns",
"(",
")",
".",
"keySet",
"(",
")",
";",
"return",
"attrNameSet",
".",
"toArray",
"(",
"new",
"String",
"[",
"attrNameSet",
".",
... | Return column names of this record. | [
"Return",
"column",
"names",
"of",
"this",
"record",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Record.java#L362-L365 |
31,138 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Record.java | Record.getColumnValues | public Object[] getColumnValues() {
java.util.Collection<Object> attrValueCollection = getColumns().values();
return attrValueCollection.toArray(new Object[attrValueCollection.size()]);
} | java | public Object[] getColumnValues() {
java.util.Collection<Object> attrValueCollection = getColumns().values();
return attrValueCollection.toArray(new Object[attrValueCollection.size()]);
} | [
"public",
"Object",
"[",
"]",
"getColumnValues",
"(",
")",
"{",
"java",
".",
"util",
".",
"Collection",
"<",
"Object",
">",
"attrValueCollection",
"=",
"getColumns",
"(",
")",
".",
"values",
"(",
")",
";",
"return",
"attrValueCollection",
".",
"toArray",
"... | Return column values of this record. | [
"Return",
"column",
"values",
"of",
"this",
"record",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Record.java#L370-L373 |
31,139 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.setAttr | public Controller setAttr(String name, Object value) {
request.setAttribute(name, value);
return this;
} | java | public Controller setAttr(String name, Object value) {
request.setAttribute(name, value);
return this;
} | [
"public",
"Controller",
"setAttr",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"request",
".",
"setAttribute",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Stores an attribute in this request
@param name a String specifying the name of the attribute
@param value the Object to be stored | [
"Stores",
"an",
"attribute",
"in",
"this",
"request"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L132-L135 |
31,140 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.setAttrs | public Controller setAttrs(Map<String, Object> attrMap) {
for (Map.Entry<String, Object> entry : attrMap.entrySet())
request.setAttribute(entry.getKey(), entry.getValue());
return this;
} | java | public Controller setAttrs(Map<String, Object> attrMap) {
for (Map.Entry<String, Object> entry : attrMap.entrySet())
request.setAttribute(entry.getKey(), entry.getValue());
return this;
} | [
"public",
"Controller",
"setAttrs",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"attrMap",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"attrMap",
".",
"entrySet",
"(",
")",
")",
"request",
".",
"setA... | Stores attributes in this request, key of the map as attribute name and value of the map as attribute value
@param attrMap key and value as attribute of the map to be stored | [
"Stores",
"attributes",
"in",
"this",
"request",
"key",
"of",
"the",
"map",
"as",
"attribute",
"name",
"and",
"value",
"of",
"the",
"map",
"as",
"attribute",
"value"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L150-L154 |
31,141 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getPara | public String getPara(String name, String defaultValue) {
String result = request.getParameter(name);
return result != null && !"".equals(result) ? result : defaultValue;
} | java | public String getPara(String name, String defaultValue) {
String result = request.getParameter(name);
return result != null && !"".equals(result) ? result : defaultValue;
} | [
"public",
"String",
"getPara",
"(",
"String",
"name",
",",
"String",
"defaultValue",
")",
"{",
"String",
"result",
"=",
"request",
".",
"getParameter",
"(",
"name",
")",
";",
"return",
"result",
"!=",
"null",
"&&",
"!",
"\"\"",
".",
"equals",
"(",
"resul... | Returns the value of a request parameter as a String, or default value if the parameter does not exist.
@param name a String specifying the name of the parameter
@param defaultValue a String value be returned when the value of parameter is null
@return a String representing the single value of the parameter | [
"Returns",
"the",
"value",
"of",
"a",
"request",
"parameter",
"as",
"a",
"String",
"or",
"default",
"value",
"if",
"the",
"parameter",
"does",
"not",
"exist",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L177-L180 |
31,142 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getParaValuesToInt | 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 : Integer.parseInt(values[i]);
}
return result;
} | java | 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 : Integer.parseInt(values[i]);
}
return result;
} | [
"public",
"Integer",
"[",
"]",
"getParaValuesToInt",
"(",
"String",
"name",
")",
"{",
"String",
"[",
"]",
"values",
"=",
"request",
".",
"getParameterValues",
"(",
"name",
")",
";",
"if",
"(",
"values",
"==",
"null",
"||",
"values",
".",
"length",
"==",
... | Returns an array of Integer objects containing all of the values the given request
parameter has, or null if the parameter does not exist. If the parameter has a
single value, the array has a length of 1.
@param name a String containing the name of the parameter whose value is requested
@return an array of Integer objects containing the parameter's values | [
"Returns",
"an",
"array",
"of",
"Integer",
"objects",
"containing",
"all",
"of",
"the",
"values",
"the",
"given",
"request",
"parameter",
"has",
"or",
"null",
"if",
"the",
"parameter",
"does",
"not",
"exist",
".",
"If",
"the",
"parameter",
"has",
"a",
"sin... | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L219-L229 |
31,143 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getParaToInt | public Integer getParaToInt(String name, Integer defaultValue) {
return toInt(request.getParameter(name), defaultValue);
} | java | public Integer getParaToInt(String name, Integer defaultValue) {
return toInt(request.getParameter(name), defaultValue);
} | [
"public",
"Integer",
"getParaToInt",
"(",
"String",
"name",
",",
"Integer",
"defaultValue",
")",
"{",
"return",
"toInt",
"(",
"request",
".",
"getParameter",
"(",
"name",
")",
",",
"defaultValue",
")",
";",
"}"
] | Returns the value of a request parameter and convert to Integer with a default value if it is null.
@param name a String specifying the name of the parameter
@return a Integer representing the single value of the parameter | [
"Returns",
"the",
"value",
"of",
"a",
"request",
"parameter",
"and",
"convert",
"to",
"Integer",
"with",
"a",
"default",
"value",
"if",
"it",
"is",
"null",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L319-L321 |
31,144 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getParaToLong | public Long getParaToLong(String name, Long defaultValue) {
return toLong(request.getParameter(name), defaultValue);
} | java | public Long getParaToLong(String name, Long defaultValue) {
return toLong(request.getParameter(name), defaultValue);
} | [
"public",
"Long",
"getParaToLong",
"(",
"String",
"name",
",",
"Long",
"defaultValue",
")",
"{",
"return",
"toLong",
"(",
"request",
".",
"getParameter",
"(",
"name",
")",
",",
"defaultValue",
")",
";",
"}"
] | Returns the value of a request parameter and convert to Long with a default value if it is null.
@param name a String specifying the name of the parameter
@return a Integer representing the single value of the parameter | [
"Returns",
"the",
"value",
"of",
"a",
"request",
"parameter",
"and",
"convert",
"to",
"Long",
"with",
"a",
"default",
"value",
"if",
"it",
"is",
"null",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L351-L353 |
31,145 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getParaToBoolean | public Boolean getParaToBoolean(String name, Boolean defaultValue) {
return toBoolean(request.getParameter(name), defaultValue);
} | java | public Boolean getParaToBoolean(String name, Boolean defaultValue) {
return toBoolean(request.getParameter(name), defaultValue);
} | [
"public",
"Boolean",
"getParaToBoolean",
"(",
"String",
"name",
",",
"Boolean",
"defaultValue",
")",
"{",
"return",
"toBoolean",
"(",
"request",
".",
"getParameter",
"(",
"name",
")",
",",
"defaultValue",
")",
";",
"}"
] | Returns the value of a request parameter and convert to Boolean with a default value if it is null.
@param name a String specifying the name of the parameter
@return true if the value of the parameter is "true" or "1", false if it is "false" or "0", default value if it is null | [
"Returns",
"the",
"value",
"of",
"a",
"request",
"parameter",
"and",
"convert",
"to",
"Boolean",
"with",
"a",
"default",
"value",
"if",
"it",
"is",
"null",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L380-L382 |
31,146 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getParaToDate | public Date getParaToDate(String name, Date defaultValue) {
return toDate(request.getParameter(name), defaultValue);
} | java | public Date getParaToDate(String name, Date defaultValue) {
return toDate(request.getParameter(name), defaultValue);
} | [
"public",
"Date",
"getParaToDate",
"(",
"String",
"name",
",",
"Date",
"defaultValue",
")",
"{",
"return",
"toDate",
"(",
"request",
".",
"getParameter",
"(",
"name",
")",
",",
"defaultValue",
")",
";",
"}"
] | Returns the value of a request parameter and convert to Date with a default value if it is null.
@param name a String specifying the name of the parameter
@return a Date representing the single value of the parameter | [
"Returns",
"the",
"value",
"of",
"a",
"request",
"parameter",
"and",
"convert",
"to",
"Date",
"with",
"a",
"default",
"value",
"if",
"it",
"is",
"null",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L429-L431 |
31,147 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getSessionAttr | public <T> T getSessionAttr(String key) {
HttpSession session = request.getSession(false);
return session != null ? (T)session.getAttribute(key) : null;
} | java | public <T> T getSessionAttr(String key) {
HttpSession session = request.getSession(false);
return session != null ? (T)session.getAttribute(key) : null;
} | [
"public",
"<",
"T",
">",
"T",
"getSessionAttr",
"(",
"String",
"key",
")",
"{",
"HttpSession",
"session",
"=",
"request",
".",
"getSession",
"(",
"false",
")",
";",
"return",
"session",
"!=",
"null",
"?",
"(",
"T",
")",
"session",
".",
"getAttribute",
... | Return a Object from session.
@param key a String specifying the key of the Object stored in session | [
"Return",
"a",
"Object",
"from",
"session",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L473-L476 |
31,148 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.removeSessionAttr | public Controller removeSessionAttr(String key) {
HttpSession session = request.getSession(false);
if (session != null)
session.removeAttribute(key);
return this;
} | java | public Controller removeSessionAttr(String key) {
HttpSession session = request.getSession(false);
if (session != null)
session.removeAttribute(key);
return this;
} | [
"public",
"Controller",
"removeSessionAttr",
"(",
"String",
"key",
")",
"{",
"HttpSession",
"session",
"=",
"request",
".",
"getSession",
"(",
"false",
")",
";",
"if",
"(",
"session",
"!=",
"null",
")",
"session",
".",
"removeAttribute",
"(",
"key",
")",
"... | Remove Object in session.
@param key a String specifying the key of the Object stored in session | [
"Remove",
"Object",
"in",
"session",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L497-L502 |
31,149 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getCookie | public String getCookie(String name, String defaultValue) {
Cookie cookie = getCookieObject(name);
return cookie != null ? cookie.getValue() : defaultValue;
} | java | public String getCookie(String name, String defaultValue) {
Cookie cookie = getCookieObject(name);
return cookie != null ? cookie.getValue() : defaultValue;
} | [
"public",
"String",
"getCookie",
"(",
"String",
"name",
",",
"String",
"defaultValue",
")",
"{",
"Cookie",
"cookie",
"=",
"getCookieObject",
"(",
"name",
")",
";",
"return",
"cookie",
"!=",
"null",
"?",
"cookie",
".",
"getValue",
"(",
")",
":",
"defaultVal... | Get cookie value by cookie name. | [
"Get",
"cookie",
"value",
"by",
"cookie",
"name",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L507-L510 |
31,150 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getCookieToInt | public Integer getCookieToInt(String name, Integer defaultValue) {
String result = getCookie(name);
return result != null ? Integer.parseInt(result) : defaultValue;
} | java | public Integer getCookieToInt(String name, Integer defaultValue) {
String result = getCookie(name);
return result != null ? Integer.parseInt(result) : defaultValue;
} | [
"public",
"Integer",
"getCookieToInt",
"(",
"String",
"name",
",",
"Integer",
"defaultValue",
")",
"{",
"String",
"result",
"=",
"getCookie",
"(",
"name",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"Integer",
".",
"parseInt",
"(",
"result",
")",
":",... | Get cookie value by cookie name and convert to Integer. | [
"Get",
"cookie",
"value",
"by",
"cookie",
"name",
"and",
"convert",
"to",
"Integer",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L530-L533 |
31,151 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getCookieToLong | public Long getCookieToLong(String name) {
String result = getCookie(name);
return result != null ? Long.parseLong(result) : null;
} | java | public Long getCookieToLong(String name) {
String result = getCookie(name);
return result != null ? Long.parseLong(result) : null;
} | [
"public",
"Long",
"getCookieToLong",
"(",
"String",
"name",
")",
"{",
"String",
"result",
"=",
"getCookie",
"(",
"name",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"Long",
".",
"parseLong",
"(",
"result",
")",
":",
"null",
";",
"}"
] | Get cookie value by cookie name and convert to Long. | [
"Get",
"cookie",
"value",
"by",
"cookie",
"name",
"and",
"convert",
"to",
"Long",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L538-L541 |
31,152 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getCookieObject | 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 | 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;
} | [
"public",
"Cookie",
"getCookieObject",
"(",
"String",
"name",
")",
"{",
"Cookie",
"[",
"]",
"cookies",
"=",
"request",
".",
"getCookies",
"(",
")",
";",
"if",
"(",
"cookies",
"!=",
"null",
")",
"for",
"(",
"Cookie",
"cookie",
":",
"cookies",
")",
"if",... | Get cookie object by cookie name. | [
"Get",
"cookie",
"object",
"by",
"cookie",
"name",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L554-L561 |
31,153 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getCookieObjects | public Cookie[] getCookieObjects() {
Cookie[] result = request.getCookies();
return result != null ? result : new Cookie[0];
} | java | public Cookie[] getCookieObjects() {
Cookie[] result = request.getCookies();
return result != null ? result : new Cookie[0];
} | [
"public",
"Cookie",
"[",
"]",
"getCookieObjects",
"(",
")",
"{",
"Cookie",
"[",
"]",
"result",
"=",
"request",
".",
"getCookies",
"(",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"result",
":",
"new",
"Cookie",
"[",
"0",
"]",
";",
"}"
] | Get all cookie objects. | [
"Get",
"all",
"cookie",
"objects",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L566-L569 |
31,154 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.setCookie | public Controller setCookie(String name, String value, int maxAgeInSeconds, String path, boolean isHttpOnly) {
return doSetCookie(name, value, maxAgeInSeconds, path, null, isHttpOnly);
} | java | public Controller setCookie(String name, String value, int maxAgeInSeconds, String path, boolean isHttpOnly) {
return doSetCookie(name, value, maxAgeInSeconds, path, null, isHttpOnly);
} | [
"public",
"Controller",
"setCookie",
"(",
"String",
"name",
",",
"String",
"value",
",",
"int",
"maxAgeInSeconds",
",",
"String",
"path",
",",
"boolean",
"isHttpOnly",
")",
"{",
"return",
"doSetCookie",
"(",
"name",
",",
"value",
",",
"maxAgeInSeconds",
",",
... | Set Cookie to response.
@param name cookie name
@param value cookie value
@param maxAgeInSeconds -1: clear cookie when close browser. 0: clear cookie immediately. n>0 : max age in n seconds.
@param path see Cookie.setPath(String)
@param isHttpOnly true if this cookie is to be marked as HttpOnly, false otherwise | [
"Set",
"Cookie",
"to",
"response",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L608-L610 |
31,155 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getPara | 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);
for (int i=0; i<urlParaArray.length; i++)
if ("".equals(urlParaArray[i]))
urlParaArray[i] = null;
}
return urlParaArray.length > index ? urlParaArray[index] : null;
} | java | 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);
for (int i=0; i<urlParaArray.length; i++)
if ("".equals(urlParaArray[i]))
urlParaArray[i] = null;
}
return urlParaArray.length > index ? urlParaArray[index] : null;
} | [
"public",
"String",
"getPara",
"(",
"int",
"index",
")",
"{",
"if",
"(",
"index",
"<",
"0",
")",
"return",
"getPara",
"(",
")",
";",
"if",
"(",
"urlParaArray",
"==",
"null",
")",
"{",
"if",
"(",
"urlPara",
"==",
"null",
"||",
"\"\"",
".",
"equals",... | Get para from url. The index of first url para is 0. | [
"Get",
"para",
"from",
"url",
".",
"The",
"index",
"of",
"first",
"url",
"para",
"is",
"0",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L690-L705 |
31,156 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getPara | public String getPara(int index, String defaultValue) {
String result = getPara(index);
return result != null && !"".equals(result) ? result : defaultValue;
} | java | public String getPara(int index, String defaultValue) {
String result = getPara(index);
return result != null && !"".equals(result) ? result : defaultValue;
} | [
"public",
"String",
"getPara",
"(",
"int",
"index",
",",
"String",
"defaultValue",
")",
"{",
"String",
"result",
"=",
"getPara",
"(",
"index",
")",
";",
"return",
"result",
"!=",
"null",
"&&",
"!",
"\"\"",
".",
"equals",
"(",
"result",
")",
"?",
"resul... | Get para from url with default value if it is null or "". | [
"Get",
"para",
"from",
"url",
"with",
"default",
"value",
"if",
"it",
"is",
"null",
"or",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L710-L713 |
31,157 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getModel | public <T> T getModel(Class<T> modelClass) {
return (T)Injector.injectModel(modelClass, request, false);
} | java | public <T> T getModel(Class<T> modelClass) {
return (T)Injector.injectModel(modelClass, request, false);
} | [
"public",
"<",
"T",
">",
"T",
"getModel",
"(",
"Class",
"<",
"T",
">",
"modelClass",
")",
"{",
"return",
"(",
"T",
")",
"Injector",
".",
"injectModel",
"(",
"modelClass",
",",
"request",
",",
"false",
")",
";",
"}"
] | Get model from http request. | [
"Get",
"model",
"from",
"http",
"request",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L760-L762 |
31,158 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.getFiles | 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 | 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();
} | [
"public",
"List",
"<",
"UploadFile",
">",
"getFiles",
"(",
"String",
"uploadPath",
",",
"Integer",
"maxPostSize",
",",
"String",
"encoding",
")",
"{",
"if",
"(",
"request",
"instanceof",
"MultipartRequest",
"==",
"false",
")",
"request",
"=",
"new",
"Multipart... | Get upload file from multipart request. | [
"Get",
"upload",
"file",
"from",
"multipart",
"request",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L820-L824 |
31,159 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.keepPara | 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);
}
return this;
} | java | 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);
}
return this;
} | [
"public",
"Controller",
"keepPara",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"map",
"=",
"request",
".",
"getParameterMap",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
"[",
"]",
">",
"e",
":",
"map",
... | Keep all parameter's value except model value | [
"Keep",
"all",
"parameter",
"s",
"value",
"except",
"model",
"value"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L877-L887 |
31,160 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.keepPara | 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 | 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;
} | [
"public",
"Controller",
"keepPara",
"(",
"String",
"...",
"names",
")",
"{",
"for",
"(",
"String",
"name",
":",
"names",
")",
"{",
"String",
"[",
"]",
"values",
"=",
"request",
".",
"getParameterValues",
"(",
"name",
")",
";",
"if",
"(",
"values",
"!="... | Keep parameter's value names pointed, model value can not be kept | [
"Keep",
"parameter",
"s",
"value",
"names",
"pointed",
"model",
"value",
"can",
"not",
"be",
"kept"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L892-L903 |
31,161 | jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.keepPara | 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
request.setAttribute(name, values);
}
return this;
} | java | 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
request.setAttribute(name, values);
}
return this;
} | [
"public",
"Controller",
"keepPara",
"(",
"Class",
"type",
",",
"String",
"name",
")",
"{",
"String",
"[",
"]",
"values",
"=",
"request",
".",
"getParameterValues",
"(",
"name",
")",
";",
"if",
"(",
"values",
"!=",
"null",
")",
"{",
"if",
"(",
"values",... | Convert para to special type and keep it | [
"Convert",
"para",
"to",
"special",
"type",
"and",
"keep",
"it"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L908-L917 |
31,162 | jfinal/jfinal | src/main/java/com/jfinal/template/Env.java | Env.addFunction | 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()),
function.getLocation()
);
}
functionMap.put(fn, function);
} | java | 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()),
function.getLocation()
);
}
functionMap.put(fn, function);
} | [
"public",
"void",
"addFunction",
"(",
"Define",
"function",
")",
"{",
"String",
"fn",
"=",
"function",
".",
"getFunctionName",
"(",
")",
";",
"if",
"(",
"functionMap",
".",
"containsKey",
"(",
"fn",
")",
")",
"{",
"Define",
"previous",
"=",
"functionMap",
... | Add template function | [
"Add",
"template",
"function"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/Env.java#L58-L69 |
31,163 | jfinal/jfinal | src/main/java/com/jfinal/template/Env.java | Env.getFunction | public Define getFunction(String functionName) {
Define func = functionMap.get(functionName);
return func != null ? func : engineConfig.getSharedFunction(functionName);
} | java | public Define getFunction(String functionName) {
Define func = functionMap.get(functionName);
return func != null ? func : engineConfig.getSharedFunction(functionName);
} | [
"public",
"Define",
"getFunction",
"(",
"String",
"functionName",
")",
"{",
"Define",
"func",
"=",
"functionMap",
".",
"get",
"(",
"functionName",
")",
";",
"return",
"func",
"!=",
"null",
"?",
"func",
":",
"engineConfig",
".",
"getSharedFunction",
"(",
"fun... | Get function of current template first, getting shared function if null before | [
"Get",
"function",
"of",
"current",
"template",
"first",
"getting",
"shared",
"function",
"if",
"null",
"before"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/Env.java#L84-L87 |
31,164 | jfinal/jfinal | src/main/java/com/jfinal/template/Engine.java | Engine.create | 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 : " + engineName);
}
Engine newEngine = new Engine(engineName);
engineMap.put(engineName, newEngine);
return newEngine;
} | java | 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 : " + engineName);
}
Engine newEngine = new Engine(engineName);
engineMap.put(engineName, newEngine);
return newEngine;
} | [
"public",
"synchronized",
"static",
"Engine",
"create",
"(",
"String",
"engineName",
")",
"{",
"if",
"(",
"StrKit",
".",
"isBlank",
"(",
"engineName",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Engine name can not be blank\"",
")",
";",
"... | Create engine with engine name managed by JFinal | [
"Create",
"engine",
"with",
"engine",
"name",
"managed",
"by",
"JFinal"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/Engine.java#L96-L107 |
31,165 | jfinal/jfinal | src/main/java/com/jfinal/template/Engine.java | Engine.remove | 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 | 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;
} | [
"public",
"synchronized",
"static",
"Engine",
"remove",
"(",
"String",
"engineName",
")",
"{",
"Engine",
"removed",
"=",
"engineMap",
".",
"remove",
"(",
"engineName",
")",
";",
"if",
"(",
"removed",
"!=",
"null",
"&&",
"MAIN_ENGINE_NAME",
".",
"equals",
"("... | Remove engine with engine name managed by JFinal | [
"Remove",
"engine",
"with",
"engine",
"name",
"managed",
"by",
"JFinal"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/Engine.java#L112-L118 |
31,166 | jfinal/jfinal | src/main/java/com/jfinal/template/Engine.java | Engine.setMainEngine | 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 | 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;
} | [
"public",
"synchronized",
"static",
"void",
"setMainEngine",
"(",
"Engine",
"engine",
")",
"{",
"if",
"(",
"engine",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Engine can not be null\"",
")",
";",
"}",
"engine",
".",
"name",
"=... | Set main engine | [
"Set",
"main",
"engine"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/Engine.java#L123-L130 |
31,167 | jfinal/jfinal | src/main/java/com/jfinal/template/Engine.java | Engine.getTemplate | 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) {
template = buildTemplateBySourceFactory(fileName);
templateCache.put(fileName, template);
} else if (devMode) {
if (template.isModified()) {
template = buildTemplateBySourceFactory(fileName);
templateCache.put(fileName, template);
}
}
return template;
} | java | 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) {
template = buildTemplateBySourceFactory(fileName);
templateCache.put(fileName, template);
} else if (devMode) {
if (template.isModified()) {
template = buildTemplateBySourceFactory(fileName);
templateCache.put(fileName, template);
}
}
return template;
} | [
"public",
"Template",
"getTemplate",
"(",
"String",
"fileName",
")",
"{",
"if",
"(",
"fileName",
".",
"charAt",
"(",
"0",
")",
"!=",
"'",
"'",
")",
"{",
"char",
"[",
"]",
"arr",
"=",
"new",
"char",
"[",
"fileName",
".",
"length",
"(",
")",
"+",
"... | Get template by file name | [
"Get",
"template",
"by",
"file",
"name"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/Engine.java#L135-L154 |
31,168 | jfinal/jfinal | src/main/java/com/jfinal/template/Engine.java | Engine.getTemplateByString | 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 = buildTemplateBySource(new StringSource(content, cache));
templateCache.put(cacheKey, template);
} else if (devMode) {
if (template.isModified()) {
template = buildTemplateBySource(new StringSource(content, cache));
templateCache.put(cacheKey, template);
}
}
return template;
} | java | 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 = buildTemplateBySource(new StringSource(content, cache));
templateCache.put(cacheKey, template);
} else if (devMode) {
if (template.isModified()) {
template = buildTemplateBySource(new StringSource(content, cache));
templateCache.put(cacheKey, template);
}
}
return template;
} | [
"public",
"Template",
"getTemplateByString",
"(",
"String",
"content",
",",
"boolean",
"cache",
")",
"{",
"if",
"(",
"!",
"cache",
")",
"{",
"return",
"buildTemplateBySource",
"(",
"new",
"StringSource",
"(",
"content",
",",
"cache",
")",
")",
";",
"}",
"S... | Get template by string content
重要:StringSource 中的 cacheKey = HashKit.md5(content),也即 cacheKey
与 content 有紧密的对应关系,当 content 发生变化时 cacheKey 值也相应变化
因此,原先 cacheKey 所对应的 Template 缓存对象已无法被获取,当 getTemplateByString(String)
的 String 参数的数量不确定时会引发内存泄漏
当 getTemplateByString(String, boolean) 中的 String 参数的
数量可控并且确定时,才可对其使用缓存
@param content 模板内容
@param cache true 则缓存 Template,否则不缓存 | [
"Get",
"template",
"by",
"string",
"content"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/Engine.java#L190-L207 |
31,169 | jfinal/jfinal | src/main/java/com/jfinal/template/Engine.java | Engine.getTemplate | 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 = buildTemplateBySource(source);
templateCache.put(cacheKey, template);
} else if (devMode) {
if (template.isModified()) {
template = buildTemplateBySource(source);
templateCache.put(cacheKey, template);
}
}
return template;
} | java | 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 = buildTemplateBySource(source);
templateCache.put(cacheKey, template);
} else if (devMode) {
if (template.isModified()) {
template = buildTemplateBySource(source);
templateCache.put(cacheKey, template);
}
}
return template;
} | [
"public",
"Template",
"getTemplate",
"(",
"ISource",
"source",
")",
"{",
"String",
"cacheKey",
"=",
"source",
".",
"getCacheKey",
"(",
")",
";",
"if",
"(",
"cacheKey",
"==",
"null",
")",
"{",
"// cacheKey 为 null 则不缓存,详见 ISource.getCacheKey() 注释\r",
"return",
"buil... | Get template by implementation of ISource | [
"Get",
"template",
"by",
"implementation",
"of",
"ISource"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/Engine.java#L212-L229 |
31,170 | jfinal/jfinal | src/main/java/com/jfinal/template/Engine.java | Engine.addSharedObject | public Engine addSharedObject(String name, Object object) {
config.addSharedObject(name, object);
return this;
} | java | public Engine addSharedObject(String name, Object object) {
config.addSharedObject(name, object);
return this;
} | [
"public",
"Engine",
"addSharedObject",
"(",
"String",
"name",
",",
"Object",
"object",
")",
"{",
"config",
".",
"addSharedObject",
"(",
"name",
",",
"object",
")",
";",
"return",
"this",
";",
"}"
] | Add shared object | [
"Add",
"shared",
"object"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/template/Engine.java#L277-L280 |
31,171 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/DbKit.java | DbKit.addConfig | 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.put(config.getName(), config);
/**
* Replace the main config if current config name is MAIN_CONFIG_NAME
*/
if (MAIN_CONFIG_NAME.equals(config.getName())) {
DbKit.config = config;
Db.init(DbKit.config.getName());
}
/**
* The configName may not be MAIN_CONFIG_NAME,
* the main config have to set the first comming Config if it is null
*/
if (DbKit.config == null) {
DbKit.config = config;
Db.init(DbKit.config.getName());
}
} | java | 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.put(config.getName(), config);
/**
* Replace the main config if current config name is MAIN_CONFIG_NAME
*/
if (MAIN_CONFIG_NAME.equals(config.getName())) {
DbKit.config = config;
Db.init(DbKit.config.getName());
}
/**
* The configName may not be MAIN_CONFIG_NAME,
* the main config have to set the first comming Config if it is null
*/
if (DbKit.config == null) {
DbKit.config = config;
Db.init(DbKit.config.getName());
}
} | [
"public",
"static",
"void",
"addConfig",
"(",
"Config",
"config",
")",
"{",
"if",
"(",
"config",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Config can not be null\"",
")",
";",
"}",
"if",
"(",
"configNameToConfig",
".",
"contai... | Add Config object
@param config the Config contains DataSource, Dialect and so on | [
"Add",
"Config",
"object"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/DbKit.java#L58-L84 |
31,172 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/DbPro.java | DbPro.update | public int update(String sql, Object... paras) {
Connection conn = null;
try {
conn = config.getConnection();
return update(config, conn, sql, paras);
} catch (Exception e) {
throw new ActiveRecordException(e);
} finally {
config.close(conn);
}
} | java | public int update(String sql, Object... paras) {
Connection conn = null;
try {
conn = config.getConnection();
return update(config, conn, sql, paras);
} catch (Exception e) {
throw new ActiveRecordException(e);
} finally {
config.close(conn);
}
} | [
"public",
"int",
"update",
"(",
"String",
"sql",
",",
"Object",
"...",
"paras",
")",
"{",
"Connection",
"conn",
"=",
"null",
";",
"try",
"{",
"conn",
"=",
"config",
".",
"getConnection",
"(",
")",
";",
"return",
"update",
"(",
"config",
",",
"conn",
... | Execute update, insert or delete sql statement.
@param sql an SQL statement that may contain one or more '?' IN parameter placeholders
@param paras the parameters of sql
@return either the row count for <code>INSERT</code>, <code>UPDATE</code>,
or <code>DELETE</code> statements, or 0 for SQL statements
that return nothing | [
"Execute",
"update",
"insert",
"or",
"delete",
"sql",
"statement",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/DbPro.java#L291-L301 |
31,173 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/DbPro.java | DbPro.findFirstByCache | public Record findFirstByCache(String cacheName, Object key, String sql, Object... paras) {
ICache cache = config.getCache();
Record result = cache.get(cacheName, key);
if (result == null) {
result = findFirst(sql, paras);
cache.put(cacheName, key, result);
}
return result;
} | java | public Record findFirstByCache(String cacheName, Object key, String sql, Object... paras) {
ICache cache = config.getCache();
Record result = cache.get(cacheName, key);
if (result == null) {
result = findFirst(sql, paras);
cache.put(cacheName, key, result);
}
return result;
} | [
"public",
"Record",
"findFirstByCache",
"(",
"String",
"cacheName",
",",
"Object",
"key",
",",
"String",
"sql",
",",
"Object",
"...",
"paras",
")",
"{",
"ICache",
"cache",
"=",
"config",
".",
"getCache",
"(",
")",
";",
"Record",
"result",
"=",
"cache",
"... | Find first record by cache. I recommend add "limit 1" in your sql.
@see #findFirst(String, Object...)
@param cacheName the cache name
@param key the key used to get date from cache
@param sql an SQL statement that may contain one or more '?' IN parameter placeholders
@param paras the parameters of sql
@return the Record object | [
"Find",
"first",
"record",
"by",
"cache",
".",
"I",
"recommend",
"add",
"limit",
"1",
"in",
"your",
"sql",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/DbPro.java#L843-L851 |
31,174 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/DbPro.java | DbPro.batchSave | public int[] batchSave(List<? extends Model> modelList, int batchSize) {
if (modelList == null || modelList.size() == 0)
return new int[0];
Model model = modelList.get(0);
Map<String, Object> attrs = model._getAttrs();
int index = 0;
StringBuilder columns = new StringBuilder();
// the same as the iterator in Dialect.forModelSave() to ensure the order of the attrs
for (Entry<String, Object> e : attrs.entrySet()) {
if (config.dialect.isOracle()) { // 支持 oracle 自增主键
Object value = e.getValue();
if (value instanceof String && ((String)value).endsWith(".nextval")) {
continue ;
}
}
if (index++ > 0) {
columns.append(',');
}
columns.append(e.getKey());
}
StringBuilder sql = new StringBuilder();
List<Object> parasNoUse = new ArrayList<Object>();
config.dialect.forModelSave(TableMapping.me().getTable(model.getClass()), attrs, sql, parasNoUse);
return batch(sql.toString(), columns.toString(), modelList, batchSize);
} | java | public int[] batchSave(List<? extends Model> modelList, int batchSize) {
if (modelList == null || modelList.size() == 0)
return new int[0];
Model model = modelList.get(0);
Map<String, Object> attrs = model._getAttrs();
int index = 0;
StringBuilder columns = new StringBuilder();
// the same as the iterator in Dialect.forModelSave() to ensure the order of the attrs
for (Entry<String, Object> e : attrs.entrySet()) {
if (config.dialect.isOracle()) { // 支持 oracle 自增主键
Object value = e.getValue();
if (value instanceof String && ((String)value).endsWith(".nextval")) {
continue ;
}
}
if (index++ > 0) {
columns.append(',');
}
columns.append(e.getKey());
}
StringBuilder sql = new StringBuilder();
List<Object> parasNoUse = new ArrayList<Object>();
config.dialect.forModelSave(TableMapping.me().getTable(model.getClass()), attrs, sql, parasNoUse);
return batch(sql.toString(), columns.toString(), modelList, batchSize);
} | [
"public",
"int",
"[",
"]",
"batchSave",
"(",
"List",
"<",
"?",
"extends",
"Model",
">",
"modelList",
",",
"int",
"batchSize",
")",
"{",
"if",
"(",
"modelList",
"==",
"null",
"||",
"modelList",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
"new",
... | Batch save models using the "insert into ..." sql generated by the first model in modelList.
Ensure all the models can use the same sql as the first model. | [
"Batch",
"save",
"models",
"using",
"the",
"insert",
"into",
"...",
"sql",
"generated",
"by",
"the",
"first",
"model",
"in",
"modelList",
".",
"Ensure",
"all",
"the",
"models",
"can",
"use",
"the",
"same",
"sql",
"as",
"the",
"first",
"model",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/DbPro.java#L1123-L1150 |
31,175 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/DbPro.java | DbPro.batchSave | public int[] batchSave(String tableName, List<Record> recordList, int batchSize) {
if (recordList == null || recordList.size() == 0)
return new int[0];
Record record = recordList.get(0);
Map<String, Object> cols = record.getColumns();
int index = 0;
StringBuilder columns = new StringBuilder();
// the same as the iterator in Dialect.forDbSave() to ensure the order of the columns
for (Entry<String, Object> e : cols.entrySet()) {
if (config.dialect.isOracle()) { // 支持 oracle 自增主键
Object value = e.getValue();
if (value instanceof String && ((String)value).endsWith(".nextval")) {
continue ;
}
}
if (index++ > 0) {
columns.append(',');
}
columns.append(e.getKey());
}
String[] pKeysNoUse = new String[0];
StringBuilder sql = new StringBuilder();
List<Object> parasNoUse = new ArrayList<Object>();
config.dialect.forDbSave(tableName, pKeysNoUse, record, sql, parasNoUse);
return batch(sql.toString(), columns.toString(), recordList, batchSize);
} | java | public int[] batchSave(String tableName, List<Record> recordList, int batchSize) {
if (recordList == null || recordList.size() == 0)
return new int[0];
Record record = recordList.get(0);
Map<String, Object> cols = record.getColumns();
int index = 0;
StringBuilder columns = new StringBuilder();
// the same as the iterator in Dialect.forDbSave() to ensure the order of the columns
for (Entry<String, Object> e : cols.entrySet()) {
if (config.dialect.isOracle()) { // 支持 oracle 自增主键
Object value = e.getValue();
if (value instanceof String && ((String)value).endsWith(".nextval")) {
continue ;
}
}
if (index++ > 0) {
columns.append(',');
}
columns.append(e.getKey());
}
String[] pKeysNoUse = new String[0];
StringBuilder sql = new StringBuilder();
List<Object> parasNoUse = new ArrayList<Object>();
config.dialect.forDbSave(tableName, pKeysNoUse, record, sql, parasNoUse);
return batch(sql.toString(), columns.toString(), recordList, batchSize);
} | [
"public",
"int",
"[",
"]",
"batchSave",
"(",
"String",
"tableName",
",",
"List",
"<",
"Record",
">",
"recordList",
",",
"int",
"batchSize",
")",
"{",
"if",
"(",
"recordList",
"==",
"null",
"||",
"recordList",
".",
"size",
"(",
")",
"==",
"0",
")",
"r... | Batch save records using the "insert into ..." sql generated by the first record in recordList.
Ensure all the record can use the same sql as the first record.
@param tableName the table name | [
"Batch",
"save",
"records",
"using",
"the",
"insert",
"into",
"...",
"sql",
"generated",
"by",
"the",
"first",
"record",
"in",
"recordList",
".",
"Ensure",
"all",
"the",
"record",
"can",
"use",
"the",
"same",
"sql",
"as",
"the",
"first",
"record",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/DbPro.java#L1157-L1185 |
31,176 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/DbPro.java | DbPro.batchUpdate | public int[] batchUpdate(List<? extends Model> modelList, int batchSize) {
if (modelList == null || modelList.size() == 0)
return new int[0];
Model model = modelList.get(0);
Table table = TableMapping.me().getTable(model.getClass());
String[] pKeys = table.getPrimaryKey();
Map<String, Object> attrs = model._getAttrs();
List<String> attrNames = new ArrayList<String>();
// the same as the iterator in Dialect.forModelSave() to ensure the order of the attrs
for (Entry<String, Object> e : attrs.entrySet()) {
String attr = e.getKey();
if (config.dialect.isPrimaryKey(attr, pKeys) == false && table.hasColumnLabel(attr))
attrNames.add(attr);
}
for (String pKey : pKeys)
attrNames.add(pKey);
String columns = StrKit.join(attrNames.toArray(new String[attrNames.size()]), ",");
// update all attrs of the model not use the midifyFlag of every single model
Set<String> modifyFlag = attrs.keySet(); // model.getModifyFlag();
StringBuilder sql = new StringBuilder();
List<Object> parasNoUse = new ArrayList<Object>();
config.dialect.forModelUpdate(TableMapping.me().getTable(model.getClass()), attrs, modifyFlag, sql, parasNoUse);
return batch(sql.toString(), columns, modelList, batchSize);
} | java | public int[] batchUpdate(List<? extends Model> modelList, int batchSize) {
if (modelList == null || modelList.size() == 0)
return new int[0];
Model model = modelList.get(0);
Table table = TableMapping.me().getTable(model.getClass());
String[] pKeys = table.getPrimaryKey();
Map<String, Object> attrs = model._getAttrs();
List<String> attrNames = new ArrayList<String>();
// the same as the iterator in Dialect.forModelSave() to ensure the order of the attrs
for (Entry<String, Object> e : attrs.entrySet()) {
String attr = e.getKey();
if (config.dialect.isPrimaryKey(attr, pKeys) == false && table.hasColumnLabel(attr))
attrNames.add(attr);
}
for (String pKey : pKeys)
attrNames.add(pKey);
String columns = StrKit.join(attrNames.toArray(new String[attrNames.size()]), ",");
// update all attrs of the model not use the midifyFlag of every single model
Set<String> modifyFlag = attrs.keySet(); // model.getModifyFlag();
StringBuilder sql = new StringBuilder();
List<Object> parasNoUse = new ArrayList<Object>();
config.dialect.forModelUpdate(TableMapping.me().getTable(model.getClass()), attrs, modifyFlag, sql, parasNoUse);
return batch(sql.toString(), columns, modelList, batchSize);
} | [
"public",
"int",
"[",
"]",
"batchUpdate",
"(",
"List",
"<",
"?",
"extends",
"Model",
">",
"modelList",
",",
"int",
"batchSize",
")",
"{",
"if",
"(",
"modelList",
"==",
"null",
"||",
"modelList",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
"new",... | Batch update models using the attrs names of the first model in modelList.
Ensure all the models can use the same sql as the first model. | [
"Batch",
"update",
"models",
"using",
"the",
"attrs",
"names",
"of",
"the",
"first",
"model",
"in",
"modelList",
".",
"Ensure",
"all",
"the",
"models",
"can",
"use",
"the",
"same",
"sql",
"as",
"the",
"first",
"model",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/DbPro.java#L1191-L1217 |
31,177 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/DbPro.java | DbPro.batchUpdate | public int[] batchUpdate(String tableName, String primaryKey, List<Record> recordList, int batchSize) {
if (recordList == null || recordList.size() == 0)
return new int[0];
String[] pKeys = primaryKey.split(",");
config.dialect.trimPrimaryKeys(pKeys);
Record record = recordList.get(0);
Map<String, Object> cols = record.getColumns();
List<String> colNames = new ArrayList<String>();
// the same as the iterator in Dialect.forDbUpdate() to ensure the order of the columns
for (Entry<String, Object> e : cols.entrySet()) {
String col = e.getKey();
if (config.dialect.isPrimaryKey(col, pKeys) == false)
colNames.add(col);
}
for (String pKey : pKeys)
colNames.add(pKey);
String columns = StrKit.join(colNames.toArray(new String[colNames.size()]), ",");
Object[] idsNoUse = new Object[pKeys.length];
StringBuilder sql = new StringBuilder();
List<Object> parasNoUse = new ArrayList<Object>();
config.dialect.forDbUpdate(tableName, pKeys, idsNoUse, record, sql, parasNoUse);
return batch(sql.toString(), columns, recordList, batchSize);
} | java | public int[] batchUpdate(String tableName, String primaryKey, List<Record> recordList, int batchSize) {
if (recordList == null || recordList.size() == 0)
return new int[0];
String[] pKeys = primaryKey.split(",");
config.dialect.trimPrimaryKeys(pKeys);
Record record = recordList.get(0);
Map<String, Object> cols = record.getColumns();
List<String> colNames = new ArrayList<String>();
// the same as the iterator in Dialect.forDbUpdate() to ensure the order of the columns
for (Entry<String, Object> e : cols.entrySet()) {
String col = e.getKey();
if (config.dialect.isPrimaryKey(col, pKeys) == false)
colNames.add(col);
}
for (String pKey : pKeys)
colNames.add(pKey);
String columns = StrKit.join(colNames.toArray(new String[colNames.size()]), ",");
Object[] idsNoUse = new Object[pKeys.length];
StringBuilder sql = new StringBuilder();
List<Object> parasNoUse = new ArrayList<Object>();
config.dialect.forDbUpdate(tableName, pKeys, idsNoUse, record, sql, parasNoUse);
return batch(sql.toString(), columns, recordList, batchSize);
} | [
"public",
"int",
"[",
"]",
"batchUpdate",
"(",
"String",
"tableName",
",",
"String",
"primaryKey",
",",
"List",
"<",
"Record",
">",
"recordList",
",",
"int",
"batchSize",
")",
"{",
"if",
"(",
"recordList",
"==",
"null",
"||",
"recordList",
".",
"size",
"... | Batch update records using the columns names of the first record in recordList.
Ensure all the records can use the same sql as the first record.
@param tableName the table name
@param primaryKey the primary key of the table, composite primary key is separated by comma character: "," | [
"Batch",
"update",
"records",
"using",
"the",
"columns",
"names",
"of",
"the",
"first",
"record",
"in",
"recordList",
".",
"Ensure",
"all",
"the",
"records",
"can",
"use",
"the",
"same",
"sql",
"as",
"the",
"first",
"record",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/DbPro.java#L1225-L1250 |
31,178 | jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/DbPro.java | DbPro.batchUpdate | public int[] batchUpdate(String tableName, List<Record> recordList, int batchSize) {
return batchUpdate(tableName, config.dialect.getDefaultPrimaryKey(),recordList, batchSize);
} | java | public int[] batchUpdate(String tableName, List<Record> recordList, int batchSize) {
return batchUpdate(tableName, config.dialect.getDefaultPrimaryKey(),recordList, batchSize);
} | [
"public",
"int",
"[",
"]",
"batchUpdate",
"(",
"String",
"tableName",
",",
"List",
"<",
"Record",
">",
"recordList",
",",
"int",
"batchSize",
")",
"{",
"return",
"batchUpdate",
"(",
"tableName",
",",
"config",
".",
"dialect",
".",
"getDefaultPrimaryKey",
"("... | Batch update records with default primary key, using the columns names of the first record in recordList.
Ensure all the records can use the same sql as the first record.
@param tableName the table name | [
"Batch",
"update",
"records",
"with",
"default",
"primary",
"key",
"using",
"the",
"columns",
"names",
"of",
"the",
"first",
"record",
"in",
"recordList",
".",
"Ensure",
"all",
"the",
"records",
"can",
"use",
"the",
"same",
"sql",
"as",
"the",
"first",
"re... | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/DbPro.java#L1257-L1259 |
31,179 | jfinal/jfinal | src/main/java/com/jfinal/handler/HandlerFactory.java | HandlerFactory.getHandler | @SuppressWarnings("deprecation")
public static Handler getHandler(List<Handler> handlerList, Handler actionHandler) {
Handler result = actionHandler;
for (int i=handlerList.size()-1; i>=0; i--) {
Handler temp = handlerList.get(i);
temp.next = result;
temp.nextHandler = result;
result = temp;
}
return result;
} | java | @SuppressWarnings("deprecation")
public static Handler getHandler(List<Handler> handlerList, Handler actionHandler) {
Handler result = actionHandler;
for (int i=handlerList.size()-1; i>=0; i--) {
Handler temp = handlerList.get(i);
temp.next = result;
temp.nextHandler = result;
result = temp;
}
return result;
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"Handler",
"getHandler",
"(",
"List",
"<",
"Handler",
">",
"handlerList",
",",
"Handler",
"actionHandler",
")",
"{",
"Handler",
"result",
"=",
"actionHandler",
";",
"for",
"(",
"int",
"i... | Build handler chain | [
"Build",
"handler",
"chain"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/handler/HandlerFactory.java#L33-L45 |
31,180 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.addError | protected void addError(String errorKey, String errorMessage) {
invalid = true;
controller.setAttr(errorKey, errorMessage);
if (shortCircuit) {
throw new ValidateException();
}
} | java | protected void addError(String errorKey, String errorMessage) {
invalid = true;
controller.setAttr(errorKey, errorMessage);
if (shortCircuit) {
throw new ValidateException();
}
} | [
"protected",
"void",
"addError",
"(",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"invalid",
"=",
"true",
";",
"controller",
".",
"setAttr",
"(",
"errorKey",
",",
"errorMessage",
")",
";",
"if",
"(",
"shortCircuit",
")",
"{",
"throw",
"n... | Add message when validate failure. | [
"Add",
"message",
"when",
"validate",
"failure",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L111-L117 |
31,181 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateRequired | protected void validateRequired(String field, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (value == null || "".equals(value)) { // 经测试,form表单域无输入时值为"",跳格键值为"\t",输入空格则为空格" "
addError(errorKey, errorMessage);
}
} | java | protected void validateRequired(String field, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (value == null || "".equals(value)) { // 经测试,form表单域无输入时值为"",跳格键值为"\t",输入空格则为空格" "
addError(errorKey, errorMessage);
}
} | [
"protected",
"void",
"validateRequired",
"(",
"String",
"field",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"String",
"value",
"=",
"controller",
".",
"getPara",
"(",
"field",
")",
";",
"if",
"(",
"value",
"==",
"null",
"||",
"\"\"... | Validate Required. Allow space characters. | [
"Validate",
"Required",
".",
"Allow",
"space",
"characters",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L164-L169 |
31,182 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateRequired | protected void validateRequired(int index, String errorKey, String errorMessage) {
String value = controller.getPara(index);
if (value == null /* || "".equals(value) */) {
addError(errorKey, errorMessage);
}
} | java | protected void validateRequired(int index, String errorKey, String errorMessage) {
String value = controller.getPara(index);
if (value == null /* || "".equals(value) */) {
addError(errorKey, errorMessage);
}
} | [
"protected",
"void",
"validateRequired",
"(",
"int",
"index",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"String",
"value",
"=",
"controller",
".",
"getPara",
"(",
"index",
")",
";",
"if",
"(",
"value",
"==",
"null",
"/* || \"\".equa... | Validate Required for urlPara. | [
"Validate",
"Required",
"for",
"urlPara",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L174-L179 |
31,183 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateRequiredString | protected void validateRequiredString(String field, String errorKey, String errorMessage) {
if (StrKit.isBlank(controller.getPara(field))) {
addError(errorKey, errorMessage);
}
} | java | protected void validateRequiredString(String field, String errorKey, String errorMessage) {
if (StrKit.isBlank(controller.getPara(field))) {
addError(errorKey, errorMessage);
}
} | [
"protected",
"void",
"validateRequiredString",
"(",
"String",
"field",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"if",
"(",
"StrKit",
".",
"isBlank",
"(",
"controller",
".",
"getPara",
"(",
"field",
")",
")",
")",
"{",
"addError",
... | Validate required string. | [
"Validate",
"required",
"string",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L184-L188 |
31,184 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateInteger | protected void validateInteger(String field, String errorKey, String errorMessage) {
validateIntegerValue(controller.getPara(field), errorKey, errorMessage);
} | java | protected void validateInteger(String field, String errorKey, String errorMessage) {
validateIntegerValue(controller.getPara(field), errorKey, errorMessage);
} | [
"protected",
"void",
"validateInteger",
"(",
"String",
"field",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"validateIntegerValue",
"(",
"controller",
".",
"getPara",
"(",
"field",
")",
",",
"errorKey",
",",
"errorMessage",
")",
";",
"}... | Validate integer. | [
"Validate",
"integer",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L236-L238 |
31,185 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateInteger | protected void validateInteger(int index, String errorKey, String errorMessage) {
String value = controller.getPara(index);
if (value != null && (value.startsWith("N") || value.startsWith("n"))) {
value = "-" + value.substring(1);
}
validateIntegerValue(value, errorKey, errorMessage);
} | java | protected void validateInteger(int index, String errorKey, String errorMessage) {
String value = controller.getPara(index);
if (value != null && (value.startsWith("N") || value.startsWith("n"))) {
value = "-" + value.substring(1);
}
validateIntegerValue(value, errorKey, errorMessage);
} | [
"protected",
"void",
"validateInteger",
"(",
"int",
"index",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"String",
"value",
"=",
"controller",
".",
"getPara",
"(",
"index",
")",
";",
"if",
"(",
"value",
"!=",
"null",
"&&",
"(",
"v... | Validate integer for urlPara. | [
"Validate",
"integer",
"for",
"urlPara",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L243-L249 |
31,186 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateLong | protected void validateLong(String field, long min, long max, String errorKey, String errorMessage) {
validateLongValue(controller.getPara(field), min, max, errorKey, errorMessage);
} | java | protected void validateLong(String field, long min, long max, String errorKey, String errorMessage) {
validateLongValue(controller.getPara(field), min, max, errorKey, errorMessage);
} | [
"protected",
"void",
"validateLong",
"(",
"String",
"field",
",",
"long",
"min",
",",
"long",
"max",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"validateLongValue",
"(",
"controller",
".",
"getPara",
"(",
"field",
")",
",",
"min",
... | Validate long. | [
"Validate",
"long",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L267-L269 |
31,187 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateLong | protected void validateLong(int index, long min, long max, String errorKey, String errorMessage) {
String value = controller.getPara(index);
if (value != null && (value.startsWith("N") || value.startsWith("n"))) {
value = "-" + value.substring(1);
}
validateLongValue(value, min, max, errorKey, errorMessage);
} | java | protected void validateLong(int index, long min, long max, String errorKey, String errorMessage) {
String value = controller.getPara(index);
if (value != null && (value.startsWith("N") || value.startsWith("n"))) {
value = "-" + value.substring(1);
}
validateLongValue(value, min, max, errorKey, errorMessage);
} | [
"protected",
"void",
"validateLong",
"(",
"int",
"index",
",",
"long",
"min",
",",
"long",
"max",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"String",
"value",
"=",
"controller",
".",
"getPara",
"(",
"index",
")",
";",
"if",
"(",... | Validate long for urlPara. | [
"Validate",
"long",
"for",
"urlPara",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L274-L280 |
31,188 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateDouble | protected void validateDouble(String field, double min, double max, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
return ;
}
try {
double temp = Double.parseDouble(value.trim());
if (temp < min || temp > max) {
addError(errorKey, errorMessage);
}
}
catch (Exception e) {
addError(errorKey, errorMessage);
}
} | java | protected void validateDouble(String field, double min, double max, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
return ;
}
try {
double temp = Double.parseDouble(value.trim());
if (temp < min || temp > max) {
addError(errorKey, errorMessage);
}
}
catch (Exception e) {
addError(errorKey, errorMessage);
}
} | [
"protected",
"void",
"validateDouble",
"(",
"String",
"field",
",",
"double",
"min",
",",
"double",
"max",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"String",
"value",
"=",
"controller",
".",
"getPara",
"(",
"field",
")",
";",
"if... | Validate double. | [
"Validate",
"double",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L332-L347 |
31,189 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateDate | protected void validateDate(String field, Date min, Date max, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
return ;
}
try {
Date temp = new SimpleDateFormat(getDatePattern()).parse(value.trim()); // Date temp = Date.valueOf(value); 为了兼容 64位 JDK
if (temp.before(min) || temp.after(max)) {
addError(errorKey, errorMessage);
}
}
catch (Exception e) {
addError(errorKey, errorMessage);
}
} | java | protected void validateDate(String field, Date min, Date max, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
return ;
}
try {
Date temp = new SimpleDateFormat(getDatePattern()).parse(value.trim()); // Date temp = Date.valueOf(value); 为了兼容 64位 JDK
if (temp.before(min) || temp.after(max)) {
addError(errorKey, errorMessage);
}
}
catch (Exception e) {
addError(errorKey, errorMessage);
}
} | [
"protected",
"void",
"validateDate",
"(",
"String",
"field",
",",
"Date",
"min",
",",
"Date",
"max",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"String",
"value",
"=",
"controller",
".",
"getPara",
"(",
"field",
")",
";",
"if",
"... | Validate date. | [
"Validate",
"date",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L386-L401 |
31,190 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateEqualField | protected void validateEqualField(String field_1, String field_2, String errorKey, String errorMessage) {
String value_1 = controller.getPara(field_1);
String value_2 = controller.getPara(field_2);
if (value_1 == null || value_2 == null || (! value_1.equals(value_2))) {
addError(errorKey, errorMessage);
}
} | java | protected void validateEqualField(String field_1, String field_2, String errorKey, String errorMessage) {
String value_1 = controller.getPara(field_1);
String value_2 = controller.getPara(field_2);
if (value_1 == null || value_2 == null || (! value_1.equals(value_2))) {
addError(errorKey, errorMessage);
}
} | [
"protected",
"void",
"validateEqualField",
"(",
"String",
"field_1",
",",
"String",
"field_2",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"String",
"value_1",
"=",
"controller",
".",
"getPara",
"(",
"field_1",
")",
";",
"String",
"valu... | Validate equal field. Usually validate password and password again | [
"Validate",
"equal",
"field",
".",
"Usually",
"validate",
"password",
"and",
"password",
"again"
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L419-L425 |
31,191 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateEqualString | protected void validateEqualString(String s1, String s2, String errorKey, String errorMessage) {
if (s1 == null || s2 == null || (! s1.equals(s2))) {
addError(errorKey, errorMessage);
}
} | java | protected void validateEqualString(String s1, String s2, String errorKey, String errorMessage) {
if (s1 == null || s2 == null || (! s1.equals(s2))) {
addError(errorKey, errorMessage);
}
} | [
"protected",
"void",
"validateEqualString",
"(",
"String",
"s1",
",",
"String",
"s2",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"if",
"(",
"s1",
"==",
"null",
"||",
"s2",
"==",
"null",
"||",
"(",
"!",
"s1",
".",
"equals",
"(",... | Validate equal string. | [
"Validate",
"equal",
"string",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L430-L434 |
31,192 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateEqualInteger | protected void validateEqualInteger(Integer i1, Integer i2, String errorKey, String errorMessage) {
if (i1 == null || i2 == null || (i1.intValue() != i2.intValue())) {
addError(errorKey, errorMessage);
}
} | java | protected void validateEqualInteger(Integer i1, Integer i2, String errorKey, String errorMessage) {
if (i1 == null || i2 == null || (i1.intValue() != i2.intValue())) {
addError(errorKey, errorMessage);
}
} | [
"protected",
"void",
"validateEqualInteger",
"(",
"Integer",
"i1",
",",
"Integer",
"i2",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"if",
"(",
"i1",
"==",
"null",
"||",
"i2",
"==",
"null",
"||",
"(",
"i1",
".",
"intValue",
"(",
... | Validate equal integer. | [
"Validate",
"equal",
"integer",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L439-L443 |
31,193 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateEmail | protected void validateEmail(String field, String errorKey, String errorMessage) {
validateRegex(field, emailAddressPattern, false, errorKey, errorMessage);
} | java | protected void validateEmail(String field, String errorKey, String errorMessage) {
validateRegex(field, emailAddressPattern, false, errorKey, errorMessage);
} | [
"protected",
"void",
"validateEmail",
"(",
"String",
"field",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"validateRegex",
"(",
"field",
",",
"emailAddressPattern",
",",
"false",
",",
"errorKey",
",",
"errorMessage",
")",
";",
"}"
] | Validate email. | [
"Validate",
"email",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L448-L450 |
31,194 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateUrl | protected void validateUrl(String field, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
return ;
}
try {
value = value.trim();
if (value.startsWith("https://")) {
value = "http://" + value.substring(8); // URL doesn't understand the https protocol, hack it
}
new URL(value);
} catch (MalformedURLException e) {
addError(errorKey, errorMessage);
}
} | java | protected void validateUrl(String field, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
return ;
}
try {
value = value.trim();
if (value.startsWith("https://")) {
value = "http://" + value.substring(8); // URL doesn't understand the https protocol, hack it
}
new URL(value);
} catch (MalformedURLException e) {
addError(errorKey, errorMessage);
}
} | [
"protected",
"void",
"validateUrl",
"(",
"String",
"field",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"String",
"value",
"=",
"controller",
".",
"getPara",
"(",
"field",
")",
";",
"if",
"(",
"StrKit",
".",
"isBlank",
"(",
"value",... | Validate URL. | [
"Validate",
"URL",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L455-L470 |
31,195 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateRegex | protected void validateRegex(String field, String regExpression, boolean isCaseSensitive, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (value == null) {
addError(errorKey, errorMessage);
return ;
}
Pattern pattern = isCaseSensitive ? Pattern.compile(regExpression) : Pattern.compile(regExpression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(value);
if (!matcher.matches()) {
addError(errorKey, errorMessage);
}
} | java | protected void validateRegex(String field, String regExpression, boolean isCaseSensitive, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (value == null) {
addError(errorKey, errorMessage);
return ;
}
Pattern pattern = isCaseSensitive ? Pattern.compile(regExpression) : Pattern.compile(regExpression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(value);
if (!matcher.matches()) {
addError(errorKey, errorMessage);
}
} | [
"protected",
"void",
"validateRegex",
"(",
"String",
"field",
",",
"String",
"regExpression",
",",
"boolean",
"isCaseSensitive",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"String",
"value",
"=",
"controller",
".",
"getPara",
"(",
"field... | Validate regular expression. | [
"Validate",
"regular",
"expression",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L475-L486 |
31,196 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateRegex | protected void validateRegex(String field, String regExpression, String errorKey, String errorMessage) {
validateRegex(field, regExpression, true, errorKey, errorMessage);
} | java | protected void validateRegex(String field, String regExpression, String errorKey, String errorMessage) {
validateRegex(field, regExpression, true, errorKey, errorMessage);
} | [
"protected",
"void",
"validateRegex",
"(",
"String",
"field",
",",
"String",
"regExpression",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"validateRegex",
"(",
"field",
",",
"regExpression",
",",
"true",
",",
"errorKey",
",",
"errorMessag... | Validate regular expression and case sensitive. | [
"Validate",
"regular",
"expression",
"and",
"case",
"sensitive",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L491-L493 |
31,197 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateString | protected void validateString(String field, int minLen, int maxLen, String errorKey, String errorMessage) {
validateStringValue(controller.getPara(field), minLen, maxLen, errorKey, errorMessage);
} | java | protected void validateString(String field, int minLen, int maxLen, String errorKey, String errorMessage) {
validateStringValue(controller.getPara(field), minLen, maxLen, errorKey, errorMessage);
} | [
"protected",
"void",
"validateString",
"(",
"String",
"field",
",",
"int",
"minLen",
",",
"int",
"maxLen",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"validateStringValue",
"(",
"controller",
".",
"getPara",
"(",
"field",
")",
",",
"... | Validate string. | [
"Validate",
"string",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L498-L500 |
31,198 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateBoolean | protected void validateBoolean(String field, String errorKey, String errorMessage) {
validateBooleanValue(controller.getPara(field), errorKey, errorMessage);
} | java | protected void validateBoolean(String field, String errorKey, String errorMessage) {
validateBooleanValue(controller.getPara(field), errorKey, errorMessage);
} | [
"protected",
"void",
"validateBoolean",
"(",
"String",
"field",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"validateBooleanValue",
"(",
"controller",
".",
"getPara",
"(",
"field",
")",
",",
"errorKey",
",",
"errorMessage",
")",
";",
"}... | validate boolean. | [
"validate",
"boolean",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L543-L545 |
31,199 | jfinal/jfinal | src/main/java/com/jfinal/validate/Validator.java | Validator.validateBoolean | protected void validateBoolean(int index, String errorKey, String errorMessage) {
validateBooleanValue(controller.getPara(index), errorKey, errorMessage);
} | java | protected void validateBoolean(int index, String errorKey, String errorMessage) {
validateBooleanValue(controller.getPara(index), errorKey, errorMessage);
} | [
"protected",
"void",
"validateBoolean",
"(",
"int",
"index",
",",
"String",
"errorKey",
",",
"String",
"errorMessage",
")",
"{",
"validateBooleanValue",
"(",
"controller",
".",
"getPara",
"(",
"index",
")",
",",
"errorKey",
",",
"errorMessage",
")",
";",
"}"
] | validate boolean for urlPara. | [
"validate",
"boolean",
"for",
"urlPara",
"."
] | fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9 | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/validate/Validator.java#L550-L552 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.