Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.lib.meta;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import javax.xml.transform.Result;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
import org.apache.openjpa.lib.log.Log;
import org.apache.openjpa.lib.util.Files;
import org.apache.openjpa.lib.util.J2DoPrivHelper;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.lib.xml.Commentable;
import org.apache.openjpa.lib.xml.XMLWriter;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.AttributesImpl;
/**
* Abstract base type for serlializers that transfer groups of objects
* to XML. Includes a way of serializing objects back to the XML files
* they were parsed from. Serializers are not thread safe.
*
* @author Abe White
*/
public abstract class XMLMetaDataSerializer implements MetaDataSerializer {
private static final Localizer _loc = Localizer.forPackage
(XMLMetaDataSerializer.class);
private static final SAXTransformerFactory _factory =
(SAXTransformerFactory) TransformerFactory.newInstance();
private Log _log = null;
// current serialization state
private final AttributesImpl _attrs = new AttributesImpl();
private ContentHandler _handler = null;
private int _flags = 0;
private File _backup = null;
/**
* The log to write to.
*/
public Log getLog() {
return _log;
}
/**
* The log to write to.
*/
public void setLog(Log log) {
_log = log;
}
@Override
public void serialize(int flags) throws IOException {
serialize((Map) null, flags);
}
@Override
public void serialize(Map output, int flags)
throws IOException {
Map> files = getFileMap();
if (files == null)
return;
// for each file, serialize objects
for (Entry> entry : files.entrySet()) {
File file = entry.getKey();
Collection