code-generation

Can a Java class add a method to itself at runtime?

二次信任 提交于 2019-11-26 11:20:27
Can a class add a method to itself at runtime (like from a static block), so that if someone is performing reflection on this class, they'll see the new method, even though it wasn't defined at compile time? Background: A framework I'm using expects Action classes to be defined that have a doAction(...) method, by convention. The framework inspects these classes at runtime to see what type of parameters are available in their doAction() method. For example: doAction( String a, Integer b) I'd like each class to be able to programatically generate its doAction() method with various parameters,

Is it possible to use Razor View Engine outside asp.net

我的梦境 提交于 2019-11-26 11:11:42
If I look at the Razor View Engine, then I see a very nice and concise syntax that is not particularly tied to generating html. So I wonder, how easy would it be to use the engine outside asp.net in a "normal" .net environment for example to generate text, code,... Any pointer, example, comment or explanation is welcome. marcind There are two issues here: Yes, you can run the Razor View Engine outside of the context of an ASP.NET app domain, as explained in Andrew's blog: http://vibrantcode.com/blog/2010/11/16/hosting-razor-outside-of-aspnet-revised-for-mvc3-rc.html However, Razor is still

Rails migration for has_and_belongs_to_many join table

只愿长相守 提交于 2019-11-26 10:08:01
问题 How do I do a script/generate migration to create a join table for a has_and_belongs_to_many relationship? The application runs on Rails 2.3.2, but I also have Rails 3.0.3 installed. 回答1: Where: class Teacher < ActiveRecord::Base has_and_belongs_to_many :students end and class Student < ActiveRecord::Base has_and_belongs_to_many :teachers end for rails 4: rails generate migration CreateJoinTableStudentTeacher student teacher for rails 3: rails generate migration students_teachers student_id

Generate JPA 2 Entities from existing Database

纵饮孤独 提交于 2019-11-26 08:06:13
问题 How can I generate JPA2 compliant @Entity from existing Databases?. I found this: Question Still its not clear if JBoss will generate compliant JPA2 and also I would like to know if there is a vendor independent way to do this. 回答1: You can use a plugin like Eclipse Dali to do the trick for you. You can refer to the documentation, section 3.11 Generating Entities from Tables. I do not know of any specific vendor independent tool to do this, though. 回答2: Try using OPENJPA Reverse mapping tools

How can I automatically add some skeleton code when creating a new file with vim

▼魔方 西西 提交于 2019-11-26 07:29:20
问题 When creating a new file with vim, I would like to automatically add some skeleton code. For example, when creating a new xml file, I would like to add the first line: <?xml version=\"1.0\"?> Or when creating an html file, I would like to add: <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> <html> <head> <title></title> </head> <body> </body> </html> 回答1: If you want to adapt your skeleton to the context, or to the user choices

Generate Delete Statement From Foreign Key Relationships in SQL 2008?

£可爱£侵袭症+ 提交于 2019-11-26 07:27:47
问题 Is it possible via script/tool to generate a delete statement based on the tables fk relations. i.e. I have the table: DelMe(ID) and there are 30 tables with fk references to its ID that I need to delete first, is there some tool/script that I can run that will generate the 30 delete statements based on the FK relations for me ? (btw I know about cascade delete on the relations, I can\'t use it in this existing db) I\'m using Microsoft SQL Server 2008 回答1: DELETE statements generated for use

How do I generate a constructor from class fields using Visual Studio (and/or ReSharper)?

落爺英雄遲暮 提交于 2019-11-26 07:25:40
问题 I\'ve gotten accustomed to many of the Java IDEs (Eclipse, NetBeans, and IntelliJ IDEA) providing you with a command to generate a default constructor for a class based on the fields in the class. For example: public class Example { public decimal MyNumber { get; set; } public string Description { get; set; } public int SomeInteger { get; set; } // ↓↓↓ This is what I want generated ↓↓↓ public Example(decimal myNumber, string description, int someInteger) { MyNumber = myNumber; Description =

return only Digits 0-9 from a String

谁说胖子不能爱 提交于 2019-11-26 06:36:44
问题 I need a regular expression that I can use in VBScript and .NET that will return only the numbers that are found in a string. For Example any of the following \"strings\" should return only 1231231234 123 123 1234 (123) 123-1234 123-123-1234 (123)123-1234 123.123.1234 123 123 1234 1 2 3 1 2 3 1 2 3 4 This will be used in an email parser to find telephone numbers that customers may provide in the email and do a database search. I may have missed a similar regex but I did search on regexlib.com

Comparison of XSD Code Generators [closed]

一笑奈何 提交于 2019-11-26 04:59:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I\'m doing some research in code generation from xsd schema files. My requirements: Must generate C# 2.0 code (or above), using generic collections where needed. Must generate comments from the xsd comments Must generate fully serializable code. Should be able to generate resuable basetypes when generating from

How can I create database tables from XSD files? [closed]

Deadly 提交于 2019-11-26 04:41:30
问题 I have a set of XSDs from which I generate data access classes, stored procedures and more. What I don\'t have is a way to generate database table from these - is there a tool that will generate the DDL statements for me? This is not the same as Create DB table from dataset table, as I do not have dataset tables, but XSDs. 回答1: Commercial Product: Altova's XML Spy. Note that there's no general solution to this. An XSD can easily describe something that does not map to a relational database.