Java tutorial
/* * Copyright (C) 2016 normal * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package channellistmaker.dataextractor; import java.lang.invoke.MethodHandles; import java.util.Collections; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.collections4.keyvalue.MultiKey; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; /** * ?????XML??????? * * @author dosdiaopfhj * @param <T> EPGData?? * @param <U> ?? */ public abstract class AbstractAllEPGFileExtractor<T extends EpgData, U extends AbstractEPGFileExtractor<T>> { private static final Log LOG; static { final Class<?> myClass = MethodHandles.lookup().lookupClass(); LOG = LogFactory.getLog(myClass); } private final Set<Document> EPGXMLs; /** * @param EPGXMLs ??EPG XML? */ public AbstractAllEPGFileExtractor(Set<Document> EPGXMLs) { this.EPGXMLs = EPGXMLs; } /** * XML???????getAllEPGRecords()?? * * @param doc ??XML * @return ?? */ protected abstract U getExtractor(Document doc); /** * ????XML?? getExtractor()????????????? * * @return ??? */ public final synchronized Map<MultiKey<Integer>, T> getAllEPGRecords() { Map<MultiKey<Integer>, T> temp1 = new ConcurrentHashMap<>(); LOG.info("XML? = " + this.EPGXMLs.size()); for (Document D : this.EPGXMLs) { Map<MultiKey<Integer>, T> temp2; temp2 = this.getExtractor(D).makeMap(); temp1.putAll(temp2); } return Collections.unmodifiableMap(temp1); } }