001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.extensions.markup.html.repeater.data.table.export; 018 019import org.apache.wicket.model.IModel; 020 021/** 022 * An abstract helper implementation of {@link IDataExporter}. 023 * 024 * @author Jesse Long 025 */ 026public abstract class AbstractDataExporter implements IDataExporter 027{ 028 private IModel<String> dataFormatNameModel; 029 030 private String contentType; 031 032 private String fileNameExtension; 033 034 /** 035 * Creates a new instance with the data format name model, content type and file name extensions provided. 036 * 037 * @param dataFormatNameModel 038 * The model of the exported data format name. 039 * @param contentType 040 * The MIME content type of the exported data type. 041 * @param fileNameExtension 042 * The file name extensions to use in the file name for the exported data. 043 */ 044 public AbstractDataExporter(IModel<String> dataFormatNameModel, String contentType, String fileNameExtension) 045 { 046 this.dataFormatNameModel = dataFormatNameModel; 047 this.contentType = contentType; 048 this.fileNameExtension = fileNameExtension; 049 } 050 051 /** 052 * {@inheritDoc } 053 */ 054 @Override 055 public IModel<String> getDataFormatNameModel() 056 { 057 return dataFormatNameModel; 058 } 059 060 /** 061 * {@inheritDoc } 062 */ 063 @Override 064 public String getContentType() 065 { 066 return contentType; 067 } 068 069 /** 070 * {@inheritDoc } 071 */ 072 @Override 073 public String getFileNameExtension() 074 { 075 return fileNameExtension; 076 } 077 078 /** 079 * Sets the MIME contentType for the data export format. 080 * 081 * @param contentType 082 * The MIME contentType for the data export format. 083 * @return {@code this}, for chaining. 084 */ 085 public AbstractDataExporter setContentType(String contentType) 086 { 087 this.contentType = contentType; 088 return this; 089 } 090 091 /** 092 * Sets the data format name model. 093 * 094 * @param dataFormatNameModel 095 * the data format name model. 096 * @return {@code this}, for chaining. 097 */ 098 public AbstractDataExporter setDataFormatNameModel(IModel<String> dataFormatNameModel) 099 { 100 this.dataFormatNameModel = dataFormatNameModel; 101 return this; 102 } 103 104 /** 105 * Sets the file name extension to be used in the exported file name. 106 * 107 * @param fileNameExtension 108 * the file name extension to be used in the exported file name. 109 * @return {@code this}, for chaining. 110 */ 111 public AbstractDataExporter setFileNameExtension(String fileNameExtension) 112 { 113 this.fileNameExtension = fileNameExtension; 114 return this; 115 } 116}