Java tutorial
/* * Copyright 2016 OPEN TONE Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jp.co.opentone.bsol.linkbinder.dto; import jp.co.opentone.bsol.framework.core.dao.Entity; import jp.co.opentone.bsol.linkbinder.dto.UpdateMode.ModeHolder; import jp.co.opentone.bsol.linkbinder.dto.code.AttachmentFileType; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Set; /** * [v_attachment] ?1?Dto. * <p> * generated at Tue Mar 31 18:38:27 +0900 2009. * </p> * @author db2sgen * <p> */ public class Attachment extends AbstractDto implements Entity, ModeHolder { /** * SerialVersionUID. */ private static final long serialVersionUID = 8601859953723184513L; /** * ?????????. */ private static final Set<String> TO_STRING_IGNORE_FIELDS; static { Set<String> fields = new HashSet<String>(); fields.add("content"); TO_STRING_IGNORE_FIELDS = Collections.unmodifiableSet(fields); } /** . */ private UpdateMode mode; /** * Id. * <p> * [v_attachment.id] * </p> */ private Long id; /** * No. * <p> * [v_attachment.no] * </p> */ private Long no; /** * Correspon. * <p> * [v_attachment.correspon_id] * </p> */ private Long corresponId; /** * File. * <p> * [v_attachment.file_id] * </p> */ private String fileId; /** * File name. * <p> * [v_attachment.file_name] * </p> */ private String fileName; /** * file type. */ private AttachmentFileType fileType; /** * ????. */ private String orgExtractedText; /** * ???. */ private String extractedText; /** * Created by. * <p> * </p> */ private User createdBy; /** * Created at. * <p> * [v_attachment.created_at] * </p> */ private Date createdAt; /** * Updated by. * <p> * </p> */ private User updatedBy; /** * Updated at. * <p> * [v_attachment.updated_at] * </p> */ private Date updatedAt; /** * Delete no. * <p> * [v_attachment.delete_no] * </p> */ private Long deleteNo; /** * ?. */ private byte[] content; /** * ???. */ private String sourcePath; /** ???. */ public static final String[] IMAGE_EXTENSIONS = { "png", "gif", "jpg", "jpeg", "jpe", "tif", "tiff", "bmp" }; /** * ???. */ public Attachment() { } /** * ????. * @param fileName ?? * @return */ public static AttachmentFileType detectFileTypeByFileName(String fileName) { if (StringUtils.isEmpty(fileName)) { return AttachmentFileType.UNKNOWN; } String extension = FilenameUtils.getExtension(fileName); if (StringUtils.isEmpty(extension)) { return AttachmentFileType.UNKNOWN; } return ArrayUtils.contains(IMAGE_EXTENSIONS, extension.toLowerCase()) ? AttachmentFileType.IMAGE : AttachmentFileType.UNKNOWN; } /** * ??????true?. * @return ? */ public boolean isExtractedTextChanged() { return !StringUtils.equals(orgExtractedText, extractedText); } /** * id ??. * <p> * [v_attachment.id] * </p> * @return id */ public Long getId() { return id; } /** * id ??. * <p> * [v_attachment.id] * </p> * @param id * id */ public void setId(Long id) { this.id = id; } /** * no ??. * <p> * [v_attachment.no] * </p> * @return no */ public Long getNo() { return no; } /** * no ??. * <p> * [v_attachment.no] * </p> * @param no * no */ public void setNo(Long no) { this.no = no; } /** * corresponId ??. * <p> * [v_attachment.correspon_id] * </p> * @return corresponId */ public Long getCorresponId() { return corresponId; } /** * corresponId ??. * <p> * [v_attachment.correspon_id] * </p> * @param corresponId * corresponId */ public void setCorresponId(Long corresponId) { this.corresponId = corresponId; } /** * fileId ??. * <p> * [v_attachment.file_id] * </p> * @return fileId */ public String getFileId() { return fileId; } /** * fileId ??. * <p> * [v_attachment.file_id] * </p> * @param fileId * fileId */ public void setFileId(String fileId) { this.fileId = fileId; } /** * fileName ??. * <p> * [v_attachment.file_name] * </p> * @return fileName */ public String getFileName() { return fileName; } /** * fileName ??. * <p> * [v_attachment.file_name] * </p> * @param fileName * fileName */ public void setFileName(String fileName) { this.fileName = fileName; } /** * ??. * <p> * </p> * @return createdBy */ public User getCreatedBy() { return createdBy; } /** * ??. * <p> * </p> * @param createdBy * ? */ public void setCreatedBy(User createdBy) { this.createdBy = createdBy; } /** * createdAt ??. * <p> * [v_attachment.created_at] * </p> * @return createdAt */ public Date getCreatedAt() { return createdAt; } /** * createdAt ??. * <p> * [v_attachment.created_at] * </p> * @param createdAt * createdAt */ public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } /** * ?. * <p> * </p> * @return updatedBy */ public User getUpdatedBy() { return updatedBy; } /** * ?. * <p> * </p> * @param updatedBy * */ public void setUpdatedBy(User updatedBy) { this.updatedBy = updatedBy; } /** * updatedAt ??. * <p> * [v_attachment.updated_at] * </p> * @return updatedAt */ public Date getUpdatedAt() { return updatedAt; } /** * updatedAt ??. * <p> * [v_attachment.updated_at] * </p> * @param updatedAt * updatedAt */ public void setUpdatedAt(Date updatedAt) { this.updatedAt = updatedAt; } /** * deleteNo ??. * <p> * [v_attachment.delete_no] * </p> * @return deleteNo */ public Long getDeleteNo() { return deleteNo; } /** * deleteNo ??. * <p> * [v_attachment.delete_no] * </p> * @param deleteNo * deleteNo */ public void setDeleteNo(Long deleteNo) { this.deleteNo = deleteNo; } /** * ??. * @param content * ? */ public void setContent(byte[] content) { this.content = content; } /** * ???. * @return ? */ public byte[] getContent() { return content; } /** * @param mode the mode to set */ public void setMode(UpdateMode mode) { this.mode = mode; } /** * @return the mode */ public UpdateMode getMode() { return mode; } /** * @param sourcePath the sourcePath to set */ public void setSourcePath(String sourcePath) { this.sourcePath = sourcePath; } /** * @return the sourcePath */ public String getSourcePath() { return sourcePath; } /* (non-Javadoc) * @see jp.co.opentone.bsol.linkbinder.dto.AbstractDto#isToStringIgnoreField(java.lang.String) */ @Override public boolean isToStringIgnoreField(String fieldName) { return super.isToStringIgnoreField(fieldName) || TO_STRING_IGNORE_FIELDS.contains(fieldName); } /** * ?. * @return */ public AttachmentFileType getFileType() { return fileType; } /** * ?. * @param fileType */ public void setFileType(AttachmentFileType fileType) { this.fileType = fileType; } /** * ?????. * @return */ public String getOrgExtractedText() { return orgExtractedText; } /** * ?????. * @param orgExtractedText */ public void setOrgExtractedText(String orgExtractedText) { this.orgExtractedText = orgExtractedText; } /** * ????. * @return */ public String getExtractedText() { return extractedText; } /** * ????. * @param extractedText */ public void setExtractedText(String extractedText) { this.extractedText = extractedText; } }