Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8015783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:21:06+00:00 2026-06-04T20:21:06+00:00

Background The FreeLing API defines an interface that does not adhere to standard Java

  • 0

Background

The FreeLing API defines an interface that does not adhere to standard Java naming conventions. For example:

package freeling;

public class sentence extends ListWord {
  public void set_parse_tree(parse_tree arg0) {

The interface is defined using SWIG, which is similar to IDL:

class sentence : public std::list<word> {
 public:
  sentence(void);

  void set_parse_tree(const parse_tree &);

Problem

Academically speaking, how would you map the interface to conventional Java naming standards (e.g., class Sentence and setParseTree( parseTree arg0 ))?

Ideas

  1. Convert the 650+ line interface file manually (and send a patch to the developers).
  2. Regex search and replace voodoo (using vi): :1,$s/_\([a-z]\)/\u\1/g
  3. Create wrapper classes from the 53 auto-generated Java source files.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:21:08+00:00Added an answer on June 4, 2026 at 8:21 pm

    SWIG provides a %rename directive that allows the names to be different in the client and implementation languages. But doing this will nearly double the length of the interface file.

    Actually, SWIG provides bulk renaming. See the documentation

    5.4.7.2 Advanced renaming support

    While writing %rename for specific declarations is simple enough, sometimes the same renaming rule needs to be applied to many, maybe all, identifiers in the SWIG input. For example, it may be necessary to apply some transformation to all the names in the target language to better follow its naming conventions, like adding a specific prefix to all wrapped functions. Doing it individually for each function is impractical so SWIG supports applying a renaming rule to all declarations if the name of the identifier to be renamed is not specified:

    %rename("myprefix_%s") ""; // print -> myprefix_print
    

    This also shows that the argument of %rename doesn’t have to be a literal string but can be a printf()-like format string. In the simplest form, "%s" is replaced with the name of the original declaration, as shown above. However this is not always enough and SWIG provides extensions to the usual format string syntax to allow applying a (SWIG-defined) function to the argument. For example, to wrap all C functions do_something_long() as more Java-like doSomethingLong() you can use the "lowercamelcase" extended format specifier like this:

    %rename("%(lowercamelcase)s") ""; // foo_bar -> fooBar; FooBar -> fooBar
    

    Some functions can be parametrized, for example the "strip" one strips the provided prefix from its argument. The prefix is specified as part of the format string, following a colon after the function name:

    %rename("%(strip:[wx])s") ""; // wxHello -> Hello; FooBar -> FooBar
    

    My recommendation is just to leave it as-is. You’re calling C++ functions, they have C++ names. If anything, this helps you remember that you’re calling out to C++ and need to follow C++ rules for object lifetime management, there’s a slight JNI performance penalty, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: the current text editor i am using does not have built-in support for
I'm trying to fill devexpress GridControl in background (it's not quick process). I do
Background I'm writing an part of my app that has no UI. It sits
Can anyone recommend a Java library that would allow me to create a video
The Problem: Background Information I'm writing an application for a client that is to
Far I've found that giving the iframe a background colour will alter the timeline
I have a feeling that this should really not be all that difficult, yet
I've created a semi-transparent form (60% opacity with black background color) that my app
Coming from a Java background, I'm used to the common practice of dealing with
Background: I have a file monitoring service that watches for changes in the files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.