dengsixing vor 6 Monaten
Ursprung
Commit
f888104d43

+ 6 - 0
src/main/java/com/fdkankan/common/util/WebUtil.java

@@ -106,4 +106,10 @@ public class WebUtil {
         return  String.format(browserFormat, browserType, browserVersion);
     }
 
+    public static <T> T getParameter(JoinPoint pjp, HttpServletRequest request, String paramName, Class<T> clazz){
+        Map<String, Object> parameter = getParameter(pjp, request);
+        Object o = parameter.get(paramName);
+        return clazz.cast(o);
+    }
+
 }

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 4631
src/main/java/com/fdkankan/model/proto/Common.java


+ 0 - 156
src/main/java/com/fdkankan/model/proto/format/CouchDBFormat.java

@@ -1,156 +0,0 @@
-package com.fdkankan.model.proto.format;
-
-
-import com.google.protobuf.ExtensionRegistry;
-import com.google.protobuf.Message;
-import com.google.protobuf.UnknownFieldSet;
-
-import java.io.IOException;
-
-/**
- * Created by IntelliJ IDEA.
- * User: aantonov
- * Date: Mar 16, 2010
- * Time: 4:06:05 PM
- * To change this template use File | Settings | File Templates.
- */
-public class CouchDBFormat extends JsonFormat {
-
-    /**
-     * Outputs a textual representation of the Protocol Message supplied into the parameter output.
-     * (This representation is the new version of the classic "ProtocolPrinter" output from the
-     * original Protocol Buffer system)
-     */
-    public static void print(Message message, Appendable output) throws IOException {
-        CouchDBGenerator generator = new CouchDBGenerator(output);
-        generator.print("{");
-        print(message, generator);
-        generator.print("}");
-    }
-
-    /**
-     * Outputs a textual representation of {@code fields} to {@code output}.
-     */
-    public static void print(UnknownFieldSet fields, Appendable output) throws IOException {
-        CouchDBGenerator generator = new CouchDBGenerator(output);
-        generator.print("{");
-        printUnknownFields(fields, generator);
-        generator.print("}");
-    }
-
-    /**
-     * Like {@code print()}, but writes directly to a {@code String} and returns it.
-     */
-    public static String printToString(Message message) {
-        try {
-            StringBuilder text = new StringBuilder();
-            print(message, text);
-            return text.toString();
-        } catch (IOException e) {
-            throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never happen).",
-                                       e);
-        }
-    }
-
-    /**
-     * Like {@code print()}, but writes directly to a {@code String} and returns it.
-     */
-    public static String printToString(UnknownFieldSet fields) {
-        try {
-            StringBuilder text = new StringBuilder();
-            print(fields, text);
-            return text.toString();
-        } catch (IOException e) {
-            throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never happen).",
-                                       e);
-        }
-    }
-
-    /**
-     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
-     */
-    public static void merge(Readable input, Message.Builder builder) throws IOException {
-        merge(input, ExtensionRegistry.getEmptyRegistry(), builder);
-    }
-
-    /**
-     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
-     */
-    public static void merge(CharSequence input, Message.Builder builder) throws ParseException {
-        merge(input, ExtensionRegistry.getEmptyRegistry(), builder);
-    }
-
-    /**
-     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
-     * Extensions will be recognized if they are registered in {@code extensionRegistry}.
-     */
-    public static void merge(Readable input,
-                             ExtensionRegistry extensionRegistry,
-                             Message.Builder builder) throws IOException {
-        // Read the entire input to a String then parse that.
-
-        // If StreamTokenizer were not quite so crippled, or if there were a kind
-        // of Reader that could read in chunks that match some particular regex,
-        // or if we wanted to write a custom Reader to tokenize our stream, then
-        // we would not have to read to one big String. Alas, none of these is
-        // the case. Oh well.
-
-        merge(toStringBuilder(input), extensionRegistry, builder);
-    }
-
-    /**
-     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
-     * Extensions will be recognized if they are registered in {@code extensionRegistry}.
-     */
-    public static void merge(CharSequence input,
-                             ExtensionRegistry extensionRegistry,
-                             Message.Builder builder) throws ParseException {
-        Tokenizer tokenizer = new Tokenizer(input);
-
-        // Based on the state machine @ http://json.org/
-
-        tokenizer.consume("{"); // Needs to happen when the object starts.
-        while (!tokenizer.tryConsume("}")) { // Continue till the object is done
-            mergeField(tokenizer, extensionRegistry, builder);
-        }
-    }
-
-    protected static class Tokenizer extends JsonFormat.Tokenizer {
-
-        /**
-         * Construct a tokenizer that parses tokens from the given text.
-         */
-        public Tokenizer(CharSequence text) {
-            super(text);
-        }
-
-        @Override
-        public String consumeIdentifier() throws ParseException {
-            String id = super.consumeIdentifier();
-            if ("_id".equals(id)) {
-                return "id";
-            } else if ("_rev".equals(id)) {
-                return "rev";
-            }
-            return id;
-        }
-    }
-
-    protected static class CouchDBGenerator extends JsonGenerator {
-
-        public CouchDBGenerator(Appendable output) {
-            super(output);
-        }
-
-        @Override
-        public void print(CharSequence text) throws IOException {
-            if ("id".equals(text)) {
-                super.print("_id");
-            } else if ("rev".equals(text)) {
-                super.print("_rev");
-            } else {
-                super.print(text);
-            }
-        }
-    }
-}

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 1338
src/main/java/com/fdkankan/model/proto/format/JavaPropsFormat.java


