Java tutorial
/******************************************************************************* * Copyright (c) 2005, 2014 springside.github.io * * Licensed under the Apache License, Version 2.0 (the "License"); *******************************************************************************/ package org.springside.examples.oadata.entity; import java.util.Date; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; import org.apache.commons.lang3.StringUtils; /** * identity. * * id?????????. * Oracle??EntityidSEQUCENCE?Idable? * * @author calvin */ // JPA @Entity @Table(name = "view_oa_service_announcementdoc") public class BulletinDocView { protected Long attachmentId; protected String projectId; private String attachmentName; private Date uploadDate; private String attachmentPath; @Id public Long getAttachmentId() { return attachmentId; } public void setAttachmentId(Long attachmentId) { this.attachmentId = attachmentId; } public String getProjectId() { return projectId; } public void setProjectId(String projectId) { this.projectId = projectId; } public String getAttachmentName() { return attachmentName; } public void setAttachmentName(String attachmentName) { this.attachmentName = attachmentName; } public Date getUploadDate() { return uploadDate; } public void setUploadDate(Date uploadDate) { this.uploadDate = uploadDate; } public String getAttachmentPath() { return attachmentPath; } @Transient public String getAttachmentPathShort() { return StringUtils.substring(attachmentPath, findFirstGBK(attachmentPath), attachmentPath.length()); } public void setAttachmentPath(String attachmentPath) { this.attachmentPath = attachmentPath; } public int findFirstGBK(String content) { int position = 0; // Unicode? String s = content; // for (int index = 0; index <= s.length() - 1; index++) { // ?? String w = s.substring(index, index + 1); if (w.compareTo("\u4e00") > 0 && w.compareTo("\u9fa5") < 0) {// \u4e00-\u9fa5// // position = index; break; } } return position; } }