001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Thomas Roger 018 */ 019 020package org.nuxeo.ecm.csv.core; 021 022import org.nuxeo.common.utils.i18n.I18NUtils; 023 024import java.io.Serializable; 025import java.util.Locale; 026 027/** 028 * @author <a href="mailto:[email protected]">Thomas Roger</a> 029 * @since 5.7 030 */ 031public class CSVImportLog implements Serializable { 032 033 private static final long serialVersionUID = 1L; 034 035 public enum Status { 036 SUCCESS, SKIPPED, ERROR 037 } 038 039 protected final long line; 040 041 protected final Status status; 042 043 protected final String message; 044 045 protected final String localizedMessage; 046 047 protected final String[] params; 048 049 public CSVImportLog(long line, Status status, String message, String localizedMessage, String... params) { 050 this.line = line; 051 this.status = status; 052 this.message = message; 053 this.localizedMessage = localizedMessage; 054 this.params = params; 055 } 056 057 public long getLine() { 058 return line; 059 } 060 061 public Status getStatus() { 062 return status; 063 } 064 065 public String getMessage() { 066 return message; 067 } 068 069 public String getLocalizedMessage() { 070 return localizedMessage; 071 } 072 073 public Object[] getLocalizedMessageParams() { 074 return params; 075 } 076 077 public String getI18nMessage(Locale locale) { 078 return I18NUtils.getMessageString("messages", getLocalizedMessage(), getLocalizedMessageParams(), locale); 079 } 080 081 public String getI18nMessage() { 082 return getI18nMessage(Locale.ENGLISH); 083 } 084 085 public boolean isSuccess() { 086 return status == Status.SUCCESS; 087 } 088 089 public boolean isSkipped() { 090 return status == Status.SKIPPED; 091 } 092 093 public boolean isError() { 094 return status == Status.ERROR; 095 } 096 097}