Informatization system developed by Java and method for generating text in two-in-one format
By obtaining and deserializing the CTRPr configuration object in Word text and generating text in two-line-in-one format, the problem that Java information system cannot create text in two-line-in-one format is solved, the function of representing component dimension tolerances is realized, and related work efficiency and data value are improved.
Patent Information
- Application Number
- CN202411891839.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-05-30
AI Technical Summary
Information systems developed by Java cannot create a double-line-in-one format that represents component dimension tolerances in their electronic documents.
By obtaining the serialization file of the CTRPr configuration object in Word text in a two-line-in-one format, deserialization process is performed to generate the configuration object, and using the object to generate the two-line-in-one format text during the Java software program run.
It realizes the function of creating a double-row-in-one format representing component dimension tolerances in the information system developed by Java language, supports the implementation of scenarios such as electronicization of industrial design information and electronicization of quality inspection, and improves work efficiency and data value.
Smart Images

Figure CN120068797A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of software development, and particularly relates to an information system developed in Java and a method for generating a double-line combined format text. Background Art
[0002] In recent years, with the continuous development of information technology, more and more enterprises use electronic information systems to manage products and verify data, and various mathematical symbols and complex formats may appear. For example, in the design and production process of mechanical parts, deviation amounts are usually added to the upper right and lower right of the standard dimension value of the part to represent the dimensional tolerance of the part, such as 30+3 -3. This format is implemented through the "double-line combined" format in Word. However, the information system developed in Java cannot create a double-line combined format representing the dimensional tolerance of parts in its electronic document, which restricts the implementation and application of the corresponding information functions. Summary of the Invention
[0003] The purpose of the present invention is to provide an information system developed in Java and a method for generating a double-line combined format text, so as to solve the problem that the information system developed in Java cannot create a double-line combined format representing the dimensional tolerance of parts in its electronic document.
[0004] The present invention provides a method for generating a double-line combined format text in an information system developed in Java to solve the above technical problems, and the steps are as follows: obtaining a serialized file of a CTRPr configuration object in a Word text containing a double-line combined format; performing deserialization processing on the serialized file of the CTRPr configuration object to generate a configuration object during the operation of the Java software program, and generating a double-line combined format text during the operation of the Java software program according to the generated configuration object; adding the generated double-line combined format text to the electronic document.
[0005] Further, the serialized file of the CTRPr configuration object in the Word text containing a double-line combined format is obtained through preprocessing, and the preprocessing process includes: reading a Word text containing a double-line combined format before the operation of the Java software program, obtaining the CTRPr configuration object of the Word text, performing serialization operation on the CTRPr configuration object, obtaining a serialized file and storing it.
[0006] Further, the Apache POI library is used to preprocess the Word text containing a double-line combined format to obtain a serialized file.
[0007] Further, during the software operation, the serialized file containing the CTRPr configuration object in the Word text in the double-line combined format is obtained by directly calling the stored serialized file.
[0008] The beneficial effects of the above technical solution are as follows: The present invention is an exploratory invention. Aiming at the problem that the information system developed in Java software cannot create a text in the double-line combined format, the serialized file containing the CTRPr configuration object in the Word text in the double-line combined format is obtained through serialization operation. When it is necessary to generate a text in the double-line combined format during the actual operation of the software, a new configuration object is generated through deserialization, and then a text in the double-line combined format is generated during the operation of the Java software program, realizing the function of creating a double-line combined format representing the dimensional tolerance of parts in the information system developed in the Java language.
[0009] To solve the above technical problems, the present invention also provides an information system developed in Java, which can generate a text in the double-line combined format. The steps of generating the double-line combined text include: obtaining the serialized file containing the CTRPr configuration object in the Word text in the double-line combined format; performing deserialization processing on the serialized file of the CTRPr configuration object to generate a configuration object during the operation of the Java software program, and generating a text in the double-line combined format during the operation of the Java software program according to the generated configuration object; adding the generated text in the double-line combined format to the electronic document.
[0010] Further, the serialized file containing the CTRPr configuration object in the Word text in the double-line combined format is obtained through preprocessing. The preprocessing process includes: reading the Word text in the double-line combined format before the Java software program runs, obtaining the CTRPr configuration object of the Word text, performing serialization operation on the CTRPr configuration object, and storing the obtained serialized file.
[0011] Further, the Apache POI library is used to preprocess the Word text in the double-line combined format to obtain the serialized file.
[0012] Further, during the software operation, the serialized file containing the CTRPr configuration object in the Word text in the double-line combined format is obtained by directly calling the stored serialized file.
[0013] The beneficial effects of the above technical solution are as follows: The present invention is an exploratory invention. Aiming at the problem that information systems developed in Java software cannot create text in the double-line combined format, a serialized file of the CTRPr configuration object in the Word text containing the double-line combined format is obtained through serialization operation. When the software actually runs and needs to generate text in the double-line combined format, a new configuration object is generated through deserialization, and then text in the double-line combined format is generated during the operation of the Java software program, realizing the function of creating the double-line combined format representing the dimensional tolerance of parts in the information system developed in the Java language. Brief Description of the Drawings
[0014] Figure 1 It is a flowchart of generating text in the double-line combined format in the information system developed in Java software in the method embodiment of the present invention. Detailed Embodiments
[0015] In order to make the purpose, technical solution and advantages of the present invention clearer, the following further describes the detailed embodiments of the present invention with reference to the drawings.
[0016] Apache POI in the Office document API library can generate the double-line combined format in Word, but it does not provide an operation interface for the double-line combined format, and the class that generates the double-line combined format in Word is internal and private, and there is no external access permission. Therefore, it is impossible to directly call Apache POI to create an object in the double-line combined format in the information system developed in the Java language. Considering that the CTRPr object in the Word text implements the serialization interface, the present invention designs a method based on Apache POI to create text in the double-line combined format in the information system developed in the Java language. This method obtains a serialized file of the CTRPr configuration object in the Word text containing the double-line combined format through serialization operation. When the software actually runs and needs to generate text in the double-line combined format, a new configuration object is generated through deserialization, and then text in the double-line combined format is generated during the operation of the Java software program, realizing the function of creating the double-line combined format representing the dimensional tolerance of parts in the information system developed in the Java language, and can correctly and quickly represent and export the dimensional tolerance representation methods commonly used by designers, producers and inspectors in the information system, supporting the implementation of scenarios such as industrial design information electronization, quality inspection electronization, and electronic certificates, and helping enterprises improve the relevant work efficiency and data value by means of information technology.
[0017] Method Embodiment A method for generating text in the double-line combined format in an information system developed in Java of the present invention, as Figure 1As shown, the method includes the following steps: 1. Preprocessing stage.
[0018] Before the Java software program runs, read the Word text in the double-line combined format, obtain the CTRPr configuration object of the Word text, perform serialization operations on the CTRPr configuration object, obtain a serialized file containing the CTRPr configuration object in the Word text in the double-line combined format, and store it. The CTRPr object is used to define the style attributes of the text. In the present invention, the Apache POI library is used to preprocess the Word text in the double-line combined format, read the Word text in the double-line combined format stored in the set path, obtain the CTRPr configuration object of the Word text, and perform serialization operations on the CTRPr configuration object to obtain a serialized file.
[0019] The code implementation is as follows: / / First, prepare a Word document named sample.docx; this document has only one paragraph, and this paragraph is the Word text in the double-line combined format String filePath = " / sample.docx": / / Create a file input stream to read the sample Word text in the form of a byte stream try (FileInputStream fis = new FileInputStream(filePath); / / Use the API provided by the Apache POI library to read the Word document and generate a document object XWPFDocument document = new XWPFDocument(fis)) { / / Obtain the first one among all the paragraph objects of the document object XWPFParagraph xwpfParagraph = document.getParagraphs().get(0); / / Obtain the first one among all the text objects in this paragraph XWPFRun xwpfRun = xwpfParagraph.getRuns().get(0); / / Obtain the CTRPr configuration object of this text object CTRPr rPr = xwpfRun.getCTR().getRPr(); / / Create a file output stream, and name the target file "word-lines-merge.obj" try (FileOutputStream fileOut = new FileOutputStream("word-lines-merge.obj"); / / Create an object output stream ObjectOutputStream out = new ObjectOutputStream(fileOut)) { / / Serialize and store the CTRPr configuration object obtained from the Word text into the "word-lines-merge.obj" file out.writeObject(rPr); / / Catch and handle exceptions } catch (IOException e) {} } catch (IOException e) {} 2. During the software operation, generate text in the combined double-line format.
[0020] Specifically, read the serialized file of the CTRPr configuration object in the Word text in the combined double-line format; perform deserialization on the serialized file of the CTRPr configuration object to generate a configuration object during the operation of the Java software program, generate text in the combined double-line format during the operation of the Java software program according to the generated configuration object; add the generated text in the combined double-line format to the electronic document. The present invention obtains the serialized file of the CTRPr configuration object in the Word text in the combined double-line format by directly calling the serialized file stored during preprocessing.
[0021] The code implementation is as follows: / / When creating a Java project, place the "word-lines-merge.obj" file in the root directory of the classpath / / During operation, first use the API provided by the Apache POI library to read the Word document and obtain the paragraphs that need to add text in the combined double-line format / / Assume the above steps have been completed. Call this method and pass in the paragraph object and the superscript and subscript content. You can append text in the combined double-line format after the paragraph. For example, if top = +3 and bottom = -5, then append +3 -5 private static void appendCombinedLines(XWPFParagraph paragraph, String top, String bottom) { / / Create a reference to the CTRPr configuration object CTRPr ctrPr = null; / / Create a file input stream to read the word-lines-merge.obj serialized file try (FileInputStream fileInputStream = new FileInputStream("word-lines-merge.obj")) { / / Create an object input stream ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); / / Use the object input stream to read the word-lines-merge.obj serialized file and deserialize the content in it to generate a CTRPr configuration object during the running of the Java software program ctrPr = (CTRPr )objectInputStream.readObject(); } catch (ClassNotFoundException | IOException e) {} / / Append a text after the paragraph and obtain the text object XWPFRun run = paragraph.createRun(); / / Set the CTR of this text to the CTRPr configuration object using the double-line merge format run.getCTR().setRPr(ctrPr); / / Add the generated double-line merge format text to the electronic document run.setText(top + " " + bottom); } Embodiment of an information system developed in Java An information system developed in Java according to the present invention. This system can generate text in the double-line merge format. The method for generating the double-line merge text is the method for generating text in the double-line merge format in the information system developed in Java described in the above method embodiments, which will not be elaborated here.
Claims
1. A method for generating a double-line-in-one format text in an information system developed in Java, characterized in that: The steps include: Get the serialized file containing the CTRPr configuration object in the Word text in double-line format; Deserialize the serialized file of the CTRPr configuration object to generate a configuration object during the running of the Java software program, and generate a two-line-in-one format text according to the generated configuration object during the running of the Java software program; Add the generated double-line formatted text to the electronic document in the information system.
2. The method for generating a two-line-in-one format text in an information system developed in Java according to claim 1, characterized in that: The serialized file of the CTRPr configuration object in the Word text containing the two-line-in-one format is obtained by preprocessing, and the preprocessing process includes: reading the Word text containing the two-line-in-one format before the Java software program is run, obtaining the CTRPr configuration object of the Word text, serializing the CTRPr configuration object, obtaining the serialized file and storing it.
3. The method for generating a two-line-in-one format text in an information system developed in Java according to claim 2, characterized in that: The Apache POI library is used to preprocess the Word text containing the double-line-in-one format to obtain a serialized file.
4. The method for generating a two-line-in-one format text in an information system developed in Java according to claim 1, characterized in that: During the software running process, the serialized file containing the CTRPr configuration object in the Word text in the double-line-in-one format is obtained by directly calling the stored serialized file.
5. An information system developed in Java, characterized in that: The system can generate a two-line-in-one format text, and the steps of generating the two-line-in-one format text include: obtaining a serialized file of a CTRPr configuration object in a Word text containing the two-line-in-one format; deserializing the serialized file of the CTRPr configuration object to generate a configuration object during the running of a Java software program, and generating a two-line-in-one format text during the running of the Java software program according to the generated configuration object; and adding the generated two-line-in-one format text to an electronic document.
6. The information system developed in Java according to claim 5, characterized in that: The serialized file of the CTRPr configuration object in the Word text containing the two-line-in-one format is obtained by preprocessing, and the preprocessing process includes: reading the Word text containing the two-line-in-one format before the Java software program is run, obtaining the CTRPr configuration object of the Word text, serializing the CTRPr configuration object, obtaining the serialized file and storing it.
7. The information system developed in Java according to claim 6, characterized in that: The Apache POI library is used to preprocess the Word text containing the double-line-in-one format to obtain a serialized file.
8. The information system developed in Java according to claim 5, characterized in that: During the software running process, the serialized file containing the CTRPr configuration object in the Word text in the double-line-in-one format is obtained by directly calling the stored serialized file.