+ 0 - 602
src/main/java/com/fdkankan/model/proto/format/SmileFormat.java

@@ -1,602 +0,0 @@
-//package com.fdkankan.model.proto.format;
-///*
-//	Copyright (c) 2009, Orbitz World Wide
-//	All rights reserved.
-//
-//	Redistribution and use in source and binary forms, with or without modification,
-//	are permitted provided that the following conditions are met:
-//
-//		* Redistributions of source code must retain the above copyright notice,
-//		  this list of conditions and the following disclaimer.
-//		* Redistributions in binary form must reproduce the above copyright notice,
-//		  this list of conditions and the following disclaimer in the documentation
-//		  and/or other materials provided with the distribution.
-//		* Neither the name of the Orbitz World Wide nor the names of its contributors
-//		  may be used to endorse or promote products derived from this software
-//		  without specific prior written permission.
-//
-//	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//	LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-//	A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-//	OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-//	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-//	LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-//	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-//	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-//	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-//	OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//*/
-//
-//
-//import com.google.protobuf.*;
-//import com.google.protobuf.Descriptors.Descriptor;
-//import com.google.protobuf.Descriptors.EnumDescriptor;
-//import com.google.protobuf.Descriptors.EnumValueDescriptor;
-//import com.google.protobuf.Descriptors.FieldDescriptor;
-//import org.codehaus.jackson.JsonGenerator;
-//import org.codehaus.jackson.JsonParseException;
-//import org.codehaus.jackson.JsonParser;
-//import org.codehaus.jackson.JsonToken;
-//import org.codehaus.jackson.smile.SmileFactory;
-//import org.codehaus.jackson.smile.SmileGenerator;
-//import org.codehaus.jackson.smile.SmileParser;
-//
-//import java.io.IOException;
-//import java.io.InputStream;
-//import java.io.OutputStream;
-//import java.math.BigInteger;
-//import java.util.Iterator;
-//import java.util.List;
-//import java.util.Locale;
-//import java.util.Map;
-//import java.util.regex.Pattern;
-//
-///**
-// * Provide ascii text parsing and formatting support for proto2 instances. The implementation
-// * largely follows google/protobuf/text_format.cc.
-// * <p>
-// * (c) 2011 Neustar, Inc. All Rights Reserved.
-// *
-// * @author jeffrey.damick@neustar.biz Jeffrey Damick
-// *         Based on the original code by:
-// * @author eliran.bivas@gmail.com Eliran Bivas
-// * @author aantonov@orbitz.com Alex Antonov
-// *         <p/>
-// * @author wenboz@google.com Wenbo Zhu
-// * @author kenton@google.com Kenton Varda
-// */
-//public class SmileFormat {
-//    private static SmileFactory smileFactory = new SmileFactory();
-//
-//
-//    /**
-//     * Outputs a Smile representation of the Protocol Message supplied into the parameter output.
-//     * (This representation is the new version of the classic "ProtocolPrinter" output from the
-//     * original Protocol Buffer system)
-//     */
-//    public static void print(Message message, OutputStream output) throws IOException {
-//        JsonGenerator generator = createGenerator(output);
-//    	print(message, generator);
-//    	generator.close();
-//    }
-//
-//    /**
-//     * Outputs a Smile representation of the Protocol Message supplied into the parameter output.
-//     * (This representation is the new version of the classic "ProtocolPrinter" output from the
-//     * original Protocol Buffer system)
-//     */
-//    public static void print(Message message, JsonGenerator generator) throws IOException {
-//    	generator.writeStartObject();
-//    	printMessage(message, generator);
-//        generator.writeEndObject();
-//        generator.flush();
-//    }
-//
-//    /**
-//     * Outputs a Smile representation of {@code fields} to {@code output}.
-//     */
-//    public static void print(UnknownFieldSet fields, OutputStream output) throws IOException {
-//    	JsonGenerator generator = createGenerator(output);
-//    	generator.writeStartObject();
-//    	printUnknownFields(fields, generator);
-//        generator.writeEndObject();
-//        generator.close();
-//    }
-//
-//
-//
-//    /**
-//     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
-//     */
-//    public static void merge(InputStream input, Message.Builder builder) throws IOException {
-//        merge(input, ExtensionRegistry.getEmptyRegistry(), builder);
-//    }
-//
-//
-//    /**
-//     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
-//     * Extensions will be recognized if they are registered in {@code extensionRegistry}.
-//     * @throws IOException
-//     */
-//    public static void merge(InputStream input,
-//                             ExtensionRegistry extensionRegistry,
-//                             Message.Builder builder) throws IOException {
-//
-//    	SmileParser parser = smileFactory.createJsonParser(input);
-//    	merge(parser, extensionRegistry, builder);
-//    }
-//
-//    /**
-//     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
-//     * Extensions will be recognized if they are registered in {@code extensionRegistry}.
-//     * @throws IOException
-//     */
-//    public static void merge(JsonParser parser,
-//    						 ExtensionRegistry extensionRegistry,
-//                             Message.Builder builder) throws IOException {
-//
-//        JsonToken token = parser.nextToken();
-//        if (token.equals(JsonToken.START_OBJECT)) {
-//        	token = parser.nextToken();
-//        }
-//        while (token != null && !token.equals(JsonToken.END_OBJECT)) {
-//        	mergeField(parser, extensionRegistry, builder);
-//        	token = parser.nextToken();
-//        }
-//
-//        // Test to make sure the tokenizer has reached the end of the stream.
-//        if (parser.nextToken() != null) {
-//            throw new RuntimeException("Expecting the end of the stream, but there seems to be more data!  Check the input for a valid JSON format.");
-//        }
-//    }
-//
-//
-//
-//    protected static JsonGenerator createGenerator(OutputStream output) throws IOException {
-//    	SmileGenerator generator = smileFactory.createJsonGenerator(output);
-//    	generator.enable(SmileGenerator.Feature.WRITE_HEADER);
-//    	generator.enable(SmileGenerator.Feature.WRITE_END_MARKER);
-//    	return generator;
-//    }
-//
-//
-//    protected static void printMessage(Message message, JsonGenerator generator) throws IOException {
-//
-//        for (Iterator<Map.Entry<FieldDescriptor, Object>> iter = message.getAllFields().entrySet().iterator(); iter.hasNext();) {
-//            Map.Entry<FieldDescriptor, Object> field = iter.next();
-//            printField(field.getKey(), field.getValue(), generator);
-//        }
-//        printUnknownFields(message.getUnknownFields(), generator);
-//    }
-//
-//    public static void printField(FieldDescriptor field, Object value, JsonGenerator generator) throws IOException {
-//
-//        printSingleField(field, value, generator);
-//    }
-//
-//    private static void printSingleField(FieldDescriptor field,
-//                                         Object value,
-//                                         JsonGenerator generator) throws IOException {
-//        if (field.isExtension()) {
-//            // We special-case MessageSet elements for compatibility with proto1.
-//            if (field.getContainingType().getOptions().getMessageSetWireFormat()
-//                && (field.getType() == FieldDescriptor.Type.MESSAGE) && (field.isOptional())
-//                // object equality
-//                && (field.getExtensionScope() == field.getMessageType())) {
-//                generator.writeFieldName(field.getMessageType().getFullName());
-//            } else {
-//            	// extensions will have '.' in them, while normal fields wont..
-//            	generator.writeFieldName(field.getFullName());
-//            }
-//        } else {
-//            if (field.getType() == FieldDescriptor.Type.GROUP) {
-//                // Groups must be serialized with their original capitalization.
-//                generator.writeFieldName(field.getMessageType().getName());
-//            } else {
-//                generator.writeFieldName(field.getName());
-//            }
-//        }
-//
-//        // Done with the name, on to the value
-//        if (field.isRepeated()) {
-//            // Repeated field. Print each element.
-//            generator.writeStartArray();
-//            for (Iterator<?> iter = ((List<?>) value).iterator(); iter.hasNext();) {
-//                printFieldValue(field, iter.next(), generator);
-//            }
-//            generator.writeEndArray();
-//        } else {
-//            printFieldValue(field, value, generator);
-//        }
-//    }
-//
-//    private static void printFieldValue(FieldDescriptor field, Object value, JsonGenerator generator) throws IOException {
-//    	// TODO: look at using field.getType().getJavaType(), to simplify this..
-//    	switch (field.getType()) {
-//            case INT32:
-//            case SINT32:
-//            case SFIXED32:
-//            	generator.writeNumber((Integer)value);
-//            	break;
-//
-//            case INT64:
-//            case SINT64:
-//            case SFIXED64:
-//            	generator.writeNumber((Long)value);
-//            	break;
-//
-//            case FLOAT:
-//            	generator.writeNumber((Float)value);
-//            	break;
-//
-//            case DOUBLE:
-//            	generator.writeNumber((Double)value);
-//            	break;
-//
-//            case BOOL:
-//                // Good old toString() does what we want for these types.
-//                generator.writeBoolean((Boolean)value);
-//                break;
-//
-//            case UINT32:
-//            case FIXED32:
-//                generator.writeNumber(unsignedInt((Integer) value));
-//                break;
-//
-//            case UINT64:
-//            case FIXED64:
-//                generator.writeNumber(unsignedLong((Long) value));
-//                break;
-//
-//            case STRING:
-//            	generator.writeString((String) value);
-//                break;
-//
-//            case BYTES: {
-//            	// Here we break with JsonFormat - since there is an issue with non-utf8 bytes..
-//            	generator.writeBinary(((ByteString)value).toByteArray());
-//                break;
-//            }
-//
-//            case ENUM: {
-//            	generator.writeString(((EnumValueDescriptor) value).getName());
-//                break;
-//            }
-//
-//            case MESSAGE:
-//            case GROUP:
-//            	generator.writeStartObject();
-//                printMessage((Message) value, generator);
-//                generator.writeEndObject();
-//                break;
-//        }
-//    }
-//
-//    protected static void printUnknownFields(UnknownFieldSet unknownFields, JsonGenerator generator) throws IOException {
-//        for (Map.Entry<Integer, UnknownFieldSet.Field> entry : unknownFields.asMap().entrySet()) {
-//            UnknownFieldSet.Field field = entry.getValue();
-//
-//            generator.writeArrayFieldStart(entry.getKey().toString());
-//            for (long value : field.getVarintList()) {
-//                generator.writeNumber(value);
-//            }
-//            for (int value : field.getFixed32List()) {
-//                generator.writeNumber(value);
-//            }
-//            for (long value : field.getFixed64List()) {
-//                generator.writeNumber(value);
-//            }
-//            for (ByteString value : field.getLengthDelimitedList()) {
-//            	// here we break with the JsonFormat to support non-utf8 bytes
-//            	generator.writeBinary(value.toByteArray());
-//            }
-//            for (UnknownFieldSet value : field.getGroupList()) {
-//                generator.writeStartObject();
-//                printUnknownFields(value, generator);
-//                generator.writeEndObject();
-//            }
-//            generator.writeEndArray();
-//        }
-//    }
-//
-//
-//
-//    // =================================================================
-//    // Parsing
-//
-//    private static final Pattern DIGITS = Pattern.compile(
-//          "[0-9]",
-//          Pattern.CASE_INSENSITIVE);
-//
-//    /**
-//     * Parse a single field from {@code parser} and merge it into {@code builder}. If a ',' is
-//     * detected after the field ends, the next field will be parsed automatically
-//     * @throws IOException
-//     * @throws JsonParseException
-//     */
-//    protected static void mergeField(JsonParser parser,
-//                                   ExtensionRegistry extensionRegistry,
-//                                   Message.Builder builder) throws JsonParseException, IOException {
-//        FieldDescriptor field = null;
-//        Descriptor type = builder.getDescriptorForType();
-//        boolean unknown = false;
-//        ExtensionRegistry.ExtensionInfo extension = null;
-//        JsonToken token = parser.getCurrentToken();
-//
-//        if (token != null) {
-//            String name = parser.getCurrentName();
-//
-//            if (name.contains(".")) {
-//            	// should be an extension
-//            	extension = extensionRegistry.findExtensionByName(name);
-//                if (extension == null) {
-//                    throw new RuntimeException("Extension \""
-//                    		+ name + "\" not found in the ExtensionRegistry.");
-//                } else if (extension.descriptor.getContainingType() != type) {
-//                    throw new RuntimeException("Extension \"" + name
-//                    		+ "\" does not extend message type \""
-//                    		+ type.getFullName() + "\".");
-//                }
-//
-//            	field = extension.descriptor;
-//            } else {
-//            	field = type.findFieldByName(name);
-//            }
-//
-//            // Group names are expected to be capitalized as they appear in the
-//            // .proto file, which actually matches their type names, not their field
-//            // names.
-//            if (field == null) {
-//                // Explicitly specify US locale so that this code does not break when
-//                // executing in Turkey.
-//                String lowerName = name.toLowerCase(Locale.US);
-//                field = type.findFieldByName(lowerName);
-//                // If the case-insensitive match worked but the field is NOT a group,
-//                if ((field != null) && (field.getType() != FieldDescriptor.Type.GROUP)) {
-//                    field = null;
-//                }
-//            }
-//            // Again, special-case group names as described above.
-//            if ((field != null) && (field.getType() == FieldDescriptor.Type.GROUP)
-//                && !field.getMessageType().getName().equals(name)
-//                && !field.getMessageType().getFullName().equalsIgnoreCase(name) /* extension */) {
-//                field = null;
-//            }
-//
-//            // Last try to lookup by field-index if 'name' is numeric,
-//            // which indicates a possible unknown field
-//            if (field == null && DIGITS.matcher(name).matches()) {
-//                field = type.findFieldByNumber(Integer.parseInt(name));
-//                unknown = true;
-//            }
-//
-//            // no throwing exceptions if field not found, since it could be a different version.
-//            if (field == null) {
-//            	UnknownFieldSet.Builder unknownsBuilder = UnknownFieldSet.newBuilder();
-//            	handleMissingField(name, parser, extensionRegistry, unknownsBuilder);
-//            	builder.setUnknownFields(unknownsBuilder.build());
-//            }
-//        }
-//
-//        if (field != null) {
-//        	token = parser.nextToken();
-//
-//            boolean array = token.equals(JsonToken.START_ARRAY);
-//
-//            if (array) {
-//            	token = parser.nextToken();
-//                while (!token.equals(JsonToken.END_ARRAY)) {
-//                    handleValue(parser, extensionRegistry, builder, field, extension, unknown);
-//                    token = parser.nextToken();
-//                }
-//            } else {
-//                handleValue(parser, extensionRegistry, builder, field, extension, unknown);
-//            }
-//        }
-//    }
-//
-//    private static void handleMissingField(String fieldName, JsonParser parser,
-//                                           ExtensionRegistry extensionRegistry,
-//                                           UnknownFieldSet.Builder builder) throws IOException {
-//
-//        JsonToken token = parser.nextToken();
-//        if (token.equals(JsonToken.START_OBJECT)) {
-//            // Message structure
-//        	token = parser.nextToken(); // skip name
-//        	while (token != null && !token.equals(JsonToken.END_OBJECT)) {
-//                handleMissingField(fieldName, parser, extensionRegistry, builder);
-//                token = parser.nextToken(); // get } or field name
-//            }
-//        } else if (token.equals(JsonToken.START_ARRAY)) {
-//            // Collection
-//            do {
-//                handleMissingField(fieldName, parser, extensionRegistry, builder);
-//                token = parser.getCurrentToken(); // got value or ]
-//            } while (token != null && !token.equals(JsonToken.END_ARRAY));
-//        } else {
-//            // Primitive value
-//        	// NULL, INT, BOOL, STRING
-//        	// nothing to do..
-//        }
-//    }
-//
-//    private static void handleValue(JsonParser parser,
-//                                    ExtensionRegistry extensionRegistry,
-//                                    Message.Builder builder,
-//                                    FieldDescriptor field,
-//                                    ExtensionRegistry.ExtensionInfo extension,
-//                                    boolean unknown) throws IOException {
-//
-//        Object value = null;
-//        if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
-//            value = handleObject(parser, extensionRegistry, builder, field, extension, unknown);
-//        } else {
-//            value = handlePrimitive(parser, field);
-//        }
-//        if (value != null) {
-//            if (field.isRepeated()) {
-//                builder.addRepeatedField(field, value);
-//            } else {
-//                builder.setField(field, value);
-//            }
-//        }
-//    }
-//
-//    private static Object handlePrimitive(JsonParser parser, FieldDescriptor field) throws IOException {
-//        Object value = null;
-//
-//        JsonToken token = parser.getCurrentToken();
-//
-//        if (token.equals(JsonToken.VALUE_NULL)) {
-//            return value;
-//        }
-//
-//        switch (field.getType()) {
-//            case INT32:
-//            case SINT32:
-//            case SFIXED32:
-//            	value = parser.getIntValue();
-//                break;
-//
-//            case INT64:
-//            case SINT64:
-//            case SFIXED64:
-//            	value = parser.getLongValue();
-//                break;
-//
-//            case UINT32:
-//            case FIXED32:
-//            	int valueInt = parser.getIntValue();
-//            	if (valueInt < 0) {
-//            		throw new NumberFormatException("Number must be positive: " + valueInt);
-//            	}
-//            	value = valueInt;
-//                break;
-//
-//            case UINT64:
-//            case FIXED64:
-//            	long valueLong = parser.getLongValue();
-//            	if (valueLong < 0) {
-//            		throw new NumberFormatException("Number must be positive: " + valueLong);
-//            	}
-//            	value = valueLong;
-//                break;
-//
-//            case FLOAT:
-//            	value = parser.getFloatValue();
-//                break;
-//
-//            case DOUBLE:
-//            	value = parser.getDoubleValue();
-//                break;
-//
-//            case BOOL:
-//            	value = parser.getBooleanValue();
-//                break;
-//
-//            case STRING:
-//            	value = parser.getText();
-//                break;
-//
-//            case BYTES:
-//            	value = ByteString.copyFrom(parser.getBinaryValue());
-//                break;
-//
-//            case ENUM: {
-//                EnumDescriptor enumType = field.getEnumType();
-//                if (token.equals(JsonToken.VALUE_NUMBER_INT)) {
-//                    int number = parser.getIntValue();
-//                    value = enumType.findValueByNumber(number);
-//                    if (value == null) {
-//                        throw new RuntimeException("Enum type \""
-//                        		+ enumType.getFullName()
-//                        		+ "\" has no value with number "
-//                        		+ number + ".");
-//                    }
-//                } else {
-//                    String id = parser.getText();
-//                    value = enumType.findValueByName(id);
-//                    if (value == null) {
-//                    	throw new RuntimeException("Enum type \""
-//                    			+ enumType.getFullName()
-//                    			+ "\" has no value named \""
-//                    			+ id + "\".");
-//                    }
-//                }
-//                break;
-//            }
-//
-//            case MESSAGE:
-//            case GROUP:
-//                throw new RuntimeException("Can't get here.");
-//        }
-//        return value;
-//    }
-//
-//
-//    private static Object handleObject(JsonParser parser,
-//                                       ExtensionRegistry extensionRegistry,
-//                                       Message.Builder builder,
-//                                       FieldDescriptor field,
-//                                       ExtensionRegistry.ExtensionInfo extension,
-//                                       boolean unknown) throws IOException {
-//
-//        Message.Builder subBuilder;
-//        if (extension == null) {
-//            subBuilder = builder.newBuilderForField(field);
-//        } else {
-//            subBuilder = extension.defaultInstance.newBuilderForType();
-//        }
-//
-//        JsonToken token = parser.getCurrentToken();
-//
-//        if (unknown) {
-//        	ByteString data = ByteString.copyFrom(parser.getBinaryValue());
-//            try {
-//                subBuilder.mergeFrom(data);
-//                return subBuilder.build();
-//            } catch (InvalidProtocolBufferException e) {
-//                throw new RuntimeException("Failed to build " + field.getFullName() + " from " + data);
-//            }
-//        }
-//
-//        //token = parser.nextToken();
-//        if (token.equals(JsonToken.START_OBJECT)) {
-//	        token = parser.nextToken();
-//	        while (token != null && !token.equals(JsonToken.END_OBJECT)) {
-//	            mergeField(parser, extensionRegistry, subBuilder);
-//	            token = parser.nextToken();
-//	        }
-//        }
-//        return subBuilder.build();
-//    }
-//
-//    // =================================================================
-//    // Utility functions
-//    //
-//    // Some of these methods are package-private because Descriptors.java uses
-//    // them.
-//
-//    /**
-//     * Convert an unsigned 32-bit integer to a string.
-//     */
-//    private static Integer unsignedInt(int value) {
-//        if (value < 0) {
-//            return (int) ((value) & 0x00000000FFFFFFFFL);
-//        }
-//        return value;
-//    }
-//
-//    /**
-//     * Convert an unsigned 64-bit integer to a string.
-//     */
-//    private static Long unsignedLong(long value) {
-//        if (value < 0) {
-//            // Pull off the most-significant bit so that BigInteger doesn't think
-//            // the number is negative, then set it again using setBit().
-//            return BigInteger.valueOf(value & 0x7FFFFFFFFFFFFFFFL).setBit(63).longValue();
-//        }
-//        return value;
-//    }
-//}

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 1333
src/main/java/com/fdkankan/model/proto/format/XmlFormat.java


+ 27 - 32
src/main/java/com/fdkankan/model/utils/ConvertUtils.java

@@ -17,6 +17,7 @@ public class ConvertUtils {
 
     private final static String visibles_3 = "visibles3";
 
+    // 将文本文件转换为VisionModelData格式
     public static void convertTxtToVisionModelData(String srcPath, String desPath) throws Exception {
         BufferedOutputStream bos = null;
         BufferedInputStream bis = null;
@@ -26,9 +27,9 @@ public class ConvertUtils {
             JsonFormat.merge(jsonFormat, builder);
             byte[] buf = builder.build().toByteArray();
 
-            //把序列化后的数据写入本地磁盘
+            // 把序列化后的数据写入本地磁盘
             ByteArrayInputStream stream = new ByteArrayInputStream(buf);
-            bos = new BufferedOutputStream(new FileOutputStream(desPath));//设置输出路径
+            bos = new BufferedOutputStream(new FileOutputStream(desPath)); // 设置输出路径
             bis = new BufferedInputStream(stream);
             int b = -1;
             while ((b = bis.read()) != -1) {
@@ -50,6 +51,7 @@ public class ConvertUtils {
         }
     }
 
+    // 读取文本文件并转换为JSON字符串
     public static String readTxtFileToJson(String filePath) {
         try {
             String encoding = "UTF-8";
@@ -74,14 +76,13 @@ public class ConvertUtils {
         }
     }
 
-
+    // 笛卡尔积算法
     public List<List<String>> descartes(List<List<String>> dimValue) {
         List<List<String>> res = new ArrayList<>();
         if (dimValue == null || dimValue.size() == 0)
             return res;
         backtrace(dimValue, 0, res, new ArrayList<>());
         return res;
-
     }
 
     /**
@@ -106,65 +107,60 @@ public class ConvertUtils {
 
     }
 
-    public static void convertVisionmodeldataToTxt(String srcpath,String despath)throws Exception
-    {
-        try
-        {
+    // 将VisionModelData格式转换为文本文件
+    public static void convertVisionmodeldataToTxt(String srcpath, String despath) throws Exception {
+        try {
             File file = new File(srcpath);
-            FileInputStream fis=new FileInputStream(file);
+            FileInputStream fis = new FileInputStream(file);
 
             Visionmodeldata.NavigationInfo data_NavigationInfo = Visionmodeldata.NavigationInfo.parseFrom(fis);
 
-            //PrintStream out = new PrintStream(despath);
             String jsonFormat1 = JsonFormat.printToString(data_NavigationInfo);
             ByteArrayInputStream stream = new ByteArrayInputStream(jsonFormat1.getBytes());
-            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
+            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath)); // 设置输出路径
             BufferedInputStream bis = new BufferedInputStream(stream);
             int b = -1;
             while ((b = bis.read()) != -1) {
                 bos.write(b);
             }
-            //out.close();
             bis.close();
             bos.close();
-        }
-        catch(Exception e)
-        {
-            StringWriter trace=new StringWriter();
+        } catch (Exception e) {
+            StringWriter trace = new StringWriter();
             e.printStackTrace(new PrintWriter(trace));
             log.error(trace.toString());
         }
     }
 
-    public static String transferVisionUuidToIndex(String srcPath){
+    // 将Vision UUID转换为索引
+    public static String transferVisionUuidToIndex(String srcPath) {
         String visionJsonStr = readTxtFileToJson(srcPath);
         JSONObject visionJson = JSON.parseObject(visionJsonStr);
         JSONArray sweepLocationArr = visionJson.getJSONArray("sweepLocations");
         Map<String, Integer> uuidIndexMap = new HashMap<>();
         for (int i = 0; i < sweepLocationArr.size(); i++) {
-            JSONObject sweepLocationObj = (JSONObject)sweepLocationArr.get(i);
+            JSONObject sweepLocationObj = (JSONObject) sweepLocationArr.get(i);
             uuidIndexMap.put(sweepLocationObj.getString("uuid"), i);
         }
         for (Object o : sweepLocationArr) {
-            JSONObject sweepLocationObj = (JSONObject)o;
-            JSONArray visibles =  sweepLocationObj.getJSONArray("visibles");
-//			int[] visiblesArr = new int[visibles.size()];
+            JSONObject sweepLocationObj = (JSONObject) o;
+            JSONArray visibles = sweepLocationObj.getJSONArray("visibles");
             List<Integer> visiblesList = new ArrayList<>();
-            for(int i = 0; i < visibles.size(); i++){
+            for (int i = 0; i < visibles.size(); i++) {
                 Integer index = uuidIndexMap.get(visibles.get(i));
-                if(Objects.isNull(index)){
+                if (Objects.isNull(index)) {
                     continue;
                 }
                 visiblesList.add(index);
             }
             sweepLocationObj.put("visibles", visiblesList);
 
-            if(sweepLocationObj.containsKey(visibles_2)){
-                JSONArray visibles2 =  sweepLocationObj.getJSONArray(visibles_2);
+            if (sweepLocationObj.containsKey(visibles_2)) {
+                JSONArray visibles2 = sweepLocationObj.getJSONArray(visibles_2);
                 List<Integer> visibles2List = new ArrayList<>();
-                for(int i = 0; i < visibles2.size(); i++){
+                for (int i = 0; i < visibles2.size(); i++) {
                     Integer index = uuidIndexMap.get(visibles2.get(i));
-                    if(Objects.isNull(index)){
+                    if (Objects.isNull(index)) {
                         continue;
                     }
                     visibles2List.add(index);
@@ -172,13 +168,12 @@ public class ConvertUtils {
                 sweepLocationObj.put(visibles_2, visibles2List);
             }
 
-            if(sweepLocationObj.containsKey(visibles_3)){
-                JSONArray visibles3 =  sweepLocationObj.getJSONArray(visibles_3);
-//				int[] visiblesArr3 = new int[visibles3.size()];
+            if (sweepLocationObj.containsKey(visibles_3)) {
+                JSONArray visibles3 = sweepLocationObj.getJSONArray(visibles_3);
                 List<Integer> visibles3List = new ArrayList<>();
-                for(int i = 0; i < visibles3.size(); i++){
+                for (int i = 0; i < visibles3.size(); i++) {
                     Integer index = uuidIndexMap.get(visibles3.get(i));
-                    if(Objects.isNull(index)){
+                    if (Objects.isNull(index)) {
                         continue;
                     }
                     visibles3List.add(index);

+ 3 - 4
src/main/java/com/fdkankan/scene/Interceptor/CheckTokenAspect.java

@@ -65,10 +65,9 @@ public class CheckTokenAspect {
 		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
 
 		//请求4a接口获取用户信息
-		Map<String, Object> parameter = WebUtil.getParameter(joinPoint, request);
-		String acctId = (String) parameter.get("acctId");
-		String token = (String) parameter.get("token");
-		String num = (String) parameter.get("num");
+		String acctId = WebUtil.getParameter(joinPoint, request, "acctId", String.class);
+		String token = WebUtil.getParameter(joinPoint, request, "token", String.class);
+		String num = WebUtil.getParameter(joinPoint, request, "num", String.class);
 
 		//token校验
 		JSONObject checkProwadaTokenParam = new JSONObject();

+ 4 - 14
src/main/java/com/fdkankan/scene/Interceptor/ViewLogAspect.java

@@ -82,11 +82,10 @@ public class ViewLogAspect {
 		}
 
 		//请求4a接口获取用户信息
-		Map<String, Object> parameter = WebUtil.getParameter(joinPoint, request);
-		String acctId = (String) parameter.get("acctId");
-		String token = (String) parameter.get(TOKEN_KEY.toLowerCase());
-		String num = (String) parameter.get("num");
-        String syscode = (String) parameter.get("syscode");
+		String acctId = WebUtil.getParameter(joinPoint, request, "acctId", String.class);
+		String token = WebUtil.getParameter(joinPoint, request, TOKEN_KEY.toLowerCase(), String.class);
+		String num = WebUtil.getParameter(joinPoint, request, "num", String.class);
+		String syscode = WebUtil.getParameter(joinPoint, request, "syscode", String.class);
 
 		//token校验
 		JSONObject checkProwadaTokenParam = new JSONObject();
@@ -167,13 +166,4 @@ public class ViewLogAspect {
 		sceneViewLogService.save(sceneViewLog);
 	}
 
-	public static void main(String[] args) {
-		JSONObject param2 = new JSONObject();
-		param2.put(SERVICE_ID, "CHNTRMS2");
-		param2.put("LOGINACCOUNT", "wx-sunql3");
-		param2.put(TOKEN_KEY, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJSRVMiLCJpc3MiOiJXUzRBIiwiZXhwIjoxNzMzMzEwNjY1LCJOQU5PU0VDT05EIjo0MjAxNTczODIzODYyMjgzOH0.sQR4qkTeRZEOQMI-Rjck35dFswoOMYHsGSuNcXH45TI");
-		String encode = ThreeDESUtil.encode(JSON.toJSONString(param2), "6#dPz>3F");
-		System.out.println(encode);
-	}
-
 }