org.netbeans.upgrade.systemoptions.SerParser Maven / Gradle / Ivy
The newest version!
/*
* 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.netbeans.upgrade.systemoptions;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import org.openide.util.NotImplementedException;
/* The following may be useful to Emacs users:
(defun comma-sep-decimal-encode ()
(interactive)
(while
(let ((p (point)))
(and (re-search-forward "\\(-?[0-9][0-9]?[0-9]?\\),?" nil t)
(= p (match-beginning 0))))
(replace-match (char-to-string
(let ((x (string-to-int (match-string 1))))
(when (< x 0) (setq x (+ x 256)))
x))
t t)))
After evaluating this, go into an old cpanel.xml or similar
(M-x find-file-literally, by the way) and type
M-x comma-sep-decimal-encode right after the opening quote
of the value. The contents will be converted to raw binary and
may be saved as a .ser file parsable by this class.
(defun hex-encode ()
(interactive)
(while
(let ((p (point)))
(and (re-search-forward "\\s-*\\([a-fA-F0-9][a-fA-F0-9]\\)" nil t)
(= p (match-beginning 0))))
(replace-match (char-to-string
(string-to-int (match-string 1) 16))
t t)))
Same for hexadecimal serialized data. For .settings files, it is
easier to select Customize Bean... in the IDE and save as *.ser.
*/
/** Parser for Java serialization files.
* Does no classloading or per-class semantics, simply parses the
* raw serialization structure.
* @author Jesse Glick
*/
public final class SerParser implements ObjectStreamConstants {
private static final boolean DEBUG = Boolean.getBoolean("org.netbeans.modules.clazz.SerParser.DEBUG"); // NOI18N
private final InputStream is;
private int seq = 0;
private final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy