001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: https://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: https://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.search.documents; 029 030/** 031 * Base class for all document factories that allow to configure if meta data should be extracted or ignored. 032 */ 033public abstract class A_CmsVfsDocumentWithMetaData extends A_CmsVfsDocument { 034 035 /** Parameter key for configuring if meta data should be extracted or not. */ 036 public static final String PARAM_EXTRACT_METADATA = "extract.metadata"; 037 038 /** Flag, indicating if metadata should be extracted. */ 039 private boolean m_extractMetaData; 040 041 /** 042 * Creates a new instance of this document factory.<p> 043 * 044 * @param name name of the documenttype 045 */ 046 public A_CmsVfsDocumentWithMetaData(String name) { 047 048 this(name, true); 049 } 050 051 /** 052 * Creates a new instance of this document factory.<p> 053 * 054 * @param name name of the documenttype 055 * @param extractMetaDataByDefault flag, indicating if meta data should be extracted by default. 056 */ 057 public A_CmsVfsDocumentWithMetaData(String name, boolean extractMetaDataByDefault) { 058 059 super(name); 060 m_extractMetaData = extractMetaDataByDefault; 061 } 062 063 /** 064 * @see org.opencms.search.documents.I_CmsDocumentFactory#addConfigurationParameter(java.lang.String, java.lang.String) 065 */ 066 @Override 067 public void addConfigurationParameter(String key, String value) { 068 069 switch (key) { 070 case PARAM_EXTRACT_METADATA: 071 m_extractMetaData = !"false".equalsIgnoreCase(value); 072 break; 073 default: 074 // do nothing; 075 } 076 } 077 078 /** 079 * @return flag, indicating if meta data should be extracted. 080 */ 081 public boolean isExtractMetaData() { 082 083 return m_extractMetaData; 084 } 085}