The Unified and Autonomous Development Platform
fix .gitignore issue
robin shine2f63f96e3392
diff --git a/.gitignore b/.gitignoreindex 419619e200..f8fc669cf3 100644--- a/.gitignore+++ b/.gitignore@@ -20,31 +20,4 @@ pom.xml.releaseBackup*~.nib*.DS_Store*.log-/archetype.artifact/-/archetype.plugin/-/archetype.product/-/commons.all/-/commons.bootstrap/-/commons.editable/-/commons.git/-/commons.hibernate/-/commons.jackson/-/commons.jersey/-/commons.jetty/-/commons.jsw/-/commons.lang/-/commons.loader/-/commons.markdown/-/commons.schedule/-/commons.shiro/-/commons.util/-/commons.validation/-/commons.wicket/-/gitplex.core/-/gitplex.http/-/gitplex.product/-/gitplex.rest/-/gitplex.search/-/gitplex.web/-/parent.general/-/plugin.maven/+diff --git a/commons.git/src/main/java/com/pmease/commons/git/Blob.java b/commons.git/src/main/java/com/pmease/commons/git/Blob.javanew file mode 100644index 0000000000..4cb0f38faa--- /dev/null+++ b/commons.git/src/main/java/com/pmease/commons/git/Blob.java@@ -0,0 +1,129 @@+package com.pmease.commons.git;++import java.nio.charset.Charset;+import java.util.ArrayList;+import java.util.List;++import javax.annotation.Nullable;++import org.apache.tika.mime.MediaType;++import com.google.common.base.Optional;+import com.pmease.commons.util.Charsets;+import com.pmease.commons.util.MediaTypes;++public class Blob {++ private final BlobIdent ident;++ private final byte[] bytes;++ private final long size;++ private transient MediaType mediaType;++ private transient Optional<Text> optionalText;++ public Blob(BlobIdent ident, byte[] bytes) {+ this(ident, bytes, bytes.length);+ }++ public Blob(BlobIdent ident, byte[] bytes, long size) {+ this.ident = ident;+ this.bytes = bytes;+ this.size = size;+ }++ public BlobIdent getIdent() {+ return ident;+ }++ public byte[] getBytes() {+ return bytes;+ }++ public long getSize() {+ return size;+ }++ public boolean isPartial() {+ return bytes.length < size;+ }++ public MediaType getMediaType() {+ if (mediaType == null) {+ if (ident.isGitLink() || ident.isSymbolLink() || ident.isTree())+ mediaType = MediaType.TEXT_PLAIN;+ else+ mediaType = MediaTypes.detectFrom(bytes, ident.path);+ }+ return mediaType;+ }++ /**+ * Get text representation of this blob.+ *+ * @return+ * text representation of this blob, or <tt>null</tt> if this blob+ * content is binary+ */+ public @Nullable Text getText() {+ if (optionalText == null) {+ if (ident.isGitLink() || ident.isSymbolLink() || ident.isTree()) {+ Charset charset = Charsets.UTF_8;+ optionalText = Optional.of(new Text(charset, new String(bytes, charset)));+ } else if (!isPartial()) {+ Charset charset = Charsets.detectFrom(bytes);+ if (charset != null)+ optionalText = Optional.of(new Text(charset, new String(bytes, charset)));+ else+ optionalText = Optional.absent();+ } else {+ optionalText = Optional.absent();+ }+ }+ return optionalText.orNull();+ }++ public static class Text {++ private final Charset charset;++ private final String content;++ private transient List<String> lines;++ public Text(Charset charset, String content) {+ this.charset = charset;+ this.content = content;+ }++ public Charset getCharset() {+ return charset;+ }++ public String getContent() {+ return content;+ }++ public List<String> getLines() {+ if (lines == null) {+ lines = new ArrayList<>();+ StringBuilder builder = new StringBuilder();+ for (int i=0; i<content.length(); i++) {+ char ch = content.charAt(i);+ if (ch == '\n') {+ lines.add(builder.toString());+ builder = new StringBuilder();+ } else {+ builder.append(ch);+ }+ }+ if (builder.length() != 0)+ lines.add(builder.toString());+ }+ return lines;+ }++ }+